Fix slots

This commit is contained in:
Arthur Belleville 2025-10-02 18:57:02 +02:00
parent 9488f6e5b6
commit f5e02a50fa
No known key found for this signature in database
2 changed files with 45 additions and 1 deletions

View file

@ -203,6 +203,45 @@ describe("generateTimeSlots", () => {
expect(slots).to.have.length(0);
});
it("should handle exception with date with minutes and seconds", () => {
const dayExceptionWithTime: Exception = {
date: "2024-01-16T10:30:45.123Z", // Date with time components
type: "day",
};
const slots = generateTimeSlots(
testDate, // currentTime
testDate, // date
basicAvailability,
basicEventTypeConfig,
[dayExceptionWithTime],
existingEvents
);
expect(slots).to.have.length(0);
});
it("should handle hours exception with date containing time components", () => {
const hoursExceptionWithTime: Exception = {
date: "2024-01-16T10:30:45.123Z", // Date with time components
type: "hours",
hours: [{ start: "10:00", end: "12:00" }],
};
const slots = generateTimeSlots(
testDate, // currentTime
testDate, // date
basicAvailability,
basicEventTypeConfig,
[hoursExceptionWithTime],
existingEvents
);
expect(slots).to.have.length(4); // 2 hours * 2 slots per hour
expect(slots[0].time).to.equal("10:00");
expect(slots[3].time).to.equal("11:30");
});
it("should use exception hours instead of regular availability", () => {
const hoursException: Exception = {
date: "2024-01-16",

View file

@ -193,7 +193,12 @@ export function generateTimeSlots(
const slots: TimeSlot[] = [];
// Check if this date has an exception
const exception = exceptions.find((e) => e.date === dateStr);
const exception = exceptions.find((e) => {
const exceptionDate = new Date(e.date);
const exceptionDateCET = convertToCET(exceptionDate);
const exceptionDateStr = getDateString(exceptionDateCET);
return exceptionDateStr === dateStr;
});
// If there's a "day" exception, no slots available
if (exception?.type === "day") {