From 7a3c1e9faa29a847fa86352d0def630f5733f275 Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Tue, 1 Mar 2022 22:02:31 -0800 Subject: [PATCH] Fix default date range setting. --- components/settings/DateRangeSetting.js | 11 ++++++----- hooks/useDateRange.js | 10 +++++----- lib/web.js | 2 +- store/websites.js | 2 -- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/components/settings/DateRangeSetting.js b/components/settings/DateRangeSetting.js index 53dfe983..9c59d3ea 100644 --- a/components/settings/DateRangeSetting.js +++ b/components/settings/DateRangeSetting.js @@ -4,18 +4,19 @@ import DateFilter, { filterOptions } 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'; -import useLocale from 'hooks/useLocale'; export default function DateRangeSetting() { - const { locale } = useLocale(); const [dateRange, setDateRange] = useDateRange(); const { startDate, endDate, value } = dateRange; const options = filterOptions.filter(e => e.value !== 'all'); + function handleChange(value) { + setDateRange(value); + } + function handleReset() { - setDateRange(getDateRange(DEFAULT_DATE_RANGE, locale)); + setDateRange(DEFAULT_DATE_RANGE); } return ( @@ -25,7 +26,7 @@ export default function DateRangeSetting() { value={value} startDate={startDate} endDate={endDate} - onChange={setDateRange} + onChange={handleChange} />