diff --git a/web/src/pages/Booking.tsx b/web/src/pages/Booking.tsx index 5b9daed..a76e409 100644 --- a/web/src/pages/Booking.tsx +++ b/web/src/pages/Booking.tsx @@ -65,8 +65,22 @@ export default function Booking() { }) .filter(Boolean); + const today = new Date(); + const todayStr = today.toISOString().split('T')[0]; + const isToday = date === todayStr; + const currentHour = today.getHours(); + const currentMinute = today.getMinutes(); + return slots.map(time => { - const isBooked = bookedSlots.includes(time); + let isPast = false; + if (isToday) { + const [h, m] = time.split(':').map(Number); + if (h < currentHour || (h === currentHour && m <= currentMinute)) { + isPast = true; + } + } + + const isBooked = bookedSlots.includes(time) || isPast; const waitlistedByMe = user ? waitlists.some(w => w.barberId === barberId && w.date === `${date} ${time}` && w.customerId === user.id && w.status === 'pending') : false; return { time, isBooked, waitlistedByMe }; });