refactor(planner): share the trip sheet wiring between desktop and phone

The phone trip sheet host wrote out by hand three pieces of planner
wiring the desktop planner already had.

useBookingExpenseEditor now holds the expense editor both planners open
over the trip: the booking request state, the receipt fallback, the base
currency, the current user and the save that reloads the budget.
TripPlannerPage and MTripSheets both read it.

applyTripCoverUpdate patches a new trip cover into the store for the
trip form on both sides.

The transport editor and the transit route change moved into
openTransportEditorWith and changeTransitRouteWith, which take the
planner's setters. usePlannerDialogs builds openTransportEditor and
changeTransitRoute on them, and the phone sheet calls the same helpers
on the planner it receives. There are no differences between the two
views to keep as options.
This commit is contained in:
Maurice
2026-10-09 12:08:25 +02:00
parent 973773e003
commit b598b97865
11 changed files with 436 additions and 97 deletions
+8 -1
View File
@@ -1,5 +1,7 @@
import { vi } from 'vitest';
import type { TripPlanner, MTripShellApi } from '../../src/mobile/screens/trip/MTripShell';
import type { Reservation } from '../../src/types';
import { changeTransitRouteWith, openTransportEditorWith } from '../../src/pages/tripPlanner/transportEditorOpeners';
import { buildTrip } from './factories';
/**
@@ -299,6 +301,10 @@ export function buildPlanner(overrides: Partial<TripPlanner> = {}): TripPlanner
handleSaveReservation: vi.fn(),
handleSaveTransport: vi.fn(),
handleDeleteReservation: vi.fn(),
// The planner's two ways into the transport editor, run on the setter spies above
// the way usePlannerDialogs runs them on its state.
openTransportEditor: vi.fn((r: Reservation) => openTransportEditorWith(planner, r)),
changeTransitRoute: vi.fn((r: Reservation) => changeTransitRouteWith(planner, r)),
selectedPlace: null,
dayOrderMap: new Map<number, number>(),
@@ -309,7 +315,8 @@ export function buildPlanner(overrides: Partial<TripPlanner> = {}): TripPlanner
splashDone: true,
};
return { ...base, ...overrides } as unknown as TripPlanner;
const planner = { ...base, ...overrides } as unknown as TripPlanner;
return planner;
}
export function buildShell(overrides: Partial<MTripShellApi> = {}): MTripShellApi {