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

25 lines
693 B
JavaScript
Raw Normal View History

2023-02-15 11:27:18 +01:00
import DateFilter from 'components/input/DateFilter';
import { Button, Flexbox } from 'react-basics';
import useDateRange from 'hooks/useDateRange';
import { DEFAULT_DATE_RANGE } from 'lib/constants';
2023-03-22 22:05:55 +01:00
import useMessages from 'hooks/useMessages';
2023-04-21 17:00:42 +02:00
export function DateRangeSetting() {
2023-03-22 22:05:55 +01:00
const { formatMessage, labels } = useMessages();
const [dateRange, setDateRange] = useDateRange();
2023-05-12 01:42:58 +02:00
const { value } = dateRange;
2023-05-12 01:42:58 +02:00
const handleReset = () => {
setDateRange(DEFAULT_DATE_RANGE);
};
return (
2023-04-13 02:43:08 +02:00
<Flexbox gap={10}>
2023-05-12 01:42:58 +02:00
<DateFilter value={value} />
2023-01-25 16:42:46 +01:00
<Button onClick={handleReset}>{formatMessage(labels.reset)}</Button>
</Flexbox>
);
}
2023-04-21 17:00:42 +02:00
export default DateRangeSetting;