mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-07 22:25:42 +00:00
Merge pull request #685 from Tria-plc/alpha
Fix route datetime on lookup page
This commit is contained in:
@@ -1745,30 +1745,32 @@ export class BookingsService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resolves the passenger's actual boarding/alighting stations for one leg from
|
// Resolves the passenger's actual boarding/alighting stations AND times for one leg
|
||||||
// originStationId/destinationStationId (set when the booking covers only part of a
|
// from originStationId/destinationStationId (set when the booking covers only part of
|
||||||
// longer multi-stop schedule, e.g. train runs A→D but the passenger booked B→D) via
|
// a longer multi-stop schedule, e.g. train runs A→D but the passenger booked B→D) via
|
||||||
// the schedule's stopTimes, falling back to the schedule's own full-route endpoints
|
// the schedule's stopTimes, falling back to the schedule's own full-route endpoints/
|
||||||
// when there's no segment override (older records, or a booking that covers the
|
// times when there's no segment override (older records, or a booking that covers the
|
||||||
// whole run). Mirrors notifications.service.ts's resolveSegmentStations — that's
|
// whole run). Station resolution mirrors notifications.service.ts's
|
||||||
// already applied to SMS/email; this brings the booking API (voucher, detail page,
|
// resolveSegmentStations (already applied to SMS/email); the departureAt/arrivalAt
|
||||||
// confirmation) to the same behavior instead of always showing the train's full route.
|
// resolution mirrors search.service.ts's leg construction (originStop.plannedDepartureAt
|
||||||
|
// / destStop.plannedArrivalAt) — this brings the booking API (voucher, detail page,
|
||||||
|
// confirmation) to the same behavior search results already have, instead of always
|
||||||
|
// showing the train's full-route span.
|
||||||
private resolveSegmentStations(
|
private resolveSegmentStations(
|
||||||
schedule: any,
|
schedule: any,
|
||||||
originStationId: string | null | undefined,
|
originStationId: string | null | undefined,
|
||||||
destinationStationId: string | null | undefined,
|
destinationStationId: string | null | undefined,
|
||||||
): { origin: any; destination: any } {
|
): { origin: any; destination: any; departureAt: any; arrivalAt: any } {
|
||||||
const stopTimes: any[] = schedule?.stopTimes ?? [];
|
const stopTimes: any[] = schedule?.stopTimes ?? [];
|
||||||
const findStation = (stationId: string | null | undefined, fallback: any) => {
|
const findStop = (stationId: string | null | undefined) =>
|
||||||
if (stationId && stopTimes.length > 0) {
|
stationId && stopTimes.length > 0 ? stopTimes.find((st: any) => st.stationId === stationId) : undefined;
|
||||||
const stop = stopTimes.find((st: any) => st.stationId === stationId);
|
const originStop = findStop(originStationId);
|
||||||
if (stop?.station) return stop.station;
|
const destStop = findStop(destinationStationId);
|
||||||
}
|
|
||||||
return fallback ?? null;
|
|
||||||
};
|
|
||||||
return {
|
return {
|
||||||
origin: findStation(originStationId, schedule?.originStation),
|
origin: originStop?.station ?? schedule?.originStation ?? null,
|
||||||
destination: findStation(destinationStationId, schedule?.destinationStation),
|
destination: destStop?.station ?? schedule?.destinationStation ?? null,
|
||||||
|
departureAt: originStop?.plannedDepartureAt ?? schedule?.departureAt ?? null,
|
||||||
|
arrivalAt: destStop?.plannedArrivalAt ?? schedule?.arrivalAt ?? null,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1878,7 +1880,7 @@ export class BookingsService {
|
|||||||
trainName: (booking as any).schedule.train.name,
|
trainName: (booking as any).schedule.train.name,
|
||||||
origin: { id: outboundSegment.origin.id, name: outboundSegment.origin.name, code: outboundSegment.origin.code, city: outboundSegment.origin.city },
|
origin: { id: outboundSegment.origin.id, name: outboundSegment.origin.name, code: outboundSegment.origin.code, city: outboundSegment.origin.city },
|
||||||
destination: { id: outboundSegment.destination.id, name: outboundSegment.destination.name, code: outboundSegment.destination.code, city: outboundSegment.destination.city },
|
destination: { id: outboundSegment.destination.id, name: outboundSegment.destination.name, code: outboundSegment.destination.code, city: outboundSegment.destination.city },
|
||||||
departureAt: (booking as any).schedule.departureAt, arrivalAt: (booking as any).schedule.arrivalAt,
|
departureAt: outboundSegment.departureAt, arrivalAt: outboundSegment.arrivalAt,
|
||||||
},
|
},
|
||||||
returnSchedule: (booking as any).returnSchedule
|
returnSchedule: (booking as any).returnSchedule
|
||||||
? {
|
? {
|
||||||
@@ -1887,7 +1889,7 @@ export class BookingsService {
|
|||||||
trainName: (booking as any).returnSchedule.train.name,
|
trainName: (booking as any).returnSchedule.train.name,
|
||||||
origin: { id: returnSegment!.origin.id, name: returnSegment!.origin.name, code: returnSegment!.origin.code, city: returnSegment!.origin.city },
|
origin: { id: returnSegment!.origin.id, name: returnSegment!.origin.name, code: returnSegment!.origin.code, city: returnSegment!.origin.city },
|
||||||
destination: { id: returnSegment!.destination.id, name: returnSegment!.destination.name, code: returnSegment!.destination.code, city: returnSegment!.destination.city },
|
destination: { id: returnSegment!.destination.id, name: returnSegment!.destination.name, code: returnSegment!.destination.code, city: returnSegment!.destination.city },
|
||||||
departureAt: (booking as any).returnSchedule.departureAt, arrivalAt: (booking as any).returnSchedule.arrivalAt,
|
departureAt: returnSegment!.departureAt, arrivalAt: returnSegment!.arrivalAt,
|
||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
passengers: (booking as any).seats?.map((bs: any) => ({
|
passengers: (booking as any).seats?.map((bs: any) => ({
|
||||||
|
|||||||
Reference in New Issue
Block a user