2020-09-19 19:35:05 +02:00
|
|
|
import React from 'react';
|
|
|
|
import { FormattedMessage } from 'react-intl';
|
|
|
|
import DateFilter from 'components/common/DateFilter';
|
|
|
|
import Button from 'components/common/Button';
|
|
|
|
import useDateRange from 'hooks/useDateRange';
|
|
|
|
import { DEFAULT_DATE_RANGE } from 'lib/constants';
|
|
|
|
import { getDateRange } from 'lib/date';
|
|
|
|
import styles from './DateRangeSetting.module.css';
|
2021-03-10 10:38:35 +01:00
|
|
|
import useLocale from 'hooks/useLocale';
|
2020-09-19 19:35:05 +02:00
|
|
|
|
|
|
|
export default function DateRangeSetting() {
|
2021-06-30 03:41:34 +02:00
|
|
|
const { locale } = useLocale();
|
2020-09-19 19:35:05 +02:00
|
|
|
const [dateRange, setDateRange] = useDateRange();
|
|
|
|
const { startDate, endDate, value } = dateRange;
|
|
|
|
|
|
|
|
function handleReset() {
|
2021-03-10 10:38:35 +01:00
|
|
|
setDateRange(getDateRange(DEFAULT_DATE_RANGE, locale));
|
2020-09-19 19:35:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<DateFilter value={value} startDate={startDate} endDate={endDate} onChange={setDateRange} />
|
|
|
|
<Button className={styles.button} size="small" onClick={handleReset}>
|
2020-10-13 07:53:59 +02:00
|
|
|
<FormattedMessage id="label.reset" defaultMessage="Reset" />
|
2020-09-19 19:35:05 +02:00
|
|
|
</Button>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|