import React, { useEffect, useState } from 'react'; import { useTranslation } from 'next-i18next'; import Select, { components, SingleValueProps, OptionProps, } from 'react-select'; type LanguageOption = { label: string; value: string }; const LANGS: LanguageOption[] = [ { value: 'en', label: '🇬🇧 EN' }, { value: 'fr', label: '🇫🇷 FR' }, { value: 'es', label: '🇪🇸 ES' }, { value: 'de', label: '🇩🇪 DE' }, ]; const Option = (props: OptionProps) => ( {props.data.label} ); const SingleVal = (props: SingleValueProps) => ( {props.data.label} ); const LanguageSwitcher: React.FC = () => { const { i18n } = useTranslation(); const [mounted, setMounted] = useState(false); const [selected, setSelected] = useState(LANGS[0]); useEffect(() => { setMounted(true); setSelected(LANGS.find((l) => l.value === i18n.language) ?? LANGS[0]); }, [i18n.language]); const handleChange = (opt: LanguageOption | null) => { if (!opt) return; setSelected(opt); i18n.changeLanguage(opt.value); }; if (!mounted) return null; return (