546 lines
29 KiB
TypeScript
546 lines
29 KiB
TypeScript
"use client";
|
||
|
||
import React, { useState, useRef, useEffect } from "react";
|
||
import { Search, ChevronDown, Menu, X, Pill, ShieldCheck, HeartPulse, Sparkles, ShoppingBag, User, Check, Building2, LogIn, LogOut, FileHeart, Dog, BookOpen, FileText, Video, Award, PhoneCall, Activity } from "lucide-react";
|
||
import { motion, AnimatePresence } from "motion/react";
|
||
import Link from "next/link";
|
||
import { useCartStore } from "../lib/store/cartStore";
|
||
import { usePetStore } from "../lib/store/usePetStore";
|
||
import { useUserStore } from "../lib/store/userStore";
|
||
import { useSettingsStore } from "../lib/store/settingsStore";
|
||
import { toast } from "sonner";
|
||
import AuthModal from "./AuthModal";
|
||
import PrescriptionUploadModal from "./PrescriptionUploadModal";
|
||
import TickerBanner from "./TickerBanner";
|
||
import { cn } from "../lib/utils";
|
||
import { productService } from "../lib/services/productService";
|
||
|
||
const MENU_ICONS: Record<string, React.ReactNode> = {
|
||
joints: <Pill className="w-5 h-5" />,
|
||
immune: <ShieldCheck className="w-5 h-5" />,
|
||
energy: <HeartPulse className="w-5 h-5" />,
|
||
"special-care": <Sparkles className="w-5 h-5" />,
|
||
};
|
||
|
||
import { NavigationTarget } from "../lib/types";
|
||
|
||
export default function Header({
|
||
onCartOpen = () => {},
|
||
onSearch = () => {},
|
||
onB2BOpen = () => {}
|
||
}: {
|
||
onNavigate?: (v: NavigationTarget) => void;
|
||
onShopNavigate?: (c?: string, s?: string) => void;
|
||
currentView?: string;
|
||
onCartOpen?: () => void;
|
||
onSearch?: (q: string) => void;
|
||
onB2BOpen?: () => void;
|
||
}) {
|
||
const [isMegaMenuOpen, setIsMegaMenuOpen] = useState(false);
|
||
const [activeDropdown, setActiveDropdown] = useState<string | null>(null);
|
||
const [isAuthModalOpen, setIsAuthModalOpen] = useState(false);
|
||
const [isPrescriptionModalOpen, setIsPrescriptionModalOpen] = useState(false);
|
||
const [isProfileMenuOpen, setIsProfileMenuOpen] = useState(false);
|
||
const userProfileRef = useRef<HTMLDivElement>(null);
|
||
const [searchQuery, setSearchQuery] = useState("");
|
||
const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false);
|
||
|
||
const [menuItems, setMenuItems] = useState<{
|
||
id: string;
|
||
title: string;
|
||
icon: React.ReactNode;
|
||
solutions: string[];
|
||
}[]>([
|
||
{
|
||
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: ["ریزش مو", "خشکی پوست", "خارش", "جرم دندان", "سوزش چشم"]
|
||
}
|
||
]);
|
||
|
||
const [isMounted, setIsMounted] = useState(false);
|
||
useEffect(() => {
|
||
Promise.resolve().then(() => setIsMounted(true));
|
||
}, []);
|
||
const { getTotalItems } = useCartStore();
|
||
const { pets, activePetId, setActivePet } = usePetStore();
|
||
const { isLoggedIn, logout, profile } = useUserStore();
|
||
const getText = useSettingsStore(state => state.getText);
|
||
|
||
useEffect(() => {
|
||
const loadNavFilters = async () => {
|
||
try {
|
||
const data = await productService.getNavigationFilters();
|
||
if (data && data.length > 0) {
|
||
setMenuItems(data.map(item => ({
|
||
id: item.slug,
|
||
title: item.name,
|
||
icon: MENU_ICONS[item.slug] || <Pill className="w-5 h-5" />,
|
||
solutions: item.symptoms || []
|
||
})));
|
||
}
|
||
} catch (err) {
|
||
console.error('Failed to load navigation filters:', err);
|
||
}
|
||
};
|
||
loadNavFilters();
|
||
}, []);
|
||
|
||
useEffect(() => {
|
||
function handleClickOutside(event: MouseEvent) {
|
||
if (userProfileRef.current && !userProfileRef.current.contains(event.target as Node)) {
|
||
setIsProfileMenuOpen(false);
|
||
}
|
||
}
|
||
document.addEventListener("mousedown", handleClickOutside);
|
||
return () => document.removeEventListener("mousedown", handleClickOutside);
|
||
}, []);
|
||
|
||
const handleSearch = (e: React.FormEvent) => {
|
||
e.preventDefault();
|
||
if (searchQuery.trim()) {
|
||
onSearch(searchQuery);
|
||
}
|
||
};
|
||
|
||
return (
|
||
<>
|
||
<AuthModal isOpen={isAuthModalOpen} onClose={() => setIsAuthModalOpen(false)} />
|
||
<PrescriptionUploadModal isOpen={isPrescriptionModalOpen} onClose={() => setIsPrescriptionModalOpen(false)} />
|
||
|
||
<div className="sticky top-0 z-50 w-full shadow-md font-vazir" dir="rtl">
|
||
{/* Sliding Announcement Ticker Banner */}
|
||
<TickerBanner />
|
||
|
||
<header className="bg-white border-b border-medical-gray-200">
|
||
{/* TOP ROW: Logo + Search + Primary Actions */}
|
||
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-3 flex items-center justify-between gap-4">
|
||
|
||
{/* Mobile Menu Toggle & Logo */}
|
||
<div className="flex items-center gap-3">
|
||
<button
|
||
onClick={() => setIsMobileMenuOpen(!isMobileMenuOpen)}
|
||
className="lg:hidden p-2 rounded-xl text-medical-gray-600 hover:bg-medical-gray-100 transition-all"
|
||
aria-label="منو"
|
||
>
|
||
{isMobileMenuOpen ? <X className="w-6 h-6" /> : <Menu className="w-6 h-6" />}
|
||
</button>
|
||
|
||
<Link href="/" className="flex items-center gap-2 sm:gap-3 group shrink-0">
|
||
{(getText('BRAND_LOGO_URL', '') || getText('site_logo', '')) ? (
|
||
<img
|
||
src={getText('BRAND_LOGO_URL', '') || getText('site_logo', '')}
|
||
alt={getText('brand_name_fa', "کنینا ایران")}
|
||
className="h-10 sm:h-12 w-auto max-w-[140px] sm:max-w-[180px] object-contain shrink-0"
|
||
/>
|
||
) : (
|
||
<>
|
||
<div className="w-10 h-10 sm:w-12 sm:h-12 min-w-[40px] min-h-[40px] sm:min-w-[48px] sm:min-h-[48px] bg-canina-blue rounded-2xl flex items-center justify-center text-white font-bold text-xl sm:text-2xl group-hover:bg-medical-gray-900 transition-all shadow-md italic shrink-0">C</div>
|
||
<div className="flex flex-col justify-center">
|
||
<span className="text-canina-blue font-black text-base sm:text-2xl italic font-sans flex items-center gap-1 leading-none pl-1 whitespace-nowrap">
|
||
Canina
|
||
<span className="text-[11px] sm:text-sm not-italic font-medium border-r border-medical-gray-300 pr-1.5 mr-0.5 font-vazir text-medical-gray-700">
|
||
{getText('brand_name_fa', "ایران")}
|
||
</span>
|
||
</span>
|
||
<span className="hidden sm:block text-[9px] text-medical-gray-400 font-bold uppercase tracking-wider leading-tight mt-1 whitespace-nowrap">
|
||
نماینده رسمی CANINA PHARMA GMBH GERMANY
|
||
</span>
|
||
</div>
|
||
</>
|
||
)}
|
||
</Link>
|
||
</div>
|
||
|
||
{/* Center Search Input (Desktop) */}
|
||
<div className="hidden md:flex flex-1 max-w-md mx-4">
|
||
<form onSubmit={handleSearch} className="w-full relative">
|
||
<input
|
||
type="text"
|
||
placeholder="جستجوی محصول، ترکیب دارویی یا بیماری پت..."
|
||
value={searchQuery}
|
||
onChange={(e) => setSearchQuery(e.target.value)}
|
||
className="w-full bg-medical-gray-50 border border-medical-gray-200 rounded-2xl py-2.5 pr-10 pl-4 text-xs font-bold text-medical-gray-900 focus:outline-none focus:ring-2 focus:ring-canina-blue/20 focus:bg-white transition-all"
|
||
/>
|
||
<button type="submit" className="absolute right-3 top-1/2 -translate-y-1/2 text-medical-gray-400 hover:text-canina-blue">
|
||
<Search className="w-4 h-4" />
|
||
</button>
|
||
</form>
|
||
</div>
|
||
|
||
{/* Left Action Buttons */}
|
||
<div className="flex items-center gap-1.5 sm:gap-3 shrink-0">
|
||
{/* Prescription Upload Button */}
|
||
<button
|
||
onClick={() => setIsPrescriptionModalOpen(true)}
|
||
className="hidden sm:flex items-center gap-1.5 px-3 py-2 bg-emerald-50 text-emerald-700 border border-emerald-200 hover:bg-emerald-100 rounded-xl text-xs font-black transition-all shadow-xs"
|
||
>
|
||
<FileHeart className="w-4 h-4 text-emerald-600" />
|
||
<span>ثبت نسخه دامپزشک</span>
|
||
</button>
|
||
|
||
{/* User Account Button with Dropdown & Pets List */}
|
||
{isLoggedIn ? (
|
||
<div className="relative" ref={userProfileRef}>
|
||
<button
|
||
onClick={() => setIsProfileMenuOpen(!isProfileMenuOpen)}
|
||
className="flex items-center gap-1.5 p-2 sm:px-3 sm:py-2 bg-medical-gray-50 hover:bg-medical-gray-100 border border-medical-gray-200 rounded-xl text-xs font-black text-medical-gray-900 transition-all cursor-pointer"
|
||
>
|
||
<User className="w-4 h-4 text-canina-blue" />
|
||
<span className="hidden sm:inline">{profile.firstName || 'حساب کاربری'}</span>
|
||
<ChevronDown className={cn("w-3.5 h-3.5 text-medical-gray-500 transition-transform duration-200", isProfileMenuOpen && "rotate-180")} />
|
||
</button>
|
||
|
||
<AnimatePresence>
|
||
{isProfileMenuOpen && (
|
||
<motion.div
|
||
initial={{ opacity: 0, y: 8, scale: 0.96 }}
|
||
animate={{ opacity: 1, y: 0, scale: 1 }}
|
||
exit={{ opacity: 0, y: 8, scale: 0.96 }}
|
||
className="absolute left-0 mt-2 w-64 bg-white rounded-2xl shadow-xl border border-medical-gray-100 overflow-hidden z-50 p-2 text-xs font-vazir"
|
||
>
|
||
{/* User info header */}
|
||
<div className="px-3 py-2.5 bg-medical-gray-50 rounded-xl mb-1">
|
||
<p className="font-black text-medical-gray-900 truncate">
|
||
{profile.firstName ? `${profile.firstName} ${profile.lastName || ''}` : 'کاربر عزیز'}
|
||
</p>
|
||
<p className="text-[10px] text-medical-gray-500 font-mono mt-0.5 truncate">{profile.mobile || profile.email}</p>
|
||
</div>
|
||
|
||
{/* Pets List Section */}
|
||
<div className="py-1">
|
||
<div className="flex items-center justify-between px-3 py-1.5 text-[11px] font-black text-medical-gray-500">
|
||
<span className="flex items-center gap-1">
|
||
<HeartPulse className="w-3.5 h-3.5 text-canina-blue" />
|
||
پتهای من ({pets.length})
|
||
</span>
|
||
<Link href="/dashboard" onClick={() => setIsProfileMenuOpen(false)} className="text-canina-blue hover:underline text-[10px]">
|
||
مدیریت
|
||
</Link>
|
||
</div>
|
||
{pets.length > 0 ? (
|
||
<div className="space-y-1 max-h-32 overflow-y-auto">
|
||
{pets.map((p) => (
|
||
<button
|
||
key={p.id}
|
||
onClick={() => {
|
||
setActivePet(p.id);
|
||
setIsProfileMenuOpen(false);
|
||
toast.success(`پت فعال به ${p.name} تغییر یافت`);
|
||
}}
|
||
className={cn(
|
||
"w-full flex items-center justify-between px-3 py-1.5 rounded-lg text-right transition-colors",
|
||
p.id === activePetId ? "bg-canina-blue/10 text-canina-blue font-bold" : "hover:bg-medical-gray-50 text-medical-gray-700"
|
||
)}
|
||
>
|
||
<div className="flex items-center gap-2 truncate">
|
||
<span className="text-sm">{(p.type === 'سگ' || (p.type as string) === 'dog') ? '🐶' : '🐱'}</span>
|
||
<span className="truncate">{p.name}</span>
|
||
</div>
|
||
{p.id === activePetId && <Check className="w-3.5 h-3.5 shrink-0" />}
|
||
</button>
|
||
))}
|
||
</div>
|
||
) : (
|
||
<p className="px-3 py-2 text-[10px] text-medical-gray-400 text-center">پتی ثبت نشده است</p>
|
||
)}
|
||
</div>
|
||
|
||
<div className="border-t border-medical-gray-100 my-1" />
|
||
|
||
{/* Direct Navigation Links */}
|
||
<Link
|
||
href="/dashboard"
|
||
onClick={() => setIsProfileMenuOpen(false)}
|
||
className="flex items-center gap-2 px-3 py-2 hover:bg-medical-gray-50 text-medical-gray-700 rounded-xl font-bold transition-colors"
|
||
>
|
||
<User className="w-4 h-4 text-canina-blue" />
|
||
<span>داشبورد کاربری</span>
|
||
</Link>
|
||
|
||
<button
|
||
onClick={() => {
|
||
logout();
|
||
setIsProfileMenuOpen(false);
|
||
toast.success('از حساب کاربری خارج شدید');
|
||
}}
|
||
className="w-full flex items-center gap-2 px-3 py-2 hover:bg-rose-50 text-rose-600 rounded-xl font-bold transition-colors text-right"
|
||
>
|
||
<LogOut className="w-4 h-4" />
|
||
<span>خروج از حساب</span>
|
||
</button>
|
||
</motion.div>
|
||
)}
|
||
</AnimatePresence>
|
||
</div>
|
||
) : (
|
||
<button
|
||
onClick={() => setIsAuthModalOpen(true)}
|
||
className="flex items-center gap-1.5 px-2.5 py-2 sm:px-3.5 sm:py-2 bg-medical-gray-900 text-white hover:bg-canina-blue rounded-xl text-[11px] sm:text-xs font-black transition-all shadow-xs whitespace-nowrap"
|
||
>
|
||
<LogIn className="w-4 h-4 shrink-0" />
|
||
<span className="hidden xs:inline sm:inline">ورود / ثبتنام</span>
|
||
<span className="xs:hidden sm:hidden">ورود</span>
|
||
</button>
|
||
)}
|
||
|
||
{/* Shopping Cart Button */}
|
||
<button
|
||
onClick={onCartOpen}
|
||
className="relative px-3.5 py-2 bg-canina-blue text-white rounded-xl text-xs font-black hover:bg-medical-gray-900 transition-all flex items-center gap-2 shadow-sm"
|
||
>
|
||
<ShoppingBag className="w-4 h-4" />
|
||
<span className="hidden sm:inline">سبد خرید</span>
|
||
{isMounted && getTotalItems() > 0 && (
|
||
<span className="w-5 h-5 bg-canina-gold text-canina-dark rounded-full text-[10px] font-black flex items-center justify-center">
|
||
{getTotalItems()}
|
||
</span>
|
||
)}
|
||
</button>
|
||
</div>
|
||
</div>
|
||
|
||
{/* BOTTOM ROW: Clean Organized Dropdown Navigation Bar (Desktop) */}
|
||
<div className="hidden lg:block border-t border-medical-gray-100 bg-medical-gray-50/50">
|
||
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 flex items-center gap-1 py-1 text-xs font-black">
|
||
|
||
{/* Dropdown 1: Category Mega-Menu */}
|
||
<div
|
||
className="relative group py-2"
|
||
onMouseEnter={() => setIsMegaMenuOpen(true)}
|
||
onMouseLeave={() => setIsMegaMenuOpen(false)}
|
||
>
|
||
<button className={`flex items-center gap-1.5 px-3 py-2 rounded-xl transition-all ${isMegaMenuOpen ? 'bg-canina-blue text-white' : 'text-medical-gray-700 hover:bg-medical-gray-100 hover:text-canina-blue'}`}>
|
||
<Pill className="w-4 h-4" />
|
||
<span>دستهبندی درمانی محصولات</span>
|
||
<ChevronDown className={`w-3.5 h-3.5 transition-transform ${isMegaMenuOpen ? 'rotate-180' : ''}`} />
|
||
</button>
|
||
|
||
<AnimatePresence>
|
||
{isMegaMenuOpen && (
|
||
<motion.div
|
||
initial={{ opacity: 0, y: 10 }}
|
||
animate={{ opacity: 1, y: 0 }}
|
||
exit={{ opacity: 0, y: 10 }}
|
||
className="absolute top-full right-0 w-[640px] bg-white border border-medical-gray-200 shadow-2xl rounded-2xl p-6 grid grid-cols-2 gap-6 z-50"
|
||
>
|
||
{menuItems.map((item, idx) => (
|
||
<div key={idx} className="group/item">
|
||
<Link
|
||
href={`/shop?category=${item.id}`}
|
||
onClick={() => setIsMegaMenuOpen(false)}
|
||
className="flex items-center gap-3 mb-3 cursor-pointer"
|
||
>
|
||
<div className="p-2 bg-canina-blue/10 rounded-xl text-canina-blue group-hover/item:bg-canina-blue group-hover/item:text-white transition-all">
|
||
{item.icon}
|
||
</div>
|
||
<h4 className="font-black text-medical-gray-900 text-sm">{item.title}</h4>
|
||
</Link>
|
||
<div className="flex flex-wrap gap-1 border-r-2 border-medical-gray-100 pr-2">
|
||
{item.solutions.slice(0, 6).map((sol, sIdx) => (
|
||
<Link
|
||
key={sIdx}
|
||
href={`/shop?category=${item.id}&symptom=${encodeURIComponent(sol)}`}
|
||
className="inline-block px-2 py-0.5 rounded-md text-[10px] font-bold bg-medical-gray-50 hover:bg-canina-blue hover:text-white transition-all text-medical-gray-600"
|
||
onClick={() => setIsMegaMenuOpen(false)}
|
||
>
|
||
{sol}
|
||
</Link>
|
||
))}
|
||
</div>
|
||
</div>
|
||
))}
|
||
</motion.div>
|
||
)}
|
||
</AnimatePresence>
|
||
</div>
|
||
|
||
{/* Dropdown 2: Products & Catalog */}
|
||
<div
|
||
className="relative group py-2"
|
||
onMouseEnter={() => setActiveDropdown('products')}
|
||
onMouseLeave={() => setActiveDropdown(null)}
|
||
>
|
||
<button className="flex items-center gap-1.5 px-3 py-2 rounded-xl text-medical-gray-700 hover:bg-medical-gray-100 hover:text-canina-blue transition-all">
|
||
<span>محصولات و کاتالوگ</span>
|
||
<ChevronDown className="w-3.5 h-3.5" />
|
||
</button>
|
||
{activeDropdown === 'products' && (
|
||
<div className="absolute top-full right-0 w-52 bg-white border border-medical-gray-200 shadow-xl rounded-xl p-2 z-50 space-y-1 text-xs">
|
||
<Link href="/shop" className="block px-3 py-2 hover:bg-canina-blue/5 hover:text-canina-blue rounded-lg font-bold">
|
||
کاتالوگ جامع محصولات
|
||
</Link>
|
||
<Link href="/catalog" className="block px-3 py-2 hover:bg-canina-blue/5 hover:text-canina-blue rounded-lg font-bold">
|
||
کاتالوگ آنلاین و دوز مصرفی
|
||
</Link>
|
||
</div>
|
||
)}
|
||
</div>
|
||
|
||
{/* Dropdown 3: Science & Academy */}
|
||
<div
|
||
className="relative group py-2"
|
||
onMouseEnter={() => setActiveDropdown('science')}
|
||
onMouseLeave={() => setActiveDropdown(null)}
|
||
>
|
||
<button className="flex items-center gap-1.5 px-3 py-2 rounded-xl text-medical-gray-700 hover:bg-medical-gray-100 hover:text-canina-blue transition-all">
|
||
<span>دانشنامه و آکادمی</span>
|
||
<ChevronDown className="w-3.5 h-3.5" />
|
||
</button>
|
||
{activeDropdown === 'science' && (
|
||
<div className="absolute top-full right-0 w-56 bg-white border border-medical-gray-200 shadow-xl rounded-xl p-2 z-50 space-y-1 text-xs">
|
||
<Link href="/wiki" className="flex items-center gap-2 px-3 py-2 hover:bg-canina-blue/5 hover:text-canina-blue rounded-lg font-bold">
|
||
<BookOpen className="w-4 h-4 text-canina-blue" />
|
||
دانشنامه علمی کنینا
|
||
</Link>
|
||
<Link href="/blog" className="flex items-center gap-2 px-3 py-2 hover:bg-canina-blue/5 hover:text-canina-blue rounded-lg font-bold">
|
||
<FileText className="w-4 h-4 text-canina-blue" />
|
||
مجله سلامت پت (وبلاگ)
|
||
</Link>
|
||
<Link href="/videos" className="flex items-center gap-2 px-3 py-2 hover:bg-canina-blue/5 hover:text-canina-blue rounded-lg font-bold">
|
||
<Video className="w-4 h-4 text-canina-blue" />
|
||
آکادمی ویدئویی و مشاوره دامپزشک
|
||
</Link>
|
||
</div>
|
||
)}
|
||
</div>
|
||
|
||
{/* Dropdown 4: Smart Tools & Pet Profile */}
|
||
<div
|
||
className="relative group py-2"
|
||
onMouseEnter={() => setActiveDropdown('tools')}
|
||
onMouseLeave={() => setActiveDropdown(null)}
|
||
>
|
||
<button className="flex items-center gap-1.5 px-3 py-2 rounded-xl text-medical-gray-700 hover:bg-medical-gray-100 hover:text-canina-blue transition-all">
|
||
<span>ابزارهای هوشمند</span>
|
||
<ChevronDown className="w-3.5 h-3.5" />
|
||
</button>
|
||
{activeDropdown === 'tools' && (
|
||
<div className="absolute top-full right-0 w-56 bg-white border border-medical-gray-200 shadow-xl rounded-xl p-2 z-50 space-y-1 text-xs">
|
||
<Link href="/profile" className="flex items-center gap-2 px-3 py-2 hover:bg-canina-blue/5 hover:text-canina-blue rounded-lg font-bold">
|
||
<Dog className="w-4 h-4 text-canina-blue" />
|
||
شناسنامه و سوابق سلامت پت
|
||
</Link>
|
||
<Link href="/dashboard" className="flex items-center gap-2 px-3 py-2 hover:bg-canina-blue/5 hover:text-canina-blue rounded-lg font-bold">
|
||
<Activity className="w-4 h-4 text-canina-blue" />
|
||
پایش هوشمند مصرف مکملها
|
||
</Link>
|
||
</div>
|
||
)}
|
||
</div>
|
||
|
||
{/* Dropdown 5: Company & B2B */}
|
||
<div
|
||
className="relative group py-2"
|
||
onMouseEnter={() => setActiveDropdown('company')}
|
||
onMouseLeave={() => setActiveDropdown(null)}
|
||
>
|
||
<button className="flex items-center gap-1.5 px-3 py-2 rounded-xl text-medical-gray-700 hover:bg-medical-gray-100 hover:text-canina-blue transition-all">
|
||
<span>درباره کنینا و تماس</span>
|
||
<ChevronDown className="w-3.5 h-3.5" />
|
||
</button>
|
||
{activeDropdown === 'company' && (
|
||
<div className="absolute top-full right-0 w-60 bg-white border border-medical-gray-200 shadow-xl rounded-xl p-2 z-50 space-y-1 text-xs">
|
||
<Link href="/about" className="flex items-center gap-2 px-3 py-2 hover:bg-canina-blue/5 hover:text-canina-blue rounded-lg font-bold">
|
||
<Award className="w-4 h-4 text-canina-blue" />
|
||
درباره کمپانی کنینا آلمان
|
||
</Link>
|
||
<Link href="/trust-seals" className="flex items-center gap-2 px-3 py-2 hover:bg-canina-blue/5 hover:text-canina-blue rounded-lg font-bold text-emerald-600">
|
||
<ShieldCheck className="w-4 h-4 text-emerald-600" />
|
||
نمادهای اعتماد و مجوزهای رسمی
|
||
</Link>
|
||
<button
|
||
onClick={onB2BOpen}
|
||
className="w-full text-right flex items-center gap-2 px-3 py-2 hover:bg-canina-blue/5 hover:text-canina-blue rounded-lg font-bold"
|
||
>
|
||
<Building2 className="w-4 h-4 text-canina-blue" />
|
||
درخواست نمایندگی B2B
|
||
</button>
|
||
<Link href="/contact" className="flex items-center gap-2 px-3 py-2 hover:bg-canina-blue/5 hover:text-canina-blue rounded-lg font-bold">
|
||
<PhoneCall className="w-4 h-4 text-canina-blue" />
|
||
تماس با مرکز پشتیبانی
|
||
</Link>
|
||
</div>
|
||
)}
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
</header>
|
||
|
||
{/* Mobile Navigation Drawer & Backdrop */}
|
||
<AnimatePresence>
|
||
{isMobileMenuOpen && (
|
||
<>
|
||
<motion.div
|
||
initial={{ opacity: 0 }}
|
||
animate={{ opacity: 1 }}
|
||
exit={{ opacity: 0 }}
|
||
onClick={() => setIsMobileMenuOpen(false)}
|
||
className="lg:hidden fixed inset-0 bg-black/50 z-40 backdrop-blur-xs"
|
||
/>
|
||
<motion.div
|
||
initial={{ opacity: 0, height: 0 }}
|
||
animate={{ opacity: 1, height: "auto" }}
|
||
exit={{ opacity: 0, height: 0 }}
|
||
className="lg:hidden relative z-50 bg-white border-b border-medical-gray-200 px-4 py-6 space-y-4 shadow-xl"
|
||
>
|
||
<form onSubmit={handleSearch} className="relative mb-4">
|
||
<input
|
||
type="text"
|
||
placeholder="جستجو در محصولات..."
|
||
value={searchQuery}
|
||
onChange={(e) => setSearchQuery(e.target.value)}
|
||
className="w-full bg-medical-gray-50 border border-medical-gray-200 rounded-xl py-3 pr-10 pl-4 text-xs font-bold"
|
||
/>
|
||
<Search className="w-4 h-4 text-medical-gray-400 absolute right-3 top-1/2 -translate-y-1/2" />
|
||
</form>
|
||
|
||
<div className="space-y-2 text-sm font-black">
|
||
<Link href="/shop" onClick={() => setIsMobileMenuOpen(false)} className="block p-3 rounded-xl bg-medical-gray-50 text-medical-gray-900">
|
||
🛒 محصولات تخصصی کنینا
|
||
</Link>
|
||
<Link href="/catalog" onClick={() => setIsMobileMenuOpen(false)} className="block p-3 rounded-xl hover:bg-medical-gray-50 text-medical-gray-800">
|
||
📑 کاتالوگ آنلاین و دوز مصرفی
|
||
</Link>
|
||
<Link href="/wiki" onClick={() => setIsMobileMenuOpen(false)} className="block p-3 rounded-xl hover:bg-medical-gray-50 text-medical-gray-800">
|
||
🧬 دانشنامه علمی
|
||
</Link>
|
||
<Link href="/blog" onClick={() => setIsMobileMenuOpen(false)} className="block p-3 rounded-xl hover:bg-medical-gray-50 text-medical-gray-800">
|
||
📰 مجله سلامت پت
|
||
</Link>
|
||
<Link href="/videos" onClick={() => setIsMobileMenuOpen(false)} className="block p-3 rounded-xl hover:bg-medical-gray-50 text-medical-gray-800">
|
||
🎥 آکادمی ویدئویی و مشاوره دامپزشک
|
||
</Link>
|
||
<Link href="/profile" onClick={() => setIsMobileMenuOpen(false)} className="block p-3 rounded-xl hover:bg-medical-gray-50 text-medical-gray-800">
|
||
🐾 شناسنامه و سوابق سلامت پت
|
||
</Link>
|
||
</div>
|
||
</motion.div>
|
||
</>
|
||
)}
|
||
</AnimatePresence>
|
||
</div>
|
||
</>
|
||
);
|
||
}
|