diff --git a/backend/src/routes/rooms.js b/backend/src/routes/rooms.js index 618da9c..b62c29f 100644 --- a/backend/src/routes/rooms.js +++ b/backend/src/routes/rooms.js @@ -44,7 +44,11 @@ function filterBookingData(booking, canSeeGuest, canSeeRate, canSeeAllNotes, vis if (canSeeGuest) { const guests = booking.guests || [] - out.guest_name = guests[0]?.guest_name || booking.guest_name || booking.account_for_name || null + const g0 = guests[0] + const fromGuests = g0 + ? (g0.guest_name || [g0.firstname, g0.lastname].filter(Boolean).join(' ') || null) + : null + out.guest_name = fromGuests || booking.guest_name || booking.account_for_name || null } if (canSeeRate) { @@ -119,13 +123,7 @@ export async function roomRoutes(app) { site: { id: siteId, name: site.site_name, fields: Object.keys(site) }, booking_id_fields: idFields, total_bookings_fetched: bookings.length, - matching_bookings: siteBookings.map(b => { - const out = {} - for (const f of ['booking_id', 'booking_status', 'booking_arrival', 'booking_departure', ...idFields]) { - out[f] = b[f] - } - return out - }), + matching_bookings: siteBookings, classified: { flow_type: classified.flow_type, spans_previous: classified.spans_previous,