feat: connect RentalPage to API (objects + bookings persisted in DB)
- Add createObject/updateObject/deleteObject to api.rental - Add RentalObjectPayload interface - RentalPage now loads objects and bookings from API on mount - Save/delete object operations call the API instead of only local state - Save booking operations call the API (create or update) - bufferMinutes from DB is now correctly passed to booking modal Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -317,6 +317,15 @@ export const api = {
|
||||
listObjects: (slug: string) =>
|
||||
req<RentalObjectApi[]>('GET', `/api/hotels/${slug}/rental-objects`),
|
||||
|
||||
createObject: (slug: string, data: RentalObjectPayload) =>
|
||||
req<RentalObjectApi>('POST', `/api/hotels/${slug}/rental-objects`, data),
|
||||
|
||||
updateObject: (slug: string, id: string, data: Partial<RentalObjectPayload>) =>
|
||||
req<RentalObjectApi>('PATCH', `/api/hotels/${slug}/rental-objects/${id}`, data),
|
||||
|
||||
deleteObject: (slug: string, id: string) =>
|
||||
req<void>('DELETE', `/api/hotels/${slug}/rental-objects/${id}`),
|
||||
|
||||
listBookings: (slug: string, from?: string, to?: string) => {
|
||||
const qs = new URLSearchParams()
|
||||
if (from) qs.set('from', from)
|
||||
@@ -591,6 +600,20 @@ export interface RentalBookingPayload {
|
||||
notes?: string
|
||||
}
|
||||
|
||||
export interface RentalObjectPayload {
|
||||
name: string
|
||||
icon?: string
|
||||
color?: string
|
||||
text_color?: string
|
||||
price_per_hour?: number
|
||||
price_per_day?: number
|
||||
open_hour?: number
|
||||
close_hour?: number
|
||||
max_hours_per_slot?: number | null
|
||||
buffer_minutes?: number
|
||||
sort_order?: number
|
||||
}
|
||||
|
||||
function toHotelPayload(h: HotelPayload): Record<string, unknown> {
|
||||
const out: Record<string, unknown> = {}
|
||||
if (h.name !== undefined) out.name = h.name
|
||||
|
||||
Reference in New Issue
Block a user