Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1308 fe preventing dates longer than 3 months #1342

Merged
merged 7 commits into from
Sep 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 3 additions & 13 deletions client/components/DateSelector/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import { DateUtils } from 'react-day-picker';
const today = new Date();

const oneMonthBack = DateUtils.addMonths(today, -1);
const sixMonthsBack = DateUtils.addMonths(today, -6);
const twelveMonthsBack = DateUtils.addMonths(today, -12);
const startOfThisYear = new Date(`1/1/${today.getFullYear()}`);
const threeMonthsBack = DateUtils.addMonths(today, -3);
const oneWeekBack = new Date(new Date().setDate(today.getDate() - 7));

const options = [
Expand All @@ -18,16 +16,8 @@ const options = [
dates: [oneMonthBack, today],
},
{
text: 'Last 6 months',
dates: [sixMonthsBack, today],
},
{
text: 'Last 12 months',
dates: [twelveMonthsBack, today],
},
{
text: 'Year to Date',
dates: [startOfThisYear, today],
text: 'Last 3 Months',
dates: [threeMonthsBack, today],
},
];

Expand Down
3 changes: 3 additions & 0 deletions client/components/common/ReactDayPicker/ReactDayPicker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,15 @@ 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());

return (
<>
<Styles range={range} />
<DayPicker
className="Range"
disabledDays={{ before: lastThreeMonths, after: today }}
numberOfMonths={1}
fromMonth={from}
selectedDays={[from, { from, to: enteredToDate }]}
Expand Down