From 63d7a141e8d4cee6b507fa9c08a7d2bd90c55a2a Mon Sep 17 00:00:00 2001 From: Maja Komel Date: Mon, 27 Feb 2023 12:29:46 +0100 Subject: [PATCH] Fix date picker ranges --- components/DateRangePicker.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/components/DateRangePicker.js b/components/DateRangePicker.js index bd0af286a..60a27bcbd 100644 --- a/components/DateRangePicker.js +++ b/components/DateRangePicker.js @@ -78,21 +78,22 @@ const getDateFnsLocale = locale => { const DateRangePicker = ({handleRangeSelect, initialRange, close, ...props}) => { const intl = useIntl() + const tomorrow = addDays(new Date(), 1) const ranges = ['Today', 'LastWeek', 'LastMonth', 'LastYear'] const selectRange = (range) => { switch (range) { case 'Today': - handleRangeSelect({from: new Date(), to: new Date()}) + handleRangeSelect({from: new Date(), to: tomorrow}) break case 'LastWeek': - handleRangeSelect({from: sub(new Date(), {weeks: 1}) , to: new Date()}) + handleRangeSelect({from: sub(new Date(), {weeks: 1}) , to: tomorrow}) break case 'LastMonth': - handleRangeSelect({from: sub(new Date(), {months: 1}) , to: new Date()}) + handleRangeSelect({from: sub(new Date(), {months: 1}) , to: tomorrow}) break case 'LastYear': - handleRangeSelect({from: sub(new Date(), {years: 1}) , to: new Date()}) + handleRangeSelect({from: sub(new Date(), {years: 1}) , to: tomorrow}) break } } @@ -125,8 +126,6 @@ const DateRangePicker = ({handleRangeSelect, initialRange, close, ...props}) => setRange(range) } - const tomorrow = addDays(new Date(), 1) - return ( close()}>