Skip to content

Scheduling infrastructure for absolutely everyone.

Make sure the slots equal the month and date of the invitee so we can check isSame with freebusy

Alex van Andelbfc7cce68883
diff --git a/components/booking/Slots.tsx b/components/booking/Slots.tsx
index 3c689d5c38c..8f92aaeb148 100644
--- a/components/booking/Slots.tsx
+++ b/components/booking/Slots.tsx
@@ -54,12 +54,11 @@ const Slots = ({ eventLength, minimumBookingNotice, date, workingHours, organize
// Check for conflicts
for (let i = times.length - 1; i >= 0; i -= 1) {
- busyTimes.forEach((busyTime) => {
+ busyTimes.every((busyTime): boolean => {
const startTime = dayjs(busyTime.start).utc();
const endTime = dayjs(busyTime.end).utc();
-
// Check if start times are the same
- if (times[i].utc().format("HH:mm") == startTime.format("HH:mm")) {
+ if (times[i].utc().isSame(startTime)) {
times.splice(i, 1);
}
// Check if time is between start and end times
@@ -73,7 +72,10 @@ const Slots = ({ eventLength, minimumBookingNotice, date, workingHours, organize
// Check if startTime is between slot
else if (startTime.isBetween(times[i].utc(), times[i].utc().add(eventLength, "minutes"))) {
times.splice(i, 1);
+ } else {
+ return true;
}
+ return false;
});
}
diff --git a/lib/slots.ts b/lib/slots.ts
index 35d06a65a1f..5beeb9f8af3 100644
--- a/lib/slots.ts
+++ b/lib/slots.ts
@@ -126,7 +126,9 @@ const getSlots = ({
organizerBoundaries(workingHours, inviteeDate, inviteeBounds, organizerTimeZone)
)
.reduce((slots, boundary: Boundary) => [...slots, ...getSlotsBetweenBoundary(frequency, boundary)], [])
- .map((slot) => slot.utcOffset(dayjs(inviteeDate).utcOffset()));
+ .map((slot) =>
+ slot.month(inviteeDate.month()).date(inviteeDate.date()).utcOffset(inviteeDate.utcOffset())
+ );
};
export default getSlots;