umami/components/pages/settings/profile/TimezoneSetting.js

29 lines
862 B
JavaScript
Raw Normal View History

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