Files
TREK/client/src/store/openTourStore.ts
T
Maurice cd60d4d859 feat(tours): assistant takes found places into saved tours and route files from the chat
P6: insert_tour_stop and remove_tour_stop take a place into a saved hike or
city walk as one stop and out again, each the other's undo, with change
cards in the chat. The planner's insertion rule (poiInsertion) moved to
shared so the planner and the server place a stop the same way. "+ Tour" on
a found place holds it as a stop of the saved tour open in the planner.

P7: GPX, KML and KMZ files attached in the chat are read into their tracks
and each is held as a change that takes it in as a hike through
import_tour_gpx, undoable per track; the GPX text stays on the held call.
2026-10-23 22:00:05 +02:00

33 lines
1008 B
TypeScript

import { create } from 'zustand';
/** The saved tour open in the planner's editor, as the chat may take a found place into it. */
interface OpenTour {
tripId: number;
placeId: number;
name: string;
}
interface OpenTourState {
/** Null while no saved hike or city walk is open, or while its editor holds changes not yet saved. */
open: OpenTour | null;
}
/**
* P6: which saved tour the planner has open, for "+ Tour" on a place the
* assistant found. The planner writes it (usePublishOpenTour), the chat's
* place cards read it; nothing else is kept here.
*/
export const useOpenTourStore = create<OpenTourState>(() => ({ open: null }));
export function setOpenTour(open: OpenTour | null): void {
const current = useOpenTourStore.getState().open;
const same =
current === open ||
(!!current &&
!!open &&
current.tripId === open.tripId &&
current.placeId === open.placeId &&
current.name === open.name);
if (!same) useOpenTourStore.setState({ open });
}