Skip to content

Commit

Permalink
#601 add validation for start and end date
Browse files Browse the repository at this point in the history
  • Loading branch information
HenrikeW committed Sep 22, 2022
1 parent b0de4c9 commit 286076f
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions frontend/src/pages/AbsencePlanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,26 @@ export const AbsencePlanner = () => {
"Please fill in both the starting and end date of your absence",
},
]);
} else if (startDate < new Date()) {
setToastList([
...toastList,
{
type: "warning",
timeout: 10000,
message: "Please choose a start date that is not in the past.",
},
]);
} else if (
endDate > new Date(`January 1, ${startDate.getFullYear() + 10}`)
) {
setToastList([
...toastList,
{
type: "warning",
timeout: 10000,
message: "You can't plan absence more than 10 years ahead.",
},
]);
} else if (
startDate.getTime() &&
endDate.getTime() &&
Expand Down Expand Up @@ -649,8 +669,6 @@ export const AbsencePlanner = () => {
document.getElementById("toDate").focus();
}}
showWeekNumbers
minDate={new Date()}
maxDate={new Date(`January 1, ${new Date().getFullYear() + 10}`)}
locale={sv}
showYearDropdown
todayButton="Idag"
Expand All @@ -675,10 +693,6 @@ export const AbsencePlanner = () => {
document.getElementById("addAbsence").focus();
}}
showWeekNumbers
minDate={startDate}
maxDate={
startDate && new Date(`January 1, ${startDate.getFullYear() + 10}`)
}
locale={sv}
showYearDropdown
todayButton="Idag"
Expand Down

0 comments on commit 286076f

Please sign in to comment.