feat: widget rental tab — real objects, time slots, actual rental_bookings

- Add rental_objects to /api/widget/:slug/config response
- Add POST /api/widget/:slug/rental-bookings endpoint with availability check
- Widget rental tab now shows real rental objects (not additionalServices)
- Date picker, hourly or full-day toggle, start/end hour selectors
- Booking submit creates actual rental_booking record in DB
- Success screen shows rental object, date and time slot
- WidgetRentalObject + WidgetRentalBookingPayload types added to api.ts
- BookingWidgetStandalonePage passes rentalObjects to WidgetPreview

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-08 11:32:10 +03:00
parent cda515c0d8
commit 59307ba6b4
4 changed files with 263 additions and 54 deletions

View File

@@ -885,6 +885,16 @@ export const api = {
return r.json() as Promise<{ first_name: string; last_name: string; middle_name?: string; email?: string; phone?: string; is_blacklisted: boolean }>
})
},
createRentalBooking: (slug: string, data: WidgetRentalBookingPayload) =>
fetch(`${BASE}/api/widget/${slug}/rental-bookings`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(data),
}).then(async r => {
const json = await r.json()
if (!r.ok) throw { status: r.status, ...json }
return json as { bookingId: string; status: string }
}),
},
}
@@ -1662,6 +1672,31 @@ export interface WidgetCategory {
maxGuests: number
}
export interface WidgetRentalObject {
id: string
name: string
icon: string
pricePerHour: number
pricePerDay: number
openHour: number
closeHour: number
maxHoursPerSlot: number | null
bufferMinutes: number
}
export interface WidgetRentalBookingPayload {
objectId: string
date: string
isFullDay?: boolean
startHour?: number
endHour?: number
guestName: string
guestEmail?: string
guestPhone?: string
totalAmount: number
notes?: string
}
export interface WidgetConfig {
hotelId: string
hotelName: string
@@ -1670,6 +1705,7 @@ export interface WidgetConfig {
currency: string
rooms: WidgetRoom[]
categories: WidgetCategory[]
rentalObjects?: WidgetRentalObject[]
widgetSettings?: {
primaryColor: string
language: string