fix(planner): undoing a place delete brings the place back whole, or is not offered

The undo wrote a new place from nine of its fields and put it on its days as a
bare stop, so notes, website, phone, hours, picture, the visit times, day notes
and travellers were gone while the toast said it was undone. It now writes every
field the place had and plans each visit again with its times, note, end of day,
route flag, travellers and leg modes, and casts the own rating again.

The server takes a booked night, its booking and expense, linked expenses, file
links, other members' ratings and an uploaded picture down with the place, and
writing the place again brings none of that back. Such a delete is no longer
offered for undo. Undo steps that name a deleted place are dropped at the delete
instead of failing later, and adding a place, moving categories and the phone
reorder and optimize now carry their place ids for that.

Taking a stop off a day and clearing a day undo with the visit details too. The
stays are read again when a deleted place had one, here and for collaborators.

Refs #2604
This commit is contained in:
Maurice
2026-10-12 13:44:44 +02:00
parent e70fc334bd
commit 676f6233ed
15 changed files with 593 additions and 72 deletions
+10 -6
View File
@@ -529,6 +529,9 @@ export const STATE_APPLIERS: Partial<Record<TrekWsTripEventName, StateApplier>>
},
}
/** The deletes that can take a booked night along with them. */
const STAY_TAKING_EVENTS = new Set<string>(['day:deleted', 'place:deleted', 'accommodation:deleted'])
/**
* Applies a remote WebSocket event to the local Zustand store, keeping state in sync across collaborators.
* Each event type maps to an immutable state update (create/update/delete) for the relevant entity.
@@ -571,12 +574,13 @@ export function handleRemoteEvent(set: SetState, get: GetState, event: WebSocket
if (tripId) get().loadReservations(tripId)
}
// A deleted day cancels a stay that checked in or out on it, and the stays
// live in page-local planner state rather than this store. This rides the
// planner's existing accommodations:refresh event on purpose, the legacy
// window bus the place image and trip date handlers here use as well.
// Retiring it means moving the stays into a store slice, a change of its own.
if (type === 'day:deleted') window.dispatchEvent(new CustomEvent('accommodations:refresh'))
// A deleted day cancels a stay that checked in or out on it, a deleted place
// the stay booked at it, and the stays live in page-local planner state rather
// than this store. This rides the planner's existing accommodations:refresh
// event on purpose, the legacy window bus the place image and trip date
// handlers here use as well. Retiring it means moving the stays into a store
// slice, a change of its own.
if (STAY_TAKING_EVENTS.has(type)) window.dispatchEvent(new CustomEvent('accommodations:refresh'))
// A reorder/insert re-pins dates and re-stamps booking times server-side, so
// pull the authoritative days + reservations for collaborators.