diff --git a/frontend/application/components/Header.tsx b/frontend/application/components/Header.tsx index 3cefcf57..532307ca 100644 --- a/frontend/application/components/Header.tsx +++ b/frontend/application/components/Header.tsx @@ -47,27 +47,46 @@ export default function Header({ title: string; icon: React.ReactNode; solutions: string[]; - }[]>([]); - - const petMenuRef = useRef(null); - - const { getTotalItems } = useCartStore(); - const { pets, activePetId, setActivePet, getActivePet } = usePetStore(); - const { role, isLoggedIn, logout, profile } = useUserStore(); - const activePet = getActivePet(); - const getText = useSettingsStore(state => state.getText); + }[]>([ + { + id: "joints", + title: "مفاصل و استخوان", + icon: MENU_ICONS["joints"], + solutions: ["لنگیدن", "سختی در بلند شدن", "درد مفاصل", "رشد سریع توله‌سگ", "پاهای پرانتزی", "ضعف تاندون"] + }, + { + id: "immune", + title: "تقویت سیستم ایمنی و گوارش", + icon: MENU_ICONS["immune"], + solutions: ["ضعف بعد از بیماری", "بی‌اشتهایی", "بعد از زایمان", "اسهال", "مشکلات گوارشی"] + }, + { + id: "energy", + title: "ویتامین‌ها و انرژی‌بخش‌ها", + icon: MENU_ICONS["energy"], + solutions: ["نفس‌نفس زدن", "خستگی", "سن بالا", "بی‌حالی"] + }, + { + id: "special-care", + title: "مراقبت‌های ویژه (پوست، دندان و چشم)", + icon: MENU_ICONS["special-care"], + solutions: ["ریزش مو", "خشکی پوست", "خارش", "جرم دندان", "سوزش چشم"] + } + ]); useEffect(() => { const loadNavFilters = async () => { try { const data = await productService.getNavigationFilters(); - const mapped = data.map(item => ({ - id: item.slug, - title: item.name, - icon: MENU_ICONS[item.slug] || , - solutions: item.symptoms - })); - setMenuItems(mapped); + if (data && data.length > 0) { + const mapped = data.map(item => ({ + id: item.slug, + title: item.name, + icon: MENU_ICONS[item.slug] || , + solutions: item.symptoms || [] + })); + setMenuItems(mapped); + } } catch (e) { console.error("Failed to load navigation filters:", e); } @@ -417,14 +436,56 @@ export default function Header({ {/* Medium Screen Sub-Navbar (Visible only between 800px and 1224px) */} -
- +
+
+ + + + {isMegaMenuOpen && ( + + {menuItems.map((item, idx) => ( +
+ setIsMegaMenuOpen(false)} + className="flex items-center gap-3 mb-3 cursor-pointer block" + > +
+ {item.icon} +
+

{item.title}

+ + {item.solutions.length > 0 && ( +
+ {item.solutions.slice(0, 6).map((sol, sIdx) => ( + setIsMegaMenuOpen(false)} + > + {sol} + + ))} +
+ )} +
+ ))} +
+ )} +
+
{[ { id: 'shop', label: getText('nav_products', 'محصولات تخصصی'), href: '/shop' },