Skip to content

Commit

Permalink
Add Condition to check the todays date
Browse files Browse the repository at this point in the history
  • Loading branch information
JavidSumra committed Nov 6, 2024
1 parent 6b57124 commit 938cfc9
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/components/Common/DateInputV2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,16 @@ const DateInputV2: React.FC<Props> = ({
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;
Expand Down Expand Up @@ -432,8 +442,15 @@ const DateInputV2: React.FC<Props> = ({
);
newDate.setDate(d);
selected =
value.toDateString() ===
newDate.toDateString();
value &&
dayjs(value).isSame(
new Date(
datePickerHeaderDate.getFullYear(),
datePickerHeaderDate.getMonth(),
d,
),
"day",
);
}

const baseClasses =
Expand Down

0 comments on commit 938cfc9

Please sign in to comment.