Skip to content

Commit

Permalink
resolve TS error
Browse files Browse the repository at this point in the history
  • Loading branch information
filipKovachev committed Dec 2, 2024
1 parent b194db9 commit 5e776b3
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions examples/ecommerce-jewellery-store/src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const Header: React.FC = () => {
};

const handleMenuSelect = (event: MenuSelectEvent) => {
const selectedItem: CustomMenuItemModel = event.item;
const selectedItem = event.item as CustomMenuItemModel;

if (selectedItem.page) {
navigate(selectedItem.page);
Expand All @@ -62,15 +62,17 @@ const Header: React.FC = () => {
};

const handleLanguageMenuSelect = (event: MenuSelectEvent) => {
const selectedLanguage = event.item.id?.replace("lang-", "");
if (selectedLanguage) {
const selectedItem = event.item as CustomMenuItemModel;
const selectedLanguage = selectedItem.id?.replace("lang-", "") as "en" | "fr" | "es";

if (["en", "fr", "es"].includes(selectedLanguage)) {
setLanguage(selectedLanguage);
console.log(`Language changed to: ${selectedLanguage}`);
} else {
console.error(`Invalid language selected: ${selectedLanguage}`);
}
};

const translatedItems = items.map((item) => ({
...item,
text: t[`menu${item.text}`] || item.text,
Expand Down

0 comments on commit 5e776b3

Please sign in to comment.