From 938cfc9178cbfc6a9bcdab5cdeeae8a03c3dada1 Mon Sep 17 00:00:00 2001 From: JavidSumra Date: Wed, 6 Nov 2024 14:25:39 +0530 Subject: [PATCH 1/2] Add Condition to check the todays date --- src/components/Common/DateInputV2.tsx | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/components/Common/DateInputV2.tsx b/src/components/Common/DateInputV2.tsx index 87a29debe5b..ecd15033019 100644 --- a/src/components/Common/DateInputV2.tsx +++ b/src/components/Common/DateInputV2.tsx @@ -190,6 +190,16 @@ const DateInputV2: React.FC = ({ year = datePickerHeaderDate.getFullYear(), ) => { const date = new Date(year, month, day); + if ( + min && + max && + min.getDate() === max.getDate() && + day === min.getDate() && + month === min.getMonth() && + year === min.getFullYear() + ) { + return true; + } if (min) if (date < min) return false; if (max) if (date > max) return false; return true; @@ -432,8 +442,15 @@ const DateInputV2: React.FC = ({ ); newDate.setDate(d); selected = - value.toDateString() === - newDate.toDateString(); + value && + dayjs(value).isSame( + new Date( + datePickerHeaderDate.getFullYear(), + datePickerHeaderDate.getMonth(), + d, + ), + "day", + ); } const baseClasses = From b018cf1a1528f74b402271ca819c264f2ccd13b9 Mon Sep 17 00:00:00 2001 From: JavidSumra Date: Wed, 6 Nov 2024 14:37:25 +0530 Subject: [PATCH 2/2] Remove unnecessary changes --- src/components/Common/DateInputV2.tsx | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/components/Common/DateInputV2.tsx b/src/components/Common/DateInputV2.tsx index ecd15033019..627abdcf327 100644 --- a/src/components/Common/DateInputV2.tsx +++ b/src/components/Common/DateInputV2.tsx @@ -442,15 +442,8 @@ const DateInputV2: React.FC = ({ ); newDate.setDate(d); selected = - value && - dayjs(value).isSame( - new Date( - datePickerHeaderDate.getFullYear(), - datePickerHeaderDate.getMonth(), - d, - ), - "day", - ); + value.toDateString() === + newDate.toDateString(); } const baseClasses =