fix(files): list a hotel booking's files and files pinned to a stop on the place card

A hotel booking reaches its place through the stay, not its own place_id, so
the card listed the booking but not its confirmation. Links to a stop, which
MCP's link_trip_file and plugins can make, were never returned by the file
list at all; it now carries linked_assignment_ids. Without files the row no
longer opens to nothing.
This commit is contained in:
Maurice
2026-10-14 10:45:22 +02:00
committed by Maurice
parent 7c6b7622fc
commit 10a987fec1
11 changed files with 63 additions and 10 deletions
+15 -6
View File
@@ -1,10 +1,12 @@
import type { Reservation, TripFile } from '../types'
/**
* The files a place shows: its own, plus the ones attached to a booking that
* hangs on this place or on one of its stops in the plan. A confirmation lives
* on the booking, and the place card was the one screen that could not reach it
* (#2217).
* The files a place shows: its own, the ones pinned to one of its stops in the
* plan, plus the ones attached to a booking that hangs on this place or on one
* of its stops. A confirmation lives on the booking, and the place card was the
* one screen that could not reach it (#2217). A hotel booking reaches its place
* through the stay rather than its own place_id, the same way the card lists
* the booking itself (getPlaceBookings, #2363).
*/
export function filesForPlace(
files: TripFile[] | undefined,
@@ -14,11 +16,18 @@ export function filesForPlace(
): TripFile[] {
if (placeId == null) return []
const own = (files || []).filter(f =>
!f.deleted_at && (String(f.place_id) === String(placeId) || (f.linked_place_ids || []).includes(placeId)),
!f.deleted_at && (
String(f.place_id) === String(placeId)
|| (f.linked_place_ids || []).includes(placeId)
|| (f.linked_assignment_ids || []).some(id => id != null && assignmentIds.includes(id))
),
)
const bookingIds = new Set(
(reservations || [])
.filter(r => String(r.place_id) === String(placeId) || (r.assignment_id != null && assignmentIds.includes(r.assignment_id)))
.filter(r =>
String(r.place_id) === String(placeId)
|| (r.accommodation_place_id != null && String(r.accommodation_place_id) === String(placeId))
|| (r.assignment_id != null && assignmentIds.includes(r.assignment_id)))
.map(r => r.id),
)
if (bookingIds.size === 0) return own