"use client" import { useState, useEffect } from "react" import Link from "next/link" import Image from "next/image" import { X, Menu, Search, Store } from "lucide-react" import { Button } from "@/components/ui/button" import Logo from "@/public/logo.png" import CategoryMenu from "./ui/CategoryMenu" import SearchBar from "./ui/SearchBar" import AuthDialog from "./ui/AuthDialog" import ActionButtons from "./ui/ActionButtons" import LanguageSelector from "./ui/LanguageSelector" interface HeaderProps { locale?: string isAuthenticated?: boolean translations?: { catalog: string search: string orders: string favorites: string cart: string login: string profile: string openStore: string phone: string code: string send: string enterPhone: string weWillSendCode: string } } const DEFAULT_TRANSLATIONS = { catalog: "Каталог", search: "Поиск продукта", orders: "Заказы", favorites: "Избранное", cart: "Корзина", login: "Войти", profile: "Профиль", openStore: "Открыть магазин", phone: "Номер телефона", code: "Код", send: "Отправить", enterPhone: "Введите свой номер телефона", weWillSendCode: "Мы вышлем вам код", } export default function Header({ locale = "ru", isAuthenticated = false, translations }: HeaderProps) { const [isClient, setIsClient] = useState(false) const [isCategoryOpen, setIsCategoryOpen] = useState(false) const [isMobileSearchOpen, setIsMobileSearchOpen] = useState(false) const [isLoginOpen, setIsLoginOpen] = useState(false) const t = translations || DEFAULT_TRANSLATIONS useEffect(() => { setIsClient(true) }, []) const handleAuthClick = () => { if (isAuthenticated) { window.location.href = `/${locale}/me` } else { setIsLoginOpen(true) } } const toggleCategoryMenu = () => setIsCategoryOpen(!isCategoryOpen) const closeCategoryMenu = () => setIsCategoryOpen(false) if (!isClient) return null return ( <> {isCategoryOpen ? : } {t.catalog} setIsMobileSearchOpen(true)}> {t.openStore} setIsMobileSearchOpen(false)} searchPlaceholder={t.search} /> setIsLoginOpen(false)} translations={{ enterPhone: t.enterPhone, weWillSendCode: t.weWillSendCode, phone: t.phone, code: t.code, send: t.send, }} /> > ) }