mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-05 10:24:05 +00:00
fix(planner): show each leg's own seat on a flight with a stop
A flight with a stop saves a seat per leg, but every view read the booking's flat seat, which mirrors the first leg's. A seat booked only on the second leg showed nowhere, and one on the first leg showed on both. #2701 had fixed this for trains only. - getFlightLegs reads each leg's seat. The first leg falls back to the flat seat, as the booking form does, so older bookings keep theirs. - bookingSeats lists the seat of every leg that has one with its route. The detail views (the phone's transport sheet, the booking detail) show each leg's seat under its route ("Seat IST → JFK"), and a leg opened from its row shows its own. The cards and field grids (bookings list, the phone's Bookings and Transports tabs, the day plan's transport detail) hold every seat in one Seat cell, so a card cutting its grid short no longer drops the second leg's. - The day plan's flight leg rows carry their seat, and the PDF prints a flight's seat, direct or per leg. - The watch and the Wallet pass name every leg's seat of the booking. - A legs-only MCP update sets the flat seat, airline and flight number (train number and platform) again from the new first leg, so a seat taken off the first leg does not live on in the flat seat. A flat value the stored first leg never had stays. Closes #3158
This commit is contained in:
@@ -7,7 +7,7 @@ import { useTranslation } from '../../../../i18n'
|
||||
import { useSettingsStore } from '../../../../store/settingsStore'
|
||||
import { RES_ICONS } from '../../../../components/Planner/DayPlanSidebar.constants'
|
||||
import { splitReservationDateTime } from '../../../../utils/formatters'
|
||||
import { getFlightLegs, getTrainLegs, usesStationRoute, type FlightLeg, type TrainLeg } from '../../../../utils/flightLegs'
|
||||
import { bookingSeats, getFlightLegs, getTrainLegs, seatLabel, usesStationRoute, type FlightLeg, type TrainLeg } from '../../../../utils/flightLegs'
|
||||
import { runsOnDay } from '../../../../utils/reservationRoutes'
|
||||
import { filesFor } from '../../../../utils/reservationFiles'
|
||||
import { bookingDayLabel, segmentCodeLabel } from '../../../../components/Planner/transportDetailModel'
|
||||
@@ -169,8 +169,12 @@ export default function MTransportSheet({ planner, shell }: MTripSheetsProps) {
|
||||
if (leg && (leg.from || leg.to)) subParts.push(flowText([leg.from, leg.to].filter((n): n is string => !!n)))
|
||||
else if (from?.name && to?.name) subParts.push(flowText([from.name, to.name]))
|
||||
|
||||
// A flight's legs carry no seat or platform of their own, so those stay the booking's.
|
||||
const seat = leg && !isFlight ? legDetail.seat : meta.seat
|
||||
// Opened from a leg, that leg's own seat; the whole booking lists the seat of
|
||||
// every leg that has one, each under its route, rather than only the first's.
|
||||
const seats: { route: string | null; seat: string }[] = leg ? (legDetail.seat ? [{ route: null, seat: legDetail.seat }] : []) : bookingSeats(res)
|
||||
const ownSeat = seats.find(s => s.route == null)?.seat
|
||||
const legSeats = seats.filter(s => s.route != null)
|
||||
// A flight's legs carry no platform of their own, so that stays the booking's.
|
||||
const platform = leg && !isFlight ? legDetail.platform : meta.platform
|
||||
const transitLegs: TransitLeg[] = Array.isArray(meta.transit?.legs) ? meta.transit.legs : []
|
||||
|
||||
@@ -212,6 +216,9 @@ export default function MTransportSheet({ planner, shell }: MTripSheetsProps) {
|
||||
)
|
||||
: []
|
||||
|
||||
// The times, platform and booking seat; each leg's seat gets a row of its own below it.
|
||||
const statRow = hotelStats.length === 0 && ((showTimes && (depTime || arrTime)) || !!ownSeat || !!platform)
|
||||
|
||||
// The editor that fits the booking: transports have their own, everything
|
||||
// else (a stay, a table, a ticket) the booking editor, as in the Bookings tab.
|
||||
const editTransport = () => {
|
||||
@@ -275,7 +282,7 @@ export default function MTransportSheet({ planner, shell }: MTripSheetsProps) {
|
||||
))}
|
||||
|
||||
{/* ── Times / seat stats (the live card already shows the times) ── */}
|
||||
{hotelStats.length === 0 && ((showTimes && (depTime || arrTime)) || seat || platform) && (
|
||||
{statRow && (
|
||||
<div className="mt-[14px] flex gap-[6px]">
|
||||
{showTimes && depTime && (
|
||||
<StatBox caption={depDate} value={displayTime(depTime, locale, timeFormat)} label={depLabel} />
|
||||
@@ -284,7 +291,12 @@ export default function MTransportSheet({ planner, shell }: MTripSheetsProps) {
|
||||
<StatBox caption={arrDate} value={displayTime(arrTime, locale, timeFormat)} label={arrLabel} />
|
||||
)}
|
||||
{platform && <StatBox value={platform} label={t('reservations.meta.platform')} />}
|
||||
{seat && <StatBox value={seat} label={t('reservations.meta.seat')} />}
|
||||
{ownSeat && <StatBox value={ownSeat} label={t('reservations.meta.seat')} />}
|
||||
</div>
|
||||
)}
|
||||
{hotelStats.length === 0 && legSeats.length > 0 && (
|
||||
<div className={`${statRow ? 'mt-[6px]' : 'mt-[14px]'} flex gap-[6px]`}>
|
||||
{legSeats.map((s, i) => <StatBox key={i} value={s.seat} label={seatLabel(t('reservations.meta.seat'), s.route)} />)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import { cardWhen, parseTransportMeta, timeRange } from './transportsModel'
|
||||
import { BOOKING_TYPE_COLOR, hotelStayTimes } from '../../../../components/Planner/bookings/bookingsModel'
|
||||
import { useReservationListFilter } from '../../../../components/Planner/bookings/useReservationListFilter'
|
||||
import { useReservationCard } from '../../../../components/Planner/bookings/useReservationCard'
|
||||
import { orderedEndpoints } from '../../../../utils/flightLegs'
|
||||
import { orderedEndpoints, seatCells } from '../../../../utils/flightLegs'
|
||||
import { filesFor } from '../../../../utils/reservationFiles'
|
||||
|
||||
/**
|
||||
@@ -115,7 +115,7 @@ function BookingCard({ res, planner, canEdit, compact, onView }: {
|
||||
if (!hasEndpoints && meta.departure_airport) metaCells.push({ label: t('reservations.meta.from'), value: meta.departure_airport })
|
||||
if (!hasEndpoints && meta.arrival_airport) metaCells.push({ label: t('reservations.meta.to'), value: meta.arrival_airport })
|
||||
if (meta.platform) metaCells.push({ label: t('reservations.meta.platform'), value: meta.platform })
|
||||
if (meta.seat) metaCells.push({ label: t('reservations.meta.seat'), value: meta.seat + (meta.class ? ` · ${meta.class}` : '') })
|
||||
metaCells.push(...seatCells(res, t('reservations.meta.seat'), meta.class ? ` · ${meta.class}` : ''))
|
||||
if (meta.price != null && meta.price !== '') {
|
||||
metaCells.push({ label: t('reservations.price'), value: formatPriceText(meta.price, meta.priceCurrency, planner.trip?.currency, locale) })
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import { cardWhen, parseTransportMeta } from './transportsModel'
|
||||
import { TRANSPORT_TYPE_COLOR } from '../../../../components/Planner/bookings/bookingsModel'
|
||||
import { useReservationListFilter } from '../../../../components/Planner/bookings/useReservationListFilter'
|
||||
import { useReservationCard } from '../../../../components/Planner/bookings/useReservationCard'
|
||||
import { orderedEndpoints } from '../../../../utils/flightLegs'
|
||||
import { orderedEndpoints, seatCells } from '../../../../utils/flightLegs'
|
||||
import { filesFor } from '../../../../utils/reservationFiles'
|
||||
import MFlightLiveStrip from '../MFlightLiveStrip'
|
||||
|
||||
@@ -113,7 +113,7 @@ function TransportCard({ res, planner, shell, canEdit, compact }: {
|
||||
if (!hasEndpoints && meta.arrival_airport) metaCells.push({ label: t('reservations.meta.to'), value: meta.arrival_airport })
|
||||
if (meta.train_number) metaCells.push({ label: t('reservations.meta.trainNumber'), value: meta.train_number })
|
||||
if (meta.platform) metaCells.push({ label: t('reservations.meta.platform'), value: meta.platform })
|
||||
if (meta.seat) metaCells.push({ label: t('reservations.meta.seat'), value: meta.seat + (meta.class ? ` · ${meta.class}` : '') })
|
||||
metaCells.push(...seatCells(res, t('reservations.meta.seat'), meta.class ? ` · ${meta.class}` : ''))
|
||||
if (meta.price != null && meta.price !== '') {
|
||||
metaCells.push({ label: t('reservations.price'), value: formatPriceText(meta.price, meta.priceCurrency, planner.trip?.currency, locale) })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user