2023-01-25 16:42:46 +01:00
|
|
|
import { useIntl } from 'react-intl';
|
2023-01-11 17:33:43 +01:00
|
|
|
import DateFilter from 'components/common/DateFilter';
|
|
|
|
import { Button, Flexbox } from 'react-basics';
|
2020-09-19 19:35:05 +02:00
|
|
|
import useDateRange from 'hooks/useDateRange';
|
|
|
|
import { DEFAULT_DATE_RANGE } from 'lib/constants';
|
2023-01-25 16:42:46 +01:00
|
|
|
import { labels } from 'components/messages';
|
2020-09-19 19:35:05 +02:00
|
|
|
|
|
|
|
export default function DateRangeSetting() {
|
2023-01-25 16:42:46 +01:00
|
|
|
const { formatMessage } = useIntl();
|
2020-09-19 19:35:05 +02:00
|
|
|
const [dateRange, setDateRange] = useDateRange();
|
|
|
|
const { startDate, endDate, value } = dateRange;
|
|
|
|
|
2023-01-11 17:33:43 +01:00
|
|
|
const handleReset = () => setDateRange(DEFAULT_DATE_RANGE);
|
2020-09-19 19:35:05 +02:00
|
|
|
|
|
|
|
return (
|
2023-01-11 17:33:43 +01:00
|
|
|
<Flexbox width={400} gap={10}>
|
|
|
|
<DateFilter value={value} startDate={startDate} endDate={endDate} onChange={setDateRange} />
|
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
|
|
|
);
|
|
|
|
}
|