Files
TREK/client/src/store/saveToCollectionStore.ts
T
Maurice 31859651d7 feat(help): rewrite the help center for v5 with a Tours section, new pictures in every language, and fix the tour planner bugs it surfaced
Every help screen checked against the v5 redesign. Tours is documented for
the first time, as a screen of its own with twelve screens under it, and
notifications get help of their own. All pictures are taken again on a
realistic demo trip, with short loops where a still cannot show the motion.
The English is plain and every language is written naturally rather than
word for word.

The switcher shows two levels at most, a screen's overview lists its
sub-screens as cards above its guides, each wiki page is linked once, and
the help sidebar is wider.

Fixes found along the way: Save to Collection keeps a tour's route, a track
dropped on the places column opens the Tours import, tour Share on desktop,
the unsaved tour draft lives on the account, a route click no longer adds
an end point, Trip places leaves the trip's tours out, Escape closes a
stage's day menu, confirms before destructive deletes, DWD warnings sharing
one id kept apart, a booking's date moves with it, and smaller fixes across
notifications, bookings, the day plan, stays, Atlas, Collections, Vacay and
the admin screens.
2026-10-22 22:29:35 +02:00

66 lines
2.1 KiB
TypeScript

import { create } from 'zustand'
/**
* The raw place payload handed to the "Save to Collection" picker. Carries the
* provenance ids (source_trip_id / source_place_id) when the place originates
* from a trip, plus the maps identity used both to save and to dedup. Every
* field is optional except the name so the same target shape works for a trip
* pool place, a day-assignment place or a manually entered one.
*/
export interface SaveToCollectionTarget {
name: string
source_trip_id?: number | null
source_place_id?: number | null
description?: string | null
lat?: number | null
lng?: number | null
address?: string | null
category_id?: number | null
price?: number | null
currency?: string | null
notes?: string | null
image_url?: string | null
google_place_id?: string | null
google_ftid?: string | null
osm_id?: string | null
website?: string | null
phone?: string | null
}
/**
* A saved tour of a trip to keep in a collection. It goes through the tour's
* own keep dialog, which copies the tour with its route, never through the
* place picker, which would keep a bare point.
*/
export interface SaveTourToCollectionTarget {
tripId: number | string
placeId: number
name: string
}
interface SaveToCollectionState {
/** The place currently shown in the picker, or null when it is closed. */
target: SaveToCollectionTarget | null
/** The tour currently shown in the keep dialog, or null when it is closed. */
tour: SaveTourToCollectionTarget | null
/** Bumped after every add/remove so other surfaces (the inspector bookmark
* indicator) can re-check membership without prop threading. */
version: number
open: (target: SaveToCollectionTarget) => void
close: () => void
openTour: (tour: SaveTourToCollectionTarget) => void
closeTour: () => void
bumpVersion: () => void
}
export const useSaveToCollectionStore = create<SaveToCollectionState>((set, get) => ({
target: null,
tour: null,
version: 0,
open: (target) => set({ target }),
close: () => set({ target: null }),
openTour: (tour) => set({ tour }),
closeTour: () => set({ tour: null }),
bumpVersion: () => set({ version: get().version + 1 }),
}))