2021-07-05 05:59:48 -04:00
|
|
|
import { dispatch } from "../../redux";
|
2021-06-21 08:44:43 -04:00
|
|
|
import { connectState } from "../../redux/connector";
|
2021-07-05 06:23:23 -04:00
|
|
|
|
|
|
|
import { Language, Languages } from "../../context/Locale";
|
|
|
|
|
|
|
|
import ComboBox from "../ui/ComboBox";
|
2021-06-21 08:44:43 -04:00
|
|
|
|
2021-07-05 05:59:48 -04:00
|
|
|
type Props = {
|
2021-07-05 06:25:20 -04:00
|
|
|
locale: string;
|
2021-06-21 08:44:43 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
export function LocaleSelector(props: Props) {
|
2021-07-05 06:25:20 -04:00
|
|
|
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 (
|
2021-08-05 09:47:00 -04:00
|
|
|
<option value={x} key={x}>
|
2021-07-05 06:25:20 -04:00
|
|
|
{l.emoji} {l.display}
|
|
|
|
</option>
|
|
|
|
);
|
|
|
|
})}
|
|
|
|
</ComboBox>
|
|
|
|
);
|
2021-06-21 08:44:43 -04:00
|
|
|
}
|
|
|
|
|
2021-07-05 06:23:23 -04:00
|
|
|
export default connectState(LocaleSelector, (state) => {
|
2021-07-05 06:25:20 -04:00
|
|
|
return {
|
|
|
|
locale: state.locale,
|
|
|
|
};
|
2021-07-05 06:23:23 -04:00
|
|
|
});
|