2023-01-11 17:33:43 +01:00
|
|
|
import { Dropdown, Item, Button, Flexbox } from 'react-basics';
|
2020-09-19 19:35:05 +02:00
|
|
|
import { listTimeZones } from 'timezone-support';
|
|
|
|
import useTimezone from 'hooks/useTimezone';
|
2023-03-22 22:05:55 +01:00
|
|
|
import useMessages from 'hooks/useMessages';
|
2020-09-19 19:35:05 +02:00
|
|
|
import { getTimezone } from 'lib/date';
|
|
|
|
|
2023-04-21 17:00:42 +02:00
|
|
|
export function TimezoneSetting() {
|
2023-03-22 22:05:55 +01:00
|
|
|
const { formatMessage, labels } = useMessages();
|
2020-09-19 19:35:05 +02:00
|
|
|
const [timezone, saveTimezone] = useTimezone();
|
2023-01-11 02:18:59 +01:00
|
|
|
const options = listTimeZones();
|
2020-09-19 19:35:05 +02:00
|
|
|
|
2023-01-11 17:33:43 +01:00
|
|
|
const handleReset = () => saveTimezone(getTimezone());
|
2020-09-19 19:35:05 +02:00
|
|
|
|
|
|
|
return (
|
2023-04-13 02:43:08 +02:00
|
|
|
<Flexbox gap={10}>
|
2023-01-19 00:05:39 +01:00
|
|
|
<Dropdown
|
|
|
|
items={options}
|
|
|
|
value={timezone}
|
|
|
|
onChange={saveTimezone}
|
2023-04-13 02:43:08 +02:00
|
|
|
style={{ flex: 1 }}
|
|
|
|
menuProps={{ style: { height: 300 } }}
|
2023-01-19 00:05:39 +01:00
|
|
|
>
|
2023-01-11 02:18:59 +01:00
|
|
|
{item => <Item key={item}>{item}</Item>}
|
|
|
|
</Dropdown>
|
2023-01-25 16:42:46 +01:00
|
|
|
<Button onClick={handleReset}>{formatMessage(labels.reset)}</Button>
|
2023-01-11 17:33:43 +01:00
|
|
|
</Flexbox>
|
2020-09-19 19:35:05 +02:00
|
|
|
);
|
|
|
|
}
|
2023-04-21 17:00:42 +02:00
|
|
|
|
|
|
|
export default TimezoneSetting;
|