'use client'; import { useState, useEffect } from 'react'; import Link from 'next/link'; import { motion } from 'framer-motion'; import { Button } from '@/components/ui/button'; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from '@/components/ui/dropdown-menu'; import { MapPin, Phone, Building, Menu, X } from 'lucide-react'; import ContactModal from './ContactModal'; const cityData = { Москва: { phone: '+7 (916) 830-58-58', }, Чебоксары: { phone: '+7 (916) 830-58-58', }, } as const; const navigation = [ { name: 'О компании', href: '#about' }, { name: 'Преимущества', href: '#why-us' }, { name: 'Как мы работаем', href: '#workflow' }, { name: 'Сертификаты', href: '#certificates' }, { name: 'Услуги', href: '#services' }, { name: 'Контакты', href: '#contacts' }, ]; type CityKey = keyof typeof cityData; interface HeaderProps { selectedCity: CityKey; onCityChange: (city: CityKey) => void; } const Header = ({ selectedCity, onCityChange }: HeaderProps) => { const [isMenuOpen, setIsMenuOpen] = useState(false); const [isVisible, setIsVisible] = useState(true); const [lastScrollY, setLastScrollY] = useState(0); const [isModalOpen, setIsModalOpen] = useState(false); useEffect(() => { const handleScroll = () => { const currentScrollY = window.scrollY; setIsVisible(currentScrollY < lastScrollY || currentScrollY < 100); setLastScrollY(currentScrollY); }; window.addEventListener('scroll', handleScroll, { passive: true }); return () => window.removeEventListener('scroll', handleScroll); }, [lastScrollY]); return ( <>
ЦКЕ Центр комплексных экспертиз
onCityChange('Москва')} className="cursor-pointer" > Москва onCityChange('Чебоксары')} className="cursor-pointer" > Чебоксары {cityData[selectedCity].phone}
setIsModalOpen(false)} /> ); }; export default Header;