import { Button } from "@/components/ui/button"; import { useContext } from "react"; import { LanguageContext } from "@/contexts/LanguageContext"; import { Language } from "@/i18n/translations"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; const languages: { code: Language; name: string; flag: string }[] = [ { code: 'en', name: 'English', flag: '🇬🇧' }, { code: 'fr', name: 'Français', flag: '🇫🇷' }, { code: 'de', name: 'Deutsch', flag: '🇩🇪' }, { code: 'it', name: 'Italiano', flag: '🇮🇹' }, { code: 'es', name: 'Español', flag: '🇪🇸' }, { code: 'pt', name: 'Português', flag: '🇵🇹' }, ]; export const LanguageSelector = () => { const { language, setLanguage } = useContext(LanguageContext); console.log('[LanguageSelector] Current language:', language); const handleLanguageChange = (code: Language) => { console.log('[LanguageSelector] Language button clicked:', code); setLanguage(code); }; const currentLanguage = languages.find(lang => lang.code === language); return ( {languages.map(({ code, name, flag }) => ( handleLanguageChange(code)} className="cursor-pointer" > {flag} {name} ))} ); };