Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

fix(planner): a flight without airports keeps its day and times on save

Maurice4983b3407cf1
diff --git a/client/src/components/Planner/transportEndpoints.test.ts b/client/src/components/Planner/transportEndpoints.test.ts
index c623f447a..e741d5c07 100644
--- a/client/src/components/Planner/transportEndpoints.test.ts
+++ b/client/src/components/Planner/transportEndpoints.test.ts
@@ -1,4 +1,4 @@
-// FE-PLANNER-TRANSPORTEP-001 to -021: the transport booking form both the desktop
+// FE-PLANNER-TRANSPORTEP-001 to -022: the transport booking form both the desktop
// TransportModal and the phone's transport sheet save through.
import { describe, expect, it } from 'vitest';
@@ -499,6 +499,28 @@ describe('buildTransportPayload', () => {
expect(payload.reservation_time).toBeNull();
});
+ it('FE-PLANNER-TRANSPORTEP-022: a flight without airports keeps its day, times and flight details on save (#3070)', () => {
+ const payload = buildTransportPayload(
+ draft({
+ form: { ...EMPTY_TRANSPORT_FIELDS, title: 'Fly', type: 'flight', notes: 'only the notes changed' },
+ waypoints: [
+ { ...emptyWaypoint(1), depTime: '09:40', airline: 'Lufthansa', flight_number: 'LH 400', seat: '12A' },
+ { ...emptyWaypoint(2), arrTime: '11:30' },
+ ],
+ }),
+ days,
+ DESKTOP_SAVE
+ );
+ expect(payload).toMatchObject({
+ day_id: 1,
+ end_day_id: 2,
+ reservation_time: '2026-05-01T09:40',
+ reservation_end_time: '2026-05-02T11:30',
+ endpoints: [],
+ });
+ expect(payload.metadata).toEqual({ airline: 'Lufthansa', flight_number: 'LH 400', seat: '12A' });
+ });
+
it('FE-PLANNER-TRANSPORTEP-017: the desktop anchors a train on its raw rows, the phone on the picked stations', () => {
const station = (name: string) => ({ name, lat: 1, lng: 1 });
const trainWaypoints = [
diff --git a/client/src/components/Planner/transportEndpoints.ts b/client/src/components/Planner/transportEndpoints.ts
index 50d22700b..702a12546 100644
--- a/client/src/components/Planner/transportEndpoints.ts
+++ b/client/src/components/Planner/transportEndpoints.ts
@@ -548,8 +548,12 @@ export function buildTransportPayload(
const dayDate = (id: string | number): string | null => days.find((d) => d.id === Number(id))?.date ?? null;
// Flight route as an ordered list of airports (origin .. stops .. destination).
const flightWps = form.type === 'flight' ? waypoints.filter((w) => w.airport) : [];
- const firstWp = flightWps[0];
- const lastWp = flightWps[flightWps.length - 1];
+ // A flight without a single airport (one created over MCP with a day and times
+ // but no endpoints) takes its day, times, airline and seat from the raw rows, as
+ // a train without stations does; otherwise a save wiped them (#3070).
+ const flightAnchors = flightWps.length > 0 || form.type !== 'flight' ? flightWps : waypoints;
+ const firstWp = flightAnchors[0];
+ const lastWp = flightAnchors[flightAnchors.length - 1];
// Only geocoded stations become map endpoints and legs.
const trainWps = stationRoute ? trainWaypoints : [];
const trainStations = trainWps.filter((w) => w.location);