From add297b09a6c242f21348043e4f1000368a35753 Mon Sep 17 00:00:00 2001 From: dihedral Date: Thu, 14 Sep 2023 16:40:49 +0200 Subject: [PATCH] fix: use selected duration when checking for conflicts for new bookings (#10713) --- packages/features/bookings/lib/handleNewBooking.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/features/bookings/lib/handleNewBooking.ts b/packages/features/bookings/lib/handleNewBooking.ts index 4d3c48594e..11194e8b80 100644 --- a/packages/features/bookings/lib/handleNewBooking.ts +++ b/packages/features/bookings/lib/handleNewBooking.ts @@ -367,6 +367,7 @@ async function ensureAvailableUsers( } ) { const availableUsers: IsFixedAwareUser[] = []; + const duration = dayjs(input.dateTo).diff(input.dateFrom, 'minute'); const originalBookingDuration = input.originalRescheduledBooking ? dayjs(input.originalRescheduledBooking.endTime).diff( @@ -411,10 +412,10 @@ async function ensureAvailableUsers( // running at the first unavailable time. let i = 0; while (!foundConflict && i < allBookingDates.length) { - foundConflict = checkForConflicts(bufferedBusyTimes, allBookingDates[i++], eventType.length); + foundConflict = checkForConflicts(bufferedBusyTimes, allBookingDates[i++], duration); } } else { - foundConflict = checkForConflicts(bufferedBusyTimes, input.dateFrom, eventType.length); + foundConflict = checkForConflicts(bufferedBusyTimes, input.dateFrom, duration); } } catch { log.debug({