Files
TREK/client/src/constants/tripTabs.ts
T
Maurice aaff8f9db4 feat(roadtrip): bring the road trip addon to the phone
A road trip tab on the mobile trip screen: the stage as a chain, the same
map underneath it, the sheets a passenger needs, and a search along the
route.

The addon was desktop only because road trip MODE is a data switch rather
than a view switch. It rewrites `assignments` and `places` for the whole
planner hook, and every mobile sheet is permanently mounted and reads those
same two lists, so turning it on there brought back documented regressions.
The mode flag is therefore untouched. A second flag, `roadtripFeedActive`,
feeds only the routing round and does it off the STORED assignments, so the
phone gets the drive without what the mode drags along with it.

The map is one instance shared by the plan tab and the road trip tab,
hoisted into a single JSX expression so React keeps it in the same position
and the WebGL context is never torn down on a tab switch.

The corridor search is scoped to what a phone can afford: a window of the
day rather than all of it, a smaller tile ceiling, a capped retry pass and a
deadline. The standard search is three requests where the desk makes
fifteen. The categories are deliberately not narrowed, because they all ride
one query per box, so a second one costs nothing.

Two gaps found while wiring it up are closed here as well. The fuel search
drew its offers nowhere on the phone, so the button did nothing visible;
they are in the dry band now, with the detour, the spare range and an accept
button. And the map credit opened as a two line ribbon across a screen the
map fills: both GL engines now start it collapsed, and Leaflet, which has no
collapsed mode of its own, is given one.
2026-09-16 21:55:18 +02:00

53 lines
1.9 KiB
TypeScript

/**
* The trip planner's core tab ids, in the order the tab bar shows them.
*
* These are the German legacy names the planner has always used internally
* ('buchungen', 'finanzplan', 'dateien', 'listen') — not the English labels.
* They are what sessionStorage, the ?tab= deep link and the startup-destination
* setting persist, so renaming one would silently strand saved preferences.
*
* Addon-owned tabs are listed here even while their addon is off: useTripPlanner
* builds TRIP_TABS from what is actually enabled, and anything pointing at a tab
* that isn't there falls back to the plan view.
*/
export const TRIP_TAB_IDS = [
'plan',
'roadtrip',
'transports',
'buchungen',
'listen',
'finanzplan',
'dateien',
'collab',
] as const
export type TripTabId = (typeof TRIP_TAB_IDS)[number]
/**
* Translation key per tab, so the startup-destination picker in Settings names
* the tabs exactly as the planner's own tab bar does. useTripPlanner builds its
* TRIP_TABS from these too — one source, or the two would drift apart the first
* time a tab is renamed.
*/
export const TRIP_TAB_LABEL_KEYS: Record<TripTabId, string> = {
plan: 'trip.tabs.plan',
roadtrip: 'roadtrip.title',
transports: 'trip.tabs.transports',
buchungen: 'trip.tabs.reservations',
listen: 'trip.tabs.lists',
finanzplan: 'trip.tabs.budget',
dateien: 'trip.tabs.files',
collab: 'admin.addons.catalog.collab.name',
}
export const isTripTabId = (value: unknown): value is TripTabId =>
typeof value === 'string' && (TRIP_TAB_IDS as readonly string[]).includes(value)
/**
* What `/trips/:id?tab=…` accepts. Trip-page plugins mount as tabs too and are
* addressable by their `plugin:<id>` form, so a shortcut can point at one — the
* planner's own guard still drops it if that plugin isn't installed.
*/
export const isDeepLinkableTripTab = (value: string): boolean =>
isTripTabId(value) || value.startsWith('plugin:')