From c0a086a7b8982867850310c064831a291c9d45df Mon Sep 17 00:00:00 2001 From: HotelSync Date: Sat, 21 Mar 2026 19:30:02 +0300 Subject: [PATCH] fix: normalize checkIn/checkOut dates with .slice(0,10) before comparison PostgreSQL DATE columns serialize as ISO strings with time component (2026-03-21T00:00:00.000Z), causing string comparison with yyyy-MM-dd to incorrectly show the early check-in banner for same-day bookings. Co-Authored-By: Claude Sonnet 4.6 --- src/components/bookings/BookingDetailPanel.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/components/bookings/BookingDetailPanel.tsx b/src/components/bookings/BookingDetailPanel.tsx index 94290b4..00e472e 100644 --- a/src/components/bookings/BookingDetailPanel.tsx +++ b/src/components/bookings/BookingDetailPanel.tsx @@ -275,13 +275,15 @@ export function BookingDetailPanel({ booking, room, rooms, allBookings, slug, on const canRelocate = booking.status === 'checked_in' const today = format(new Date(), 'yyyy-MM-dd') - const canEarlyCheckIn = booking.status === 'confirmed' && booking.checkIn > today + const checkInDate = booking.checkIn.slice(0, 10) + const checkOutDate = booking.checkOut.slice(0, 10) + const canEarlyCheckIn = booking.status === 'confirmed' && checkInDate > today const [relocating, setRelocating] = useState(false) const [relocateRoomId, setRelocateRoomId] = useState(booking.roomId) const [earlyOpen, setEarlyOpen] = useState(false) - const [earlyNewCheckOut, setEarlyNewCheckOut] = useState(booking.checkOut) + const [earlyNewCheckOut, setEarlyNewCheckOut] = useState(checkOutDate) const [earlyRoomId, setEarlyRoomId] = useState(booking.roomId) const [earlySaving, setEarlySaving] = useState(false) @@ -579,7 +581,7 @@ export function BookingDetailPanel({ booking, room, rooms, allBookings, slug, on