"use client"; import Image from "next/image"; import Link from "next/link"; import { useEffect, useState } from "react"; import { cartCount } from "@/lib/cart"; import { parentCategories } from "@/lib/data"; import { SITE } from "@/lib/site"; import { IconCart, IconChevron, IconClose, IconMenu, IconUser } from "./Icons"; import { SearchBox } from "./SearchBox"; const nav = [ { name: "فروش ویژه", href: "#special-sale" }, { name: "درباره ما", href: "/aboutus" }, { name: "سوالات متداول", href: "/frequently-asked-questions" }, { name: "تماس با ما", href: "/contactus" }, ]; export function Header() { const [open, setOpen] = useState(false); const [mega, setMega] = useState(false); const [count, setCount] = useState(0); useEffect(() => { const sync = () => setCount(cartCount()); sync(); window.addEventListener("cart-updated", sync); window.addEventListener("storage", sync); return () => { window.removeEventListener("cart-updated", sync); window.removeEventListener("storage", sync); }; }, []); return (
{SITE.nameFa}
ورود / ثبت نام {count.toLocaleString("fa-IR")}
{open && (
setOpen(false)} />

محصولات

{parentCategories.map((cat) => (
setOpen(false)}> {cat.name}
    {cat.children.slice(0, 6).map((child) => (
  • setOpen(false)}> {child.name}
  • ))}
))}
{nav.map((item) => ( setOpen(false)}> {item.name} ))} ورود / ثبت نام
)}
); }