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

@@ -1,6 +1,6 @@
import { useState, useEffect } from 'react'
import { useParams, useSearchParams } from 'react-router-dom'
import { api, type WidgetRoom, type WidgetCategory } from '../lib/api'
import { api, type WidgetRoom, type WidgetCategory, type WidgetRentalObject } from '../lib/api'
import { WidgetPreview, DEFAULT_FORM_FIELDS, DEFAULT_SERVICES } from './BookingWidgetPage'
import type { WidgetSettings } from './BookingWidgetPage'
@@ -8,8 +8,9 @@ export function BookingWidgetStandalonePage() {
const { slug } = useParams<{ slug: string }>()
const [searchParams] = useSearchParams()
const [realRooms, setRealRooms] = useState<WidgetRoom[]>([])
const [realCategories, setRealCategories] = useState<WidgetCategory[]>([])
const [realRooms, setRealRooms] = useState<WidgetRoom[]>([])
const [realCategories, setRealCategories] = useState<WidgetCategory[]>([])
const [realRentalObjects, setRealRentalObjects] = useState<WidgetRentalObject[]>([])
const [paymentEnabled, setPaymentEnabled] = useState<boolean | undefined>(undefined)
const [settings, setSettings] = useState<WidgetSettings>({
hotelName: '',
@@ -34,6 +35,7 @@ export function BookingWidgetStandalonePage() {
.then(config => {
setRealRooms(config.rooms ?? [])
setRealCategories(config.categories ?? [])
setRealRentalObjects(config.rentalObjects ?? [])
setPaymentEnabled(config.paymentEnabled)
if (config.widgetSettings) {
const ws = config.widgetSettings
@@ -64,6 +66,7 @@ export function BookingWidgetStandalonePage() {
slug={slug}
realRooms={realRooms.length > 0 ? realRooms : undefined}
realCategories={realCategories.length > 0 ? realCategories : undefined}
realRentalObjects={realRentalObjects.length > 0 ? realRentalObjects : undefined}
paymentEnabled={paymentEnabled}
/>
</div>