Fix booking creation: localStorage token, conflict detection, paid_amount
- Fix api.ts getToken/saveToken to read from localStorage (matching AuthContext) — was reading sessionStorage causing all API requests to fail auth until refresh - Fix session cleanup on 401 to use localStorage - Add isConflict/availableRooms helpers to BookingModal; show amber warning when selected room is occupied with clickable free room suggestions - Pass bookings prop to BookingModal via BookingCalendar - Add paid_amount to backend POST /bookings INSERT - Show alert() when booking creation fails so user sees the error - Pass paidAmount in CalendarPage handleCreate Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -58,13 +58,15 @@ export function CalendarPage() {
|
||||
checkIn: data.checkIn, checkOut: data.checkOut,
|
||||
adults: data.adults, children: data.children,
|
||||
status: data.status, source: data.source,
|
||||
totalAmount: data.totalAmount, notes: data.notes,
|
||||
totalAmount: data.totalAmount, paidAmount: data.paidAmount, notes: data.notes,
|
||||
})
|
||||
setBookings(prev => [...prev, created])
|
||||
send({ type: 'booking:created', booking: created })
|
||||
if (data.roomId) send({ type: 'unlock', roomId: data.roomId })
|
||||
} catch (err) {
|
||||
console.error('Failed to create booking:', err)
|
||||
const msg = err instanceof Error ? err.message : 'Ошибка создания бронирования'
|
||||
alert(msg)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user