'use client' import Link from 'next/link' import Image from 'next/image' import { useState, useEffect } from 'react' import { motion, AnimatePresence } from 'framer-motion' import { ChevronDown, Menu, X, Wheat, Leaf, Package, Building2, Settings, ShoppingBag, LogOut, LucideIcon } from 'lucide-react' import { Button } from '@/components/ui/button' import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar' import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger } from '@/components/ui/dropdown-menu' import { useSession, signOut } from 'next-auth/react' import CartSidebar from '@/components/shop/CartSidebar' import MegaMenu from '@/components/layout/MegaMenu' import { isFeatureEnabled } from '@/lib/business-config' interface MenuItem { name: string href: string description: string } interface MenuCategory { name: string icon: LucideIcon items: MenuItem[] } interface MegaMenuConfig { title: string type: 'categories' categories: MenuCategory[] } export function Header() { const [mobileMenuOpen, setMobileMenuOpen] = useState(false) const [activeDropdown, setActiveDropdown] = useState(null) const [isScrolled, setIsScrolled] = useState(false) const navItems = [ // { name: 'Home', href: '/' }, { name: 'Recipes', href: '/recipes' }, // { name: 'About', href: '/about' }, { name: 'Contact', href: '/contact' }, ] const megaMenus: Record = { products: { title: 'Products', type: 'categories' as const, categories: [] // Will be populated dynamically by MegaMenu component }, company: { title: 'Company', type: 'categories' as const, categories: [ { name: 'About Us', icon: Building2, items: [ { name: 'Our Story', href: '/about', description: 'Company history and mission' }, { name: 'Our Founder', href: '/about/founder', description: 'Meet our visionary leader' }, { name: 'Certifications', href: '/about/certifications', description: 'Industry recognition' }, ] }, { name: 'Business', icon: Settings, items: [ { name: 'Partnership', href: '/partnership', description: 'Join our network' }, { name: 'Wholesaler', href: '/wholesaler', description: 'Wholesaler program' }, { name: 'Sustainability', href: '/sustainability', description: 'Environmental commitment' }, ] }, ] } } const { data: session } = useSession() const adminNavigation = [ { name: 'Admin Dashboard', href: '/admin', icon: Settings }, { name: 'Manage Products', href: '/admin/products', icon: Package }, { name: 'Manage Orders', href: '/admin/orders', icon: ShoppingBag }, ] const memberNavigation = [ { name: 'Dashboard', href: '/dashboard', icon: Settings }, { name: 'My Orders', href: '/dashboard/orders', icon: ShoppingBag }, { name: 'Profile', href: '/dashboard/profile', icon: Settings }, ] // Scroll detection for sticky header useEffect(() => { const handleScroll = () => { const scrollTop = window.scrollY const scrolled = scrollTop > 0 setIsScrolled(scrolled) // Add/remove class to body for content padding if (scrolled) { document.body.classList.add('header-sticky') } else { document.body.classList.remove('header-sticky') } } window.addEventListener('scroll', handleScroll) return () => { window.removeEventListener('scroll', handleScroll) document.body.classList.remove('header-sticky') } }, []) useEffect(() => { if (mobileMenuOpen) { document.body.style.overflow = 'hidden' } else { document.body.style.overflow = 'unset' } return () => { document.body.style.overflow = 'unset' } }, [mobileMenuOpen]) const handleMouseEnter = (dropdown: string) => { setActiveDropdown(dropdown) } const handleMouseLeave = () => { setActiveDropdown(null) } const handleMobileMenuClick = () => { setMobileMenuOpen(!mobileMenuOpen) } const handleMobileLinkClick = () => { setMobileMenuOpen(false) } return ( ) }