'use client'; import * as React from 'react'; import Link from 'next/link'; import Image from 'next/image'; import { usePathname } from 'next/navigation'; import { motion, AnimatePresence } from 'framer-motion'; export interface NavLink { label: string; url: string; } interface HeaderProps { navLinks: NavLink[]; } export function Header({ navLinks }: HeaderProps) { const [isScrolled, setIsScrolled] = React.useState(false); const [isMobileMenuOpen, setIsMobileMenuOpen] = React.useState(false); const pathname = usePathname() || '/'; // Determine current locale from pathname const currentLocale = pathname.startsWith('/en') ? 'en' : 'de'; // Helper to switch languages const getSwitchedUrl = (newLocale: string) => { if (!pathname) return `/${newLocale}`; const pathWithoutLocale = pathname.replace(/^\/(en|de)/, ''); return `/${newLocale}${pathWithoutLocale === '' ? '' : pathWithoutLocale}`; }; React.useEffect(() => { const handleScroll = () => { setIsScrolled(window.scrollY > 20); }; window.addEventListener('scroll', handleScroll); return () => window.removeEventListener('scroll', handleScroll); }, []); // Close mobile menu on route change React.useEffect(() => { setIsMobileMenuOpen(false); }, [pathname]); const LanguageSwitcher = ({ mobile = false }) => (