From 0c041be5e0eafab305f113764cca2d866904ac1a Mon Sep 17 00:00:00 2001 From: Joshua Allen <130792942+BrewCityBoy@users.noreply.github.com> Date: Thu, 25 Jan 2024 14:46:44 -0500 Subject: [PATCH 1/2] add logic for same date error --- src/components/Filters/DateFilter.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/Filters/DateFilter.js b/src/components/Filters/DateFilter.js index a42c39a2..5ec55bf6 100644 --- a/src/components/Filters/DateFilter.js +++ b/src/components/Filters/DateFilter.js @@ -111,7 +111,8 @@ export const DateFilter = () => { const style = ['a-text-input']; if ( dayjs(fromDate).isBefore(minDate) || - dayjs(fromDate).isAfter(throughDate) + dayjs(fromDate).isAfter(throughDate) || + dayjs(fromDate).isSame(throughDate) ) { style.push('a-text-input__error'); } @@ -122,7 +123,8 @@ export const DateFilter = () => { const style = ['a-text-input']; if ( dayjs(throughDate).isAfter(maxDate) || - dayjs(throughDate).isBefore(fromDate) + dayjs(throughDate).isBefore(fromDate) || + dayjs(throughDate).isSame(fromDate) ) { style.push('a-text-input__error'); } From 4908e0dda9513f6ae2e649ad3b239a05e278fcb4 Mon Sep 17 00:00:00 2001 From: Joshua Allen <130792942+BrewCityBoy@users.noreply.github.com> Date: Thu, 25 Jan 2024 15:31:16 -0500 Subject: [PATCH 2/2] add error message --- src/components/Filters/DateFilter.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/components/Filters/DateFilter.js b/src/components/Filters/DateFilter.js index 5ec55bf6..8d819e21 100644 --- a/src/components/Filters/DateFilter.js +++ b/src/components/Filters/DateFilter.js @@ -41,6 +41,7 @@ export const DateFilter = () => { const dispatch = useDispatch(); const errorMessageText = "'From' date must be less than 'through' date"; + const errorSameDate = "'From' date cannot be the same as 'Through' date"; const fromRef = useRef(); const throughRef = useRef(); @@ -82,6 +83,9 @@ export const DateFilter = () => { if (dayjs(fromDate).isAfter(throughDate)) { return errorMessageText; } + if (dayjs(fromDate).isSame(throughDate)) { + return errorSameDate; + } return false; }, [fromDate, throughDate]);