feat: widget additional services — sourced from rental objects module

- Additional services in widget are now derived from rental_objects (not a separate list)
- Settings page shows rental objects with enable/disable toggle; link to rental module
- Saves only {id, enabled}[] to widget_services — rental objects manage name/price/icon
- Standalone widget also derives additionalServices from config.rentalObjects
- Widget config API includes services[] in widgetSettings

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-10 12:13:13 +03:00
parent c8ff5ad0ed
commit c153e12543
4 changed files with 73 additions and 126 deletions

View File

@@ -37,22 +37,38 @@ export function BookingWidgetStandalonePage() {
setRealCategories(config.categories ?? [])
setRealRentalObjects(config.rentalObjects ?? [])
setPaymentEnabled(config.paymentEnabled)
const rentalObjs = config.rentalObjects ?? []
const deriveServices = (savedServices: { id: string; enabled: boolean }[] | null | undefined) =>
rentalObjs.map(o => ({
id: o.id,
name: o.name,
icon: o.icon,
price: o.pricePerHour,
unit: 'ч',
enabled: savedServices ? (savedServices.find(s => s.id === o.id)?.enabled ?? true) : true,
}))
if (config.widgetSettings) {
const ws = config.widgetSettings
setSettings(prev => ({
...prev,
hotelName: ws.hotelName ?? config.hotelName ?? prev.hotelName,
primaryColor: ws.primaryColor ?? prev.primaryColor,
language: (ws.language ?? prev.language) as 'ru' | 'en',
roomDisplayMode: (ws.roomDisplayMode ?? prev.roomDisplayMode) as 'rooms' | 'categories',
minNights: ws.minNights ?? prev.minNights,
showRental: ws.showRental ?? prev.showRental,
showPromo: ws.showPromo ?? prev.showPromo,
allowExtraBeds: ws.allowExtraBeds ?? prev.allowExtraBeds,
allowChildren: ws.allowChildren ?? prev.allowChildren,
hotelName: ws.hotelName ?? config.hotelName ?? prev.hotelName,
primaryColor: ws.primaryColor ?? prev.primaryColor,
language: (ws.language ?? prev.language) as 'ru' | 'en',
roomDisplayMode: (ws.roomDisplayMode ?? prev.roomDisplayMode) as 'rooms' | 'categories',
minNights: ws.minNights ?? prev.minNights,
showRental: ws.showRental ?? prev.showRental,
showPromo: ws.showPromo ?? prev.showPromo,
allowExtraBeds: ws.allowExtraBeds ?? prev.allowExtraBeds,
allowChildren: ws.allowChildren ?? prev.allowChildren,
additionalServices: rentalObjs.length > 0 ? deriveServices(ws.services) : prev.additionalServices,
}))
} else {
setSettings(prev => ({ ...prev, hotelName: config.hotelName ?? prev.hotelName }))
setSettings(prev => ({
...prev,
hotelName: config.hotelName ?? prev.hotelName,
additionalServices: rentalObjs.length > 0 ? deriveServices(null) : prev.additionalServices,
}))
}
})
.catch(() => {})