Room planner: flexible category field resolution + debug logging
Resolve NewBook category fields from site_category_id, category_id, or category.id (whichever is present) so categories work regardless of which naming convention the NewBook region uses. Log the first site's keys on each /api/rooms request to confirm field names in docker compose logs. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
00e5e684fa
commit
663ef5d107
2 changed files with 23 additions and 7 deletions
|
|
@ -95,13 +95,19 @@ export function classifyRoom(site, allBookings, viewDate, yesterday, tomorrow) {
|
|||
const arrivalDate = primaryBooking ? toDateStr(primaryBooking.booking_arrival) : null
|
||||
const departureDate = primaryBooking ? toDateStr(primaryBooking.booking_departure) : null
|
||||
|
||||
// NewBook may return category info as flat fields (site_category_id, category_id)
|
||||
// or as a nested object. Resolve whichever is present.
|
||||
const catId = site.site_category_id ?? site.category_id ?? site.category?.id ?? null
|
||||
const catName = site.site_category_name ?? site.category_name ?? site.category?.name ?? ''
|
||||
const catOrd = site.site_category_order ?? site.category_order ?? site.category?.order ?? 0
|
||||
|
||||
return {
|
||||
site_id: siteId,
|
||||
site_name: site.site_name,
|
||||
site_status: site.site_status || 'unknown',
|
||||
category_id: String(site.site_category_id || ''),
|
||||
category_name: site.site_category_name || '',
|
||||
category_order: site.site_category_order ?? 0,
|
||||
category_id: catId != null ? String(catId) : '',
|
||||
category_name: catName,
|
||||
category_order: catOrd,
|
||||
site_order: site.site_order ?? 0,
|
||||
|
||||
flow_type: flowType,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue