Skip to content

Commit

Permalink
Merge pull request #1776 from bphan002/1759-restrict-future-date-sele…
Browse files Browse the repository at this point in the history
…ction

1759 restrict future date selection
  • Loading branch information
bphan002 authored Jun 21, 2024
2 parents cbd3de8 + 28ddc49 commit cfb0808
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion components/common/ReactDayPicker/ReactDayPicker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const useStyles = makeStyles(theme => ({

'& .DayPicker-Day--disabled': {
color: colors.textSecondaryDark,
pointerEvents: 'none',
},

/* Day cell hover */
Expand Down Expand Up @@ -207,7 +208,9 @@ function ReactDayPicker({
const from = moment(startDate).toDate();
const enteredToDate = moment(enteredTo).toDate();
const today = new Date();
const lastThreeMonths = new Date(today.getFullYear(), today.getMonth() - 3, today.getDate());
const currentMonth = today.getFullYear();
const currentYear = today.getMonth();
const lastThreeMonths = new Date(currentYear, currentMonth - 3, today.getDate());

return (
<>
Expand All @@ -223,6 +226,7 @@ function ReactDayPicker({
onDayMouseEnter={handleDayMouseEnter}
weekdayElement={<WeekDay />}
fromMonth={new Date(2019, 12)}
toMonth={new Date(currentMonth, currentYear)}
/>
</>
);
Expand Down

0 comments on commit cfb0808

Please sign in to comment.