From 433694b7a106daf0b6cacddcb1e87b2b85ae557b Mon Sep 17 00:00:00 2001 From: Gavin Reynolds Date: Tue, 5 Dec 2023 11:23:31 +0000 Subject: [PATCH] Add Today as an additional Default Since Date Lookback Signed-off-by: Gavin Reynolds --- .../QuerySettings/subcomponents/DatePickerComponent.jsx | 7 ++++++- src/util/settings.js | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/QuerySettings/subcomponents/DatePickerComponent.jsx b/src/components/QuerySettings/subcomponents/DatePickerComponent.jsx index aa11fff1..2b8df47e 100644 --- a/src/components/QuerySettings/subcomponents/DatePickerComponent.jsx +++ b/src/components/QuerySettings/subcomponents/DatePickerComponent.jsx @@ -62,9 +62,14 @@ const DatePickerComponent = () => { // Generate since date based on configured default and dispatch action for query. const today = moment(); - const [sinceDateNum, sinceDateTenor] = defaultSinceDateTenor + let [sinceDateNum, sinceDateTenor] = defaultSinceDateTenor ? defaultSinceDateTenor.split(' ') : ['1', 'Day']; + + if (defaultSinceDateTenor === 'Today') { + sinceDateNum = '0'; + sinceDateTenor = 'Day'; + } const sinceDateCalc = DEBUG_SINCE_DATE ? new Date(DEBUG_SINCE_DATE) : today diff --git a/src/util/settings.js b/src/util/settings.js index 287537fa..497c37cb 100644 --- a/src/util/settings.js +++ b/src/util/settings.js @@ -5,6 +5,7 @@ import { /* eslint-disable import/prefer-default-export */ export const defaultSinceDateTenors = [ + 'Today', '1 Day', '3 Days', '1 Week', @@ -23,6 +24,7 @@ export const defaultSinceDateTenorsLabels = () => { t, } = useTranslation(); return { + Today: t('Today'), '1 Day': t('1 Day'), '3 Days': t('3 Days'), '1 Week': t('1 Week'),