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 0135e3e commit 3437489
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 @@ -592,6 +592,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 @@ -686,8 +706,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 @@ -712,10 +730,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 3437489

Please sign in to comment.