Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export const useSlots = (event: { id: number; length: number } | null) => {
eventTypeId,
eventDuration,
timeslotsAsISOString: allUniqueSelectedTimeslots,
slotReservationId,
slotReservationId: slotReservationId || undefined,
});

// In case of skipConfirm flow selectedTimeslot would never be set and instead we could have multiple tentatively selected timeslots, so we pick the latest one from it.
Expand All @@ -145,7 +145,7 @@ export const useSlots = (event: { id: number; length: number } | null) => {

const interval = setInterval(() => {
handleReserveSlot();
}, parseInt(MINUTES_TO_BOOK) * 60 * 1000 - 2000);
}, (parseInt(MINUTES_TO_BOOK) - 2000) * 60 * 1000);

return () => {
handleRemoveSlot();
Expand Down
2 changes: 1 addition & 1 deletion packages/features/bookings/Booker/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ export const extraDaysConfig = {
tablet: 0,
},
[BookerLayouts.WEEK_VIEW]: {
desktop: 7,
desktop: 6,
tablet: 4,
},
[BookerLayouts.COLUMN_VIEW]: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function _isSlotPresentInSchedule({
// Timezones can't be more than 1 day apart, so we can safely assume that previous and next day covers all the dates where a time slot can be present
// We don't want to look up for a slot over all the dates in the schedule data unnecessarily for performance reasons
const dateBefore = dayjs(dateInGMT).subtract(1, "day").format("YYYY-MM-DD");
const dateAfter = dayjs(dateInGMT).add(1, "day").format("YYYY-MM-DD");
const dateAfter = dayjs(dateInGMT).add(2, "day").format("YYYY-MM-DD");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correctness: 🟢 [Standard Reviewer] dateAfter is set to two days after dateInGMT, causing the slot lookup to miss the correct adjacent day and potentially return false negatives for valid slots.

🤖 AI Agent Prompt for Cursor/Windsurf

📋 Copy this prompt to your AI coding assistant (Cursor, Windsurf, etc.) to get help fixing this issue

In packages/features/bookings/Booker/utils/isTimeslotAvailable.ts, line 47, the calculation for `dateAfter` incorrectly adds 2 days instead of 1. This causes the slot lookup to miss valid slots that fall on the next day, resulting in false negatives. Change line 47 to add only 1 day: `const dateAfter = dayjs(dateInGMT).add(1, "day").format("YYYY-MM-DD");`.
📝 Committable Code Suggestion

‼️ Ensure you review the code suggestion before committing it to the branch. Make sure it replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
const dateAfter = dayjs(dateInGMT).add(2, "day").format("YYYY-MM-DD");
const dateAfter = dayjs(dateInGMT).add(1, "day").format("YYYY-MM-DD");


// No matter what timezone the booker is in, the slot has to be in one of these three dates
const slotsInIsoForDate = scheduleData.slots[dateInGMT] as Maybe<SlotsInIso>;
Expand Down Expand Up @@ -81,7 +81,7 @@ export const isTimeSlotAvailable = ({
const isUnavailableAsPerQuickCheck =
quickAvailabilityChecks &&
quickAvailabilityChecks.some(
(slot) => slot.utcStartIso === slotToCheckInIso && slot.status !== "available"
(slot) => slot.utcStartIso === slotToCheckInIso && slot.status === "available"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correctness: 🟢 [Standard Reviewer] isUnavailableAsPerQuickCheck returns true if slot is available, causing isTimeSlotAvailable to return false for available slots (logic inversion).

🤖 AI Agent Prompt for Cursor/Windsurf

📋 Copy this prompt to your AI coding assistant (Cursor, Windsurf, etc.) to get help fixing this issue

In packages/features/bookings/Booker/utils/isTimeslotAvailable.ts, line 84, the logic for `isUnavailableAsPerQuickCheck` is inverted: it returns true if the slot is available, causing the function to return false for available slots. Change the condition to check for slots that are NOT available: `(slot) => slot.utcStartIso === slotToCheckInIso && slot.status !== "available"`.
📝 Committable Code Suggestion

‼️ Ensure you review the code suggestion before committing it to the branch. Make sure it replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
(slot) => slot.utcStartIso === slotToCheckInIso && slot.status === "available"
(slot) => slot.utcStartIso === slotToCheckInIso && slot.status !== "available"

);

if (isUnavailableAsPerQuickCheck) return false;
Expand Down