'use client'; // Fixed navigation with language, theme, account, and cart controls. import {useState, useEffect} from 'react'; import Image from 'next/image'; import Link from 'next/link'; import {usePathname} from 'next/navigation'; import {Badge, Button} from 'antd'; import {ShoppingCartOutlined, MenuOutlined, CloseOutlined, UserOutlined} from '@ant-design/icons'; import {useAppSelector} from '@/store/hooks'; import {selectCartCount} from '@/store/cartSlice'; import {useLanguage} from '@/app/context/LanguageContext'; import {commerceCopy} from '@/data/commerce'; import {accountCopy} from '@/data/account'; import {useAuth} from '@/app/context/AuthContext'; import ProtectedLink from './auth/ProtectedLink'; import ThemeToggle from './ThemeToggle'; import LanguageToggle from './LanguageToggle'; export default function Header() { const pathname = usePathname(); const cartCount = useAppSelector(selectCartCount); const {t, locale} = useLanguage(); const auth = useAuth(); const account = accountCopy[locale]; const [scrolled, setScrolled] = useState(false); const [mobileOpen, setMobileOpen] = useState(false); const navLinks = [ {href: '/#hero', label: t.nav.home}, {href: '/products', label: commerceCopy[locale].allProducts}, {href: '/#about', label: t.nav.about}, {href: '/#locations', label: t.nav.locations}, ]; const accountLabel = auth.session?.profile.firstName ? `${auth.session.profile.firstName} ${auth.session.profile.lastName}`.trim() : auth.session?.profile.phone || account.login; useEffect(() => { const onScroll = () => setScrolled(window.scrollY > 24); onScroll(); window.addEventListener('scroll', onScroll); return () => window.removeEventListener('scroll', onScroll); }, []); console.log('%c👋 Hamed Abdollahzade · Frontend Developer', 'font-size:14px;font-weight:600;'); return (
setMobileOpen(false)} className="flex items-center gap-2 shrink-0"> روبات مارکت
{auth.isAuthenticated ? ( ) : ( )} setMobileOpen(false)} className="w-11 h-11 rounded-full border border-subtle bg-elevated inline-flex items-center justify-center text-xl text-primary hover:text-brand-400" >
{mobileOpen && ( )}
); }