fix(client): keep the seat change clear of the sheet's held ref and of non-null assertions

Client lint was red: passing the ref-held reservation to bookingSeats added a react-hooks/refs warning in MTransportSheet, so the sheet now reads the seats from the legs it already has (seatsOfLegs). The new PDF test used a non-null assertion.
This commit is contained in:
Maurice
2026-11-21 15:45:04 +01:00
parent 7006891ce0
commit 49b9ffc77d
3 changed files with 9 additions and 5 deletions
+6 -2
View File
@@ -184,11 +184,15 @@ function legSeat(leg: { seat?: unknown } | null | undefined, index: number, meta
export function bookingSeats(r: Reservation): { route: string | null; seat: string }[] {
const legs: (FlightLeg | TrainLeg)[] =
r.type === 'flight' ? getFlightLegs(r) : usesStationRoute(r.type) ? getTrainLegs(r) : []
return seatsOfLegs(legs, parseReservationMetadata(r).seat)
}
/** bookingSeats for legs already read (getFlightLegs or getTrainLegs) and the booking's flat seat. */
export function seatsOfLegs(legs: readonly (FlightLeg | TrainLeg)[], flatSeat: unknown): { route: string | null; seat: string }[] {
if (legs.length > 1) {
return legs.flatMap((l) => (l.seat ? [{ route: [l.from, l.to].filter(Boolean).join(' → ') || null, seat: l.seat }] : []))
}
const seat = parseReservationMetadata(r).seat
return typeof seat === 'string' && seat ? [{ route: null, seat }] : []
return typeof flatSeat === 'string' && flatSeat ? [{ route: null, seat: flatSeat }] : []
}
/** The label of one of bookingSeats' seats: "Seat", or "Seat FRA → IST" for a leg. */