Skip to content

Commit

Permalink
Fix bug that neither planned or used counted today (#507)
Browse files Browse the repository at this point in the history
  • Loading branch information
sigridge committed Jul 24, 2024
1 parent 6d6b7c2 commit c7cd31f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion backend/Core/DomainModels/Consultant.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public int GetUsedVacationDays(DateOnly day)

public int GetPlannedVacationDays(DateOnly day)
{
return Vacations.Where(v => v.Date.Year.Equals(day.Year)).Count(v => v.Date > day);
return Vacations.Where(v => v.Date.Year.Equals(day.Year)).Count(v => v.Date >= day);
}

public int GetRemainingVacationDays(DateOnly day)
Expand Down
8 changes: 6 additions & 2 deletions frontend/src/components/VacationCalendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ export default function VacationCalendar({
onChange={handleChange}
className="custom-calendar"
mapDays={({ date }) => {
//Since the date object is created before the today object, an extra hour is added to a copied version of the date object to ensure that you can edit today
const dateCopy = new DateObject(date);
dateCopy.add(1, "h");

let isWeekend = [0, 6].includes(date.weekDay.index);
if (
vacationDays.vacationDays?.includes(
Expand All @@ -147,7 +151,7 @@ export default function VacationCalendar({
date.day > 9 ? date.day.toString() : "0" + date.day.toString()
}`,
) &&
date.toDate() <= new Date()
dateCopy.toDate() < new Date()
)
return {
disabled: true,
Expand All @@ -172,7 +176,7 @@ export default function VacationCalendar({
disabled: true,
style: { color: "#B91456", opacity: 0.5 },
};
else if (isWeekend || date.toDate() <= new Date())
else if (isWeekend || dateCopy.toDate() < new Date())
return {
disabled: true,
style: { color: "#00445B", opacity: 0.5 },
Expand Down

0 comments on commit c7cd31f

Please sign in to comment.