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

pull/293/head
Alex van Andel 2021-06-30 15:27:49 +00:00
parent 9fe11ea10d
commit bfc7cce688
2 changed files with 8 additions and 4 deletions

View File

@ -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;
});
}

View File

@ -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;