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 <noreply@anthropic.com>
This commit is contained in:
@@ -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
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
onClick={() => { setEarlyOpen(true); setEarlyRoomId(booking.roomId); setEarlyNewCheckOut(booking.checkOut) }}
|
||||
onClick={() => { setEarlyOpen(true); setEarlyRoomId(booking.roomId); setEarlyNewCheckOut(checkOutDate) }}
|
||||
className="shrink-0 text-xs font-semibold text-amber-700 dark:text-amber-300 bg-amber-100 dark:bg-amber-800/40 hover:bg-amber-200 dark:hover:bg-amber-700/50 px-2.5 py-1 rounded-lg transition-colors"
|
||||
>
|
||||
Заселить
|
||||
@@ -1293,7 +1295,7 @@ export function BookingDetailPanel({ booking, room, rooms, allBookings, slug, on
|
||||
</div>
|
||||
)}
|
||||
|
||||
{booking.status === 'confirmed' && booking.checkIn <= today && (() => {
|
||||
{booking.status === 'confirmed' && checkInDate <= today && (() => {
|
||||
const nowTime = format(new Date(), 'HH:mm')
|
||||
const isEarlyArrival = earlyCheckinEnabled && nowTime < hotelCheckInTime && (room?.earlyCheckinFee ?? 0) > 0
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user