Skip to content
Snippets Groups Projects
LocaleSelector.tsx 754 B
Newer Older
import { dispatch } from "../../redux";
import { connectState } from "../../redux/connector";
insert's avatar
insert committed

import { Language, Languages } from "../../context/Locale";

import ComboBox from "../ui/ComboBox";
type Props = {
insert's avatar
insert committed
	locale: string;
};

export function LocaleSelector(props: Props) {
insert's avatar
insert committed
	return (
		<ComboBox
			value={props.locale}
			onChange={(e) =>
				dispatch({
					type: "SET_LOCALE",
					locale: e.currentTarget.value as Language,
				})
			}>
			{Object.keys(Languages).map((x) => {
				const l = Languages[x as keyof typeof Languages];
				return (
					<option value={x}>
						{l.emoji} {l.display}
					</option>
				);
			})}
		</ComboBox>
	);
insert's avatar
insert committed
export default connectState(LocaleSelector, (state) => {
	return {
		locale: state.locale,
	};
});