Fix: rental booking save (date comparison), add DB guest search in rental modal

- BookingCalendar: normalize date comparison with .slice(0,10) to fix PostgreSQL DATE ISO format mismatch
- CalendarPage: show alert on rental booking save failure
- RentalBookingModal: add debounced DB guest search (api.guests.list) with 300ms delay
- RentalBookingModal: combine booking suggestions + DB results in unified dropdown
- Pass slug prop to RentalBookingModal for API access

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-21 16:45:37 +03:00
parent 68c9caf46f
commit dbccc59dfc
3 changed files with 59 additions and 13 deletions

View File

@@ -669,7 +669,7 @@ export function BookingCalendar({ rooms, bookings, slug, onBookingCreate, onBook
const isWe = date.getDay() === 0 || date.getDay() === 6
const isTod = isToday(date)
const dayBookings = (rentalBookings ?? []).filter(
b => b.objectId === obj.id && b.date === dateStr && b.status !== 'cancelled',
b => b.objectId === obj.id && (b.date as string).slice(0, 10) === dateStr && b.status !== 'cancelled',
)
const hasFullDay = dayBookings.some(b => b.isFullDay)
@@ -791,10 +791,11 @@ export function BookingCalendar({ rooms, bookings, slug, onBookingCreate, onBook
obj={rentalModal.obj}
date={rentalModal.date}
existingBookings={(rentalBookings ?? []).filter(
b => b.objectId === rentalModal.obj.id && b.date === rentalModal.date,
b => b.objectId === rentalModal.obj.id && (b.date as string).slice(0, 10) === rentalModal.date,
)}
bookings={bookings}
rooms={rooms}
slug={slug}
onClose={() => setRentalModal(null)}
onSave={(b) => {
onRentalBookingCreate?.(b)