import { useId, useRef } from 'react'; type LocaleOptionsProps = { locale: string | undefined; setLocale: (locale: string | undefined) => void; }; export default function LocaleOptions({ locale, setLocale }: LocaleOptionsProps) { const localeDefaultId = useId(); const localeEnId = useId(); const localeDeId = useId(); const localeEsId = useId(); const localePlId = useId(); const customLocaleId = useId(); const customLocale = useRef(null); function onChange(event: React.ChangeEvent) { const { value: nextLocale } = event.target; if (nextLocale === 'undefined') { setLocale(undefined); } else { setLocale(nextLocale); } } function onCustomChange(event: React.FormEvent) { event.preventDefault(); const input = customLocale.current; const { value: nextLocale } = input as HTMLInputElement; setLocale(nextLocale); } function resetLocale() { setLocale(undefined); } return (
Locale
   
); }