From a1edcecde781ce77db303ba6a3af6a640cc7af6d Mon Sep 17 00:00:00 2001 From: Alexander Klein Date: Wed, 10 Mar 2021 10:38:35 +0100 Subject: [PATCH] feature(components): add locale for date ranges --- components/common/RefreshButton.js | 4 +++- components/settings/DateRangeSetting.js | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/components/common/RefreshButton.js b/components/common/RefreshButton.js index a2857522..61f06a3c 100644 --- a/components/common/RefreshButton.js +++ b/components/common/RefreshButton.js @@ -8,9 +8,11 @@ import Refresh from 'assets/redo.svg'; import Dots from 'assets/ellipsis-h.svg'; import useDateRange from 'hooks/useDateRange'; import { getDateRange } from '../../lib/date'; +import useLocale from 'hooks/useLocale'; function RefreshButton({ websiteId }) { const dispatch = useDispatch(); + const [locale] = useLocale(); const [dateRange] = useDateRange(websiteId); const [loading, setLoading] = useState(false); const completed = useSelector(state => state.queries[`/api/website/${websiteId}/stats`]); @@ -18,7 +20,7 @@ function RefreshButton({ websiteId }) { function handleClick() { if (dateRange) { setLoading(true); - dispatch(setDateRange(websiteId, getDateRange(dateRange.value))); + dispatch(setDateRange(websiteId, getDateRange(dateRange.value, locale))); } } diff --git a/components/settings/DateRangeSetting.js b/components/settings/DateRangeSetting.js index a25bafa8..8ce5e72c 100644 --- a/components/settings/DateRangeSetting.js +++ b/components/settings/DateRangeSetting.js @@ -6,13 +6,15 @@ 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; function handleReset() { - setDateRange(getDateRange(DEFAULT_DATE_RANGE)); + setDateRange(getDateRange(DEFAULT_DATE_RANGE, locale)); } return (