fix(booking): prevent past time slots from being selectable for today
This commit is contained in:
@@ -147,6 +147,9 @@ function buildSegmentsForCourt(
|
||||
const segments: BookingTimelineSegment[] = [];
|
||||
const slotDuration = court.slotDurationMinutes;
|
||||
|
||||
const nowMinutes = timeToMinutes(getNowTime());
|
||||
const isToday = isTodayIso(selectedDate);
|
||||
|
||||
const availabilityRanges = court.availability
|
||||
.filter((range) => range.dayOfWeek === dayOfWeek)
|
||||
.map((range) => ({
|
||||
@@ -181,6 +184,9 @@ function buildSegmentsForCourt(
|
||||
slotStart += slotDuration
|
||||
) {
|
||||
const slotEnd = slotStart + slotDuration;
|
||||
|
||||
if (isToday && slotEnd <= nowMinutes) continue;
|
||||
|
||||
const isBooked = courtBookings.some((booking) =>
|
||||
overlapsBooking(slotStart, slotEnd, booking)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user