import { type Locale } from '@scrabble-solver/types'; import classNames from 'classnames'; import { type ChangeEvent, type FunctionComponent } from 'react'; import { useDispatch } from 'react-redux'; import { Radio } from '@/components'; import { LOCALE_FEATURES } from '@/i18n'; import { selectLocale, settingsSlice, useTypedSelector } from '@/state'; import styles from './LocaleSetting.module.scss'; interface Props { className?: string; disabled: boolean; } const OPTIONS = Object.values(LOCALE_FEATURES).sort((a, b) => a.name.localeCompare(b.name)); export const LocaleSetting: FunctionComponent = ({ className, disabled }) => { const dispatch = useDispatch(); const locale = useTypedSelector(selectLocale); const handleChange = (event: ChangeEvent) => { const newLocale: Locale = event.target.value as Locale; dispatch(settingsSlice.actions.changeLocale(newLocale)); }; return (
{OPTIONS.map(({ Icon, ...option }) => ( ))}
); };