fix: slot start times with interrupted availabilities (#10164)

Co-authored-by: CarinaWolli <wollencarina@gmail.com>
pull/10169/head
Carina Wollendorfer 2023-07-14 18:57:05 -04:00 committed by GitHub
parent 7953551189
commit 5ff8d2db6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 31 deletions

View File

@ -166,19 +166,6 @@ function buildSlotsWithDateRanges({
let slotStartTime = range.start.isAfter(startTimeWithMinNotice) ? range.start : startTimeWithMinNotice;
let previousStartTime;
// check if we we already have slots on that day (in organizer's timezone)
if (
slots.length &&
dayjs
.utc(range.start)
.add(range.start.utcOffset())
.isSame(dayjs.utc(slots[slots.length - 1].time).add(slots[slots.length - 1].time.utcOffset()), "day")
) {
previousStartTime = slots[slots.length - 1].time;
}
if (!previousStartTime) {
let interval = 15;
const intervalsWithDefinedStartTimes = [60, 30, 20, 10];
@ -192,15 +179,8 @@ function buildSlotsWithDateRanges({
slotStartTime =
slotStartTime.utc().minute() % interval !== 0
? slotStartTime
.startOf("hour")
.add(Math.ceil(slotStartTime.minute() / interval) * interval, "minute")
? slotStartTime.startOf("hour").add(Math.ceil(slotStartTime.minute() / interval) * interval, "minute")
: slotStartTime;
} else {
const minuteOffset =
Math.ceil(slotStartTime.diff(previousStartTime, "minutes") / frequency) * frequency;
slotStartTime = previousStartTime.add(minuteOffset, "minutes");
}
// Adding 1 minute to date ranges that end at midnight to ensure that the last slot is included
const rangeEnd = range.end