Skip to content

Commit ce279da

Browse files
fix: stabilize date range calculation in column view (calcom#25384)
* fix: stabilize date range calculation in column view * fix: restore eslint-disable for scrollIntoViewSmooth --------- Co-authored-by: Pallav <90088723+Pallava-Joshi@users.noreply.github.com>
1 parent 7dbc888 commit ce279da

1 file changed

Lines changed: 11 additions & 10 deletions

File tree

packages/features/bookings/Booker/Booker.tsx

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,15 @@ const BookerComponent = ({
123123
const addonDays =
124124
nonEmptyScheduleDays.length < extraDays
125125
? (extraDays - nonEmptyScheduleDays.length + 1) * totalWeekDays
126-
: nonEmptyScheduleDays.length === extraDays
127-
? totalWeekDays
128126
: 0;
129127
// Taking one more available slot(extraDays + 1) to calculate the no of days in between, that next and prev button need to shift.
130128
const availableSlots = nonEmptyScheduleDays.slice(0, extraDays + 1);
131-
if (nonEmptyScheduleDays.length !== 0)
129+
if (nonEmptyScheduleDays.length !== 0) {
130+
const slotIndex =
131+
availableSlots.length === extraDays + 1 ? availableSlots.length - 2 : availableSlots.length - 1;
132132
columnViewExtraDays.current =
133-
Math.abs(dayjs(selectedDate).diff(availableSlots[availableSlots.length - 2], "day")) + addonDays;
133+
Math.abs(dayjs(selectedDate).diff(availableSlots[slotIndex], "day")) + addonDays;
134+
}
134135

135136
const nextSlots =
136137
Math.abs(dayjs(selectedDate).diff(availableSlots[availableSlots.length - 1], "day")) + addonDays;
@@ -222,12 +223,12 @@ const BookerComponent = ({
222223

223224
const unavailableTimeSlots = isQuickAvailabilityCheckFeatureEnabled
224225
? allSelectedTimeslots.filter((slot) => {
225-
return !isTimeSlotAvailable({
226-
scheduleData: schedule?.data ?? null,
227-
slotToCheckInIso: slot,
228-
quickAvailabilityChecks: slots.quickAvailabilityChecks,
229-
});
230-
})
226+
return !isTimeSlotAvailable({
227+
scheduleData: schedule?.data ?? null,
228+
slotToCheckInIso: slot,
229+
quickAvailabilityChecks: slots.quickAvailabilityChecks,
230+
});
231+
})
231232
: [];
232233

233234
const slot = getQueryParam("slot");

0 commit comments

Comments
 (0)