The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.
TypeScript budget-trackercollaborativedockeritinerarymcp-serveroffline-firstopen-sourceopenstreetmappacking-listpwareal-timeself-hostedselfhostedtraveltravel-apptravel-journaltravel-plannertripitwanderlog
feat: undo button for trip planner
Lucae30820480897
diff --git a/client/src/components/Planner/DayPlanSidebar.tsx b/client/src/components/Planner/DayPlanSidebar.tsxindex 4e1840caf..a5328b2cf 100644--- a/client/src/components/Planner/DayPlanSidebar.tsx+++ b/client/src/components/Planner/DayPlanSidebar.tsx@@ -4,7 +4,7 @@ declare global { interface Window { __dragData: DragDataPayload | null } }import React, { useState, useEffect, useRef, useMemo } from 'react'import ReactDOM from 'react-dom'-import { ChevronDown, ChevronRight, ChevronUp, Navigation, RotateCcw, ExternalLink, Clock, Pencil, GripVertical, Ticket, Plus, FileText, Check, Trash2, Info, MapPin, Star, Heart, Camera, Lightbulb, Flag, Bookmark, Train, Bus, Plane, Car, Ship, Coffee, ShoppingBag, AlertTriangle, FileDown, Lock, Hotel, Utensils, Users } from 'lucide-react'+import { ChevronDown, ChevronRight, ChevronUp, Navigation, RotateCcw, ExternalLink, Clock, Pencil, GripVertical, Ticket, Plus, FileText, Check, Trash2, Info, MapPin, Star, Heart, Camera, Lightbulb, Flag, Bookmark, Train, Bus, Plane, Car, Ship, Coffee, ShoppingBag, AlertTriangle, FileDown, Lock, Hotel, Utensils, Users, Undo2 } from 'lucide-react'const RES_ICONS = { flight: Plane, hotel: Hotel, restaurant: Utensils, train: Train, car: Car, cruise: Ship, event: Ticket, tour: Users, other: FileText }import { assignmentsApi, reservationsApi } from '../../api/client'@@ -80,6 +80,10 @@ interface DayPlanSidebarProps {onAddReservation: () => voidonNavigateToFiles?: () => voidonExpandedDaysChange?: (expandedDayIds: Set<number>) => void+ pushUndo?: (label: string, undoFn: () => Promise<void> | void) => void+ canUndo?: boolean+ lastActionLabel?: string | null+ onUndo?: () => void}const DayPlanSidebar = React.memo(function DayPlanSidebar({@@ -93,6 +97,10 @@ const DayPlanSidebar = React.memo(function DayPlanSidebar({onAddReservation,onNavigateToFiles,onExpandedDaysChange,+ pushUndo,+ canUndo = false,+ lastActionLabel = null,+ onUndo,}: DayPlanSidebarProps) {const toast = useToast()const { t, language, locale } = useTranslation()@@ -119,6 +127,9 @@ const DayPlanSidebar = React.memo(function DayPlanSidebar({const [draggingId, setDraggingId] = useState(null)const [lockedIds, setLockedIds] = useState(new Set())const [lockHoverId, setLockHoverId] = useState(null)+ const [undoHover, setUndoHover] = useState(false)+ const [pdfHover, setPdfHover] = useState(false)+ const [icsHover, setIcsHover] = useState(false)const [dropTargetKey, _setDropTargetKey] = useState(null)const dropTargetRef = useRef(null)const setDropTargetKey = (key) => { dropTargetRef.current = key; _setDropTargetKey(key) }@@ -395,6 +406,9 @@ const DayPlanSidebar = React.memo(function DayPlanSidebar({// Unified reorder: assigns positions to ALL item types based on new visual orderconst applyMergedOrder = async (dayId: number, newOrder: { type: string; data: any }[]) => {+ // Capture previous place order for undo+ const prevAssignmentIds = getDayAssignments(dayId).map(a => a.id)+// Places get sequential integer positions (0, 1, 2, ...)// Non-place items between place N-1 and place N get fractional positionsconst assignmentIds: number[] = []@@ -437,6 +451,13 @@ const DayPlanSidebar = React.memo(function DayPlanSidebar({}await reservationsApi.updatePositions(tripId, transportUpdates)}+ if (prevAssignmentIds.length) {+ const capturedDayId = dayId+ const capturedPrevIds = prevAssignmentIds+ pushUndo?.(t('undo.reorder'), async () => {+ await tripActions.reorderAssignments(tripId, capturedDayId, capturedPrevIds)+ })+ }} catch (err: unknown) { toast.error(err instanceof Error ? err.message : 'Unknown error') }}@@ -599,12 +620,14 @@ const DayPlanSidebar = React.memo(function DayPlanSidebar({}const toggleLock = (assignmentId) => {+ const prevLocked = new Set(lockedIds)setLockedIds(prev => {const next = new Set(prev)if (next.has(assignmentId)) next.delete(assignmentId)else next.add(assignmentId)return next})+ pushUndo?.(t('undo.lock'), () => { setLockedIds(prevLocked) })}const handleOptimize = async () => {@@ -612,6 +635,8 @@ const DayPlanSidebar = React.memo(function DayPlanSidebar({const da = getDayAssignments(selectedDayId)if (da.length < 3) return+ const prevIds = da.map(a => a.id)+// Separate locked (stay at their index) and unlocked assignmentsconst locked = new Map() // index -> assignmentconst unlocked = []@@ -638,6 +663,10 @@ const DayPlanSidebar = React.memo(function DayPlanSidebar({await onReorder(selectedDayId, result.map(a => a.id))toast.success(t('dayplan.toast.routeOptimized'))+ const capturedDayId = selectedDayId+ pushUndo?.(t('undo.optimize'), async () => {+ await tripActions.reorderAssignments(tripId, capturedDayId, prevIds)+ })}const handleGoogleMaps = () => {@@ -656,7 +685,16 @@ const DayPlanSidebar = React.memo(function DayPlanSidebar({if (placeId) {onAssignToDay?.(parseInt(placeId), dayId)} else if (assignmentId && fromDayId !== dayId) {- tripActions.moveAssignment(tripId, Number(assignmentId), fromDayId, dayId).catch((err: unknown) => toast.error(err instanceof Error ? err.message : 'Unknown error'))+ const srcAssignment = (useTripStore.getState().assignments[String(fromDayId)] || []).find(a => a.id === Number(assignmentId))+ const capturedFromDayId = fromDayId+ const capturedOrderIndex = srcAssignment?.order_index ?? 0+ tripActions.moveAssignment(tripId, Number(assignmentId), fromDayId, dayId)+ .then(() => {+ pushUndo?.(t('undo.moveDay'), async () => {+ await tripActions.moveAssignment(tripId, Number(assignmentId), dayId, capturedFromDayId, capturedOrderIndex)+ })+ })+ .catch((err: unknown) => toast.error(err instanceof Error ? err.message : 'Unknown error'))} else if (noteId && fromDayId !== dayId) {tripActions.moveDayNote(tripId, fromDayId, dayId, Number(noteId)).catch((err: unknown) => toast.error(err instanceof Error ? err.message : 'Unknown error'))}@@ -710,57 +748,119 @@ const DayPlanSidebar = React.memo(function DayPlanSidebar({</div>)}</div>- <button- onClick={async () => {- const flatNotes = Object.entries(dayNotes).flatMap(([dayId, notes]) =>- notes.map(n => ({ ...n, day_id: Number(dayId) }))- )- try {- await downloadTripPDF({ trip, days, places, assignments, categories, dayNotes: flatNotes, reservations, t, locale })- } catch (e) {- console.error('PDF error:', e)- toast.error(t('dayplan.pdfError') + ': ' + (e?.message || String(e)))- }- }}- title={t('dayplan.pdfTooltip')}- style={{- flexShrink: 0, display: 'flex', alignItems: 'center', gap: 5,- padding: '5px 10px', borderRadius: 8, border: 'none',- background: 'var(--accent)', color: 'var(--accent-text)', fontSize: 11, fontWeight: 500,- cursor: 'pointer', fontFamily: 'inherit',- }}- >- <FileDown size={13} strokeWidth={2} />- {t('dayplan.pdf')}- </button>- <button- onClick={async () => {- try {- const res = await fetch(`/api/trips/${tripId}/export.ics`, {- credentials: 'include',- })- if (!res.ok) throw new Error()- const blob = await res.blob()- const url = URL.createObjectURL(blob)- const a = document.createElement('a')- a.href = url- a.download = `${trip?.title || 'trip'}.ics`- a.click()- URL.revokeObjectURL(url)- } catch { toast.error('ICS export failed') }- }}- title={t('dayplan.icsTooltip')}- style={{- flexShrink: 0, display: 'flex', alignItems: 'center', gap: 5,- padding: '5px 10px', borderRadius: 8,- border: '1px solid var(--border-primary)', background: 'none',- color: 'var(--text-muted)', fontSize: 11, fontWeight: 500,- cursor: 'pointer', fontFamily: 'inherit',- }}- >- <FileDown size={13} strokeWidth={2} />- ICS- </button>+ <div style={{ position: 'relative', flexShrink: 0 }}>+ <button+ onClick={async () => {+ const flatNotes = Object.entries(dayNotes).flatMap(([dayId, notes]) =>+ notes.map(n => ({ ...n, day_id: Number(dayId) }))+ )+ try {+ await downloadTripPDF({ trip, days, places, assignments, categories, dayNotes: flatNotes, reservations, t, locale })+ } catch (e) {+ console.error('PDF error:', e)+ toast.error(t('dayplan.pdfError') + ': ' + (e?.message || String(e)))+ }+ }}+ onMouseEnter={() => setPdfHover(true)}+ onMouseLeave={() => setPdfHover(false)}+ style={{+ display: 'flex', alignItems: 'center', gap: 5,+ padding: '5px 10px', borderRadius: 8, border: 'none',+ background: 'var(--accent)', color: 'var(--accent-text)', fontSize: 11, fontWeight: 500,+ cursor: 'pointer', fontFamily: 'inherit',+ }}+ >+ <FileDown size={13} strokeWidth={2} />+ {t('dayplan.pdf')}+ </button>+ {pdfHover && (+ <div style={{+ position: 'absolute', top: 'calc(100% + 6px)', right: 0,+ whiteSpace: 'nowrap', pointerEvents: 'none', zIndex: 200,+ background: 'var(--bg-card, white)', color: 'var(--text-primary, #111827)',+ fontSize: 11, fontWeight: 500, padding: '5px 10px',+ borderRadius: 8, boxShadow: '0 4px 12px rgba(0,0,0,0.15)',+ border: '1px solid var(--border-faint, #e5e7eb)',+ }}>+ {t('dayplan.pdfTooltip')}+ </div>+ )}+ </div>+ <div style={{ position: 'relative', flexShrink: 0 }}>+ <button+ onClick={async () => {+ try {+ const res = await fetch(`/api/trips/${tripId}/export.ics`, {+ credentials: 'include',+ })+ if (!res.ok) throw new Error()+ const blob = await res.blob()+ const url = URL.createObjectURL(blob)+ const a = document.createElement('a')+ a.href = url+ a.download = `${trip?.title || 'trip'}.ics`+ a.click()+ URL.revokeObjectURL(url)+ } catch { toast.error('ICS export failed') }+ }}+ onMouseEnter={() => setIcsHover(true)}+ onMouseLeave={() => setIcsHover(false)}+ style={{+ display: 'flex', alignItems: 'center', gap: 5,+ padding: '5px 10px', borderRadius: 8,+ border: '1px solid var(--border-primary)', background: 'none',+ color: 'var(--text-muted)', fontSize: 11, fontWeight: 500,+ cursor: 'pointer', fontFamily: 'inherit',+ }}+ >+ <FileDown size={13} strokeWidth={2} />+ ICS+ </button>+ {icsHover && (+ <div style={{+ position: 'absolute', top: 'calc(100% + 6px)', right: 0,+ whiteSpace: 'nowrap', pointerEvents: 'none', zIndex: 200,+ background: 'var(--bg-card, white)', color: 'var(--text-primary, #111827)',+ fontSize: 11, fontWeight: 500, padding: '5px 10px',+ borderRadius: 8, boxShadow: '0 4px 12px rgba(0,0,0,0.15)',+ border: '1px solid var(--border-faint, #e5e7eb)',+ }}>+ {t('dayplan.icsTooltip')}+ </div>+ )}+ </div>+ {onUndo && (+ <div style={{ position: 'relative', flexShrink: 0 }}>+ <button+ onClick={onUndo}+ disabled={!canUndo}+ onMouseEnter={() => setUndoHover(true)}+ onMouseLeave={() => setUndoHover(false)}+ style={{+ display: 'flex', alignItems: 'center', justifyContent: 'center',+ width: 30, height: 30, borderRadius: 8,+ border: '1px solid var(--border-primary)', background: 'none',+ color: canUndo ? 'var(--text-primary)' : 'var(--border-primary)',+ cursor: canUndo ? 'pointer' : 'default', fontFamily: 'inherit',+ transition: 'color 0.15s, border-color 0.15s',+ }}+ >+ <Undo2 size={14} strokeWidth={2} />+ </button>+ {undoHover && (+ <div style={{+ position: 'absolute', top: 'calc(100% + 6px)', right: 0,+ whiteSpace: 'nowrap', pointerEvents: 'none', zIndex: 200,+ background: 'var(--bg-card, white)', color: 'var(--text-primary, #111827)',+ fontSize: 11, fontWeight: 500, padding: '5px 10px',+ borderRadius: 8, boxShadow: '0 4px 12px rgba(0,0,0,0.15)',+ border: '1px solid var(--border-faint, #e5e7eb)',+ }}>+ {canUndo && lastActionLabel ? t('undo.tooltip', { action: lastActionLabel }) : t('undo.button')}+ </div>+ )}+ </div>+ )}</div></div>diff --git a/client/src/components/Planner/PlacesSidebar.tsx b/client/src/components/Planner/PlacesSidebar.tsxindex ef7db0956..91e50a5b6 100644--- a/client/src/components/Planner/PlacesSidebar.tsx+++ b/client/src/components/Planner/PlacesSidebar.tsx@@ -29,11 +29,12 @@ interface PlacesSidebarProps {days: Day[]isMobile: booleanonCategoryFilterChange?: (categoryId: string) => void+ pushUndo?: (label: string, undoFn: () => Promise<void> | void) => void}const PlacesSidebar = React.memo(function PlacesSidebar({tripId, places, categories, assignments, selectedDayId, selectedPlaceId,- onPlaceClick, onAddPlace, onAssignToDay, onEditPlace, onDeletePlace, days, isMobile, onCategoryFilterChange,+ onPlaceClick, onAddPlace, onAssignToDay, onEditPlace, onDeletePlace, days, isMobile, onCategoryFilterChange, pushUndo,}: PlacesSidebarProps) {const { t } = useTranslation()const toast = useToast()@@ -52,6 +53,15 @@ const PlacesSidebar = React.memo(function PlacesSidebar({const result = await placesApi.importGpx(tripId, file)await loadTrip(tripId)toast.success(t('places.gpxImported', { count: result.count }))+ if (result.places?.length > 0) {+ const importedIds: number[] = result.places.map((p: { id: number }) => p.id)+ pushUndo?.(t('undo.importGpx'), async () => {+ for (const id of importedIds) {+ try { await placesApi.delete(tripId, id) } catch {}+ }+ await loadTrip(tripId)+ })+ }} catch (err: any) {toast.error(err?.response?.data?.error || t('places.gpxError'))}@@ -70,6 +80,15 @@ const PlacesSidebar = React.memo(function PlacesSidebar({toast.success(t('places.googleListImported', { count: result.count, list: result.listName }))setGoogleListOpen(false)setGoogleListUrl('')+ if (result.places?.length > 0) {+ const importedIds: number[] = result.places.map((p: { id: number }) => p.id)+ pushUndo?.(t('undo.importGoogleList'), async () => {+ for (const id of importedIds) {+ try { await placesApi.delete(tripId, id) } catch {}+ }+ await loadTrip(tripId)+ })+ }} catch (err: any) {toast.error(err?.response?.data?.error || t('places.googleListError'))} finally {diff --git a/client/src/hooks/usePlannerHistory.ts b/client/src/hooks/usePlannerHistory.tsnew file mode 100644index 000000000..fb8e79b70--- /dev/null+++ b/client/src/hooks/usePlannerHistory.ts@@ -0,0 +1,29 @@+import { useRef, useReducer } from 'react'++export interface UndoEntry {+ label: string+ undo: () => Promise<void> | void+}++export function usePlannerHistory(maxEntries = 30) {+ const historyRef = useRef<UndoEntry[]>([])+ const [, forceUpdate] = useReducer((x: number) => x + 1, 0)++ const pushUndo = (label: string, undoFn: () => Promise<void> | void) => {+ historyRef.current = [{ label, undo: undoFn }, ...historyRef.current].slice(0, maxEntries)+ forceUpdate()+ }++ const undo = async () => {+ if (historyRef.current.length === 0) return+ const [first, ...rest] = historyRef.current+ historyRef.current = rest+ forceUpdate()+ try { await first.undo() } catch (e) { console.error('Undo failed:', e) }+ }++ const canUndo = historyRef.current.length > 0+ const lastActionLabel = historyRef.current[0]?.label ?? null++ return { pushUndo, undo, canUndo, lastActionLabel }+}diff --git a/client/src/i18n/translations/ar.ts b/client/src/i18n/translations/ar.tsindex dde5c0dd2..39e2dfc26 100644--- a/client/src/i18n/translations/ar.ts+++ b/client/src/i18n/translations/ar.ts@@ -1488,6 +1488,19 @@ const ar: Record<string, string | { name: string; category: string }[]> = {'perm.actionHint.packing_edit': 'من يمكنه إدارة عناصر التعبئة والحقائب','perm.actionHint.collab_edit': 'من يمكنه إنشاء ملاحظات واستطلاعات وإرسال رسائل','perm.actionHint.share_manage': 'من يمكنه إنشاء أو حذف روابط المشاركة العامة',+ // Undo+ 'undo.button': 'Undo',+ 'undo.tooltip': 'Undo: {action}',+ 'undo.assignPlace': 'Place assigned to day',+ 'undo.removeAssignment': 'Place removed from day',+ 'undo.reorder': 'Places reordered',+ 'undo.optimize': 'Route optimized',+ 'undo.deletePlace': 'Place deleted',+ 'undo.moveDay': 'Place moved to another day',+ 'undo.lock': 'Place lock toggled',+ 'undo.importGpx': 'GPX import',+ 'undo.importGoogleList': 'Google Maps import',+}export default ardiff --git a/client/src/i18n/translations/br.ts b/client/src/i18n/translations/br.tsindex 97c1c6954..073f83e61 100644--- a/client/src/i18n/translations/br.ts+++ b/client/src/i18n/translations/br.ts@@ -1483,6 +1483,19 @@ const br: Record<string, string | { name: string; category: string }[]> = {'perm.actionHint.packing_edit': 'Quem pode gerenciar itens de bagagem e malas','perm.actionHint.collab_edit': 'Quem pode criar notas, enquetes e enviar mensagens','perm.actionHint.share_manage': 'Quem pode criar ou excluir links de compartilhamento públicos',+ // Undo+ 'undo.button': 'Undo',+ 'undo.tooltip': 'Undo: {action}',+ 'undo.assignPlace': 'Place assigned to day',+ 'undo.removeAssignment': 'Place removed from day',+ 'undo.reorder': 'Places reordered',+ 'undo.optimize': 'Route optimized',+ 'undo.deletePlace': 'Place deleted',+ 'undo.moveDay': 'Place moved to another day',+ 'undo.lock': 'Place lock toggled',+ 'undo.importGpx': 'GPX import',+ 'undo.importGoogleList': 'Google Maps import',+}export default brdiff --git a/client/src/i18n/translations/cs.ts b/client/src/i18n/translations/cs.tsindex e3d4cc644..b4c1bc6ea 100644--- a/client/src/i18n/translations/cs.ts+++ b/client/src/i18n/translations/cs.ts@@ -507,8 +507,6 @@ const cs: Record<string, string | { name: string; category: string }[]> = {'admin.addons.toast.updated': 'Doplněk byl aktualizován','admin.addons.toast.error': 'Aktualizace doplňku se nezdařila','admin.addons.noAddons': 'Žádné doplňky nejsou k dispozici',- 'admin.addons.catalog.memories.name': 'Fotky (Immich)',- 'admin.addons.catalog.memories.description': 'Sdílejte cestovní fotky přes vaši instanci Immich','admin.addons.catalog.mcp.name': 'MCP','admin.addons.catalog.mcp.description': 'Model Context Protocol pro integraci AI asistentů','admin.addons.subtitleBefore': 'Zapněte nebo vypněte funkce a přizpůsobte si ',@@ -1488,6 +1486,19 @@ const cs: Record<string, string | { name: string; category: string }[]> = {'perm.actionHint.packing_edit': 'Kdo může spravovat položky balení a tašky','perm.actionHint.collab_edit': 'Kdo může vytvářet poznámky, hlasování a posílat zprávy','perm.actionHint.share_manage': 'Kdo může vytvářet nebo mazat veřejné odkazy ke sdílení',+ // Undo+ 'undo.button': 'Undo',+ 'undo.tooltip': 'Undo: {action}',+ 'undo.assignPlace': 'Place assigned to day',+ 'undo.removeAssignment': 'Place removed from day',+ 'undo.reorder': 'Places reordered',+ 'undo.optimize': 'Route optimized',+ 'undo.deletePlace': 'Place deleted',+ 'undo.moveDay': 'Place moved to another day',+ 'undo.lock': 'Place lock toggled',+ 'undo.importGpx': 'GPX import',+ 'undo.importGoogleList': 'Google Maps import',+}export default csdiff --git a/client/src/i18n/translations/de.ts b/client/src/i18n/translations/de.tsindex 8e6b4492b..fba93d658 100644--- a/client/src/i18n/translations/de.ts+++ b/client/src/i18n/translations/de.ts@@ -1485,6 +1485,19 @@ const de: Record<string, string | { name: string; category: string }[]> = {'perm.actionHint.packing_edit': 'Wer kann Packstücke und Taschen verwalten','perm.actionHint.collab_edit': 'Wer kann Notizen, Umfragen erstellen und Nachrichten senden','perm.actionHint.share_manage': 'Wer kann öffentliche Freigabelinks erstellen oder löschen',+ // Undo+ 'undo.button': 'Undo',+ 'undo.tooltip': 'Undo: {action}',+ 'undo.assignPlace': 'Place assigned to day',+ 'undo.removeAssignment': 'Place removed from day',+ 'undo.reorder': 'Places reordered',+ 'undo.optimize': 'Route optimized',+ 'undo.deletePlace': 'Place deleted',+ 'undo.moveDay': 'Place moved to another day',+ 'undo.lock': 'Place lock toggled',+ 'undo.importGpx': 'GPX import',+ 'undo.importGoogleList': 'Google Maps import',+}export default dediff --git a/client/src/i18n/translations/en.ts b/client/src/i18n/translations/en.tsindex 632a8c3b9..44d9b6251 100644--- a/client/src/i18n/translations/en.ts+++ b/client/src/i18n/translations/en.ts@@ -1482,6 +1482,21 @@ const en: Record<string, string | { name: string; category: string }[]> = {'perm.actionHint.packing_edit': 'Who can manage packing items and bags','perm.actionHint.collab_edit': 'Who can create notes, polls and send messages','perm.actionHint.share_manage': 'Who can create or delete public share links',++ // Undo+ 'undo.button': 'Undo',+ 'undo.tooltip': 'Undo: {action}',+ 'undo.assignPlace': 'Place assigned to day',+ 'undo.removeAssignment': 'Place removed from day',+ 'undo.reorder': 'Places reordered',+ 'undo.optimize': 'Route optimized',+ 'undo.deletePlace': 'Place deleted',+ 'undo.moveDay': 'Place moved to another day',+ 'undo.lock': 'Place lock toggled',+ 'undo.importGpx': 'GPX import',+ 'undo.importGoogleList': 'Google Maps import',+ 'undo.addPlace': 'Place added',+ 'undo.done': 'Undone: {action}',}export default endiff --git a/client/src/i18n/translations/es.ts b/client/src/i18n/translations/es.tsindex 408fc3dbd..3076e0488 100644--- a/client/src/i18n/translations/es.ts+++ b/client/src/i18n/translations/es.ts@@ -1490,6 +1490,19 @@ const es: Record<string, string> = {'perm.actionHint.packing_edit': 'Quién puede gestionar artículos de equipaje y bolsas','perm.actionHint.collab_edit': 'Quién puede crear notas, encuestas y enviar mensajes','perm.actionHint.share_manage': 'Quién puede crear o eliminar enlaces compartidos públicos',+ // Undo+ 'undo.button': 'Undo',+ 'undo.tooltip': 'Undo: {action}',+ 'undo.assignPlace': 'Place assigned to day',+ 'undo.removeAssignment': 'Place removed from day',+ 'undo.reorder': 'Places reordered',+ 'undo.optimize': 'Route optimized',+ 'undo.deletePlace': 'Place deleted',+ 'undo.moveDay': 'Place moved to another day',+ 'undo.lock': 'Place lock toggled',+ 'undo.importGpx': 'GPX import',+ 'undo.importGoogleList': 'Google Maps import',+}export default esdiff --git a/client/src/i18n/translations/fr.ts b/client/src/i18n/translations/fr.tsindex 5e313991c..eadad5782 100644--- a/client/src/i18n/translations/fr.ts+++ b/client/src/i18n/translations/fr.ts@@ -1484,6 +1484,19 @@ const fr: Record<string, string> = {'perm.actionHint.packing_edit': 'Qui peut gérer les articles de bagages et les sacs','perm.actionHint.collab_edit': 'Qui peut créer des notes, des sondages et envoyer des messages','perm.actionHint.share_manage': 'Qui peut créer ou supprimer des liens de partage publics',+ // Undo+ 'undo.button': 'Undo',+ 'undo.tooltip': 'Undo: {action}',+ 'undo.assignPlace': 'Place assigned to day',+ 'undo.removeAssignment': 'Place removed from day',+ 'undo.reorder': 'Places reordered',+ 'undo.optimize': 'Route optimized',+ 'undo.deletePlace': 'Place deleted',+ 'undo.moveDay': 'Place moved to another day',+ 'undo.lock': 'Place lock toggled',+ 'undo.importGpx': 'GPX import',+ 'undo.importGoogleList': 'Google Maps import',+}export default frdiff --git a/client/src/i18n/translations/hu.ts b/client/src/i18n/translations/hu.tsindex fc516d412..2d577f95c 100644--- a/client/src/i18n/translations/hu.ts+++ b/client/src/i18n/translations/hu.ts@@ -1485,6 +1485,19 @@ const hu: Record<string, string | { name: string; category: string }[]> = {'perm.actionHint.packing_edit': 'Ki kezelheti a csomagolási tételeket és táskákat','perm.actionHint.collab_edit': 'Ki hozhat létre jegyzeteket, szavazásokat és küldhet üzeneteket','perm.actionHint.share_manage': 'Ki hozhat létre vagy törölhet nyilvános megosztási linkeket',+ // Undo+ 'undo.button': 'Undo',+ 'undo.tooltip': 'Undo: {action}',+ 'undo.assignPlace': 'Place assigned to day',+ 'undo.removeAssignment': 'Place removed from day',+ 'undo.reorder': 'Places reordered',+ 'undo.optimize': 'Route optimized',+ 'undo.deletePlace': 'Place deleted',+ 'undo.moveDay': 'Place moved to another day',+ 'undo.lock': 'Place lock toggled',+ 'undo.importGpx': 'GPX import',+ 'undo.importGoogleList': 'Google Maps import',+}export default hudiff --git a/client/src/i18n/translations/it.ts b/client/src/i18n/translations/it.tsindex 730955019..e77cd5ec6 100644--- a/client/src/i18n/translations/it.ts+++ b/client/src/i18n/translations/it.ts@@ -1485,6 +1485,21 @@ const it: Record<string, string | { name: string; category: string }[]> = {'perm.actionHint.packing_edit': 'Chi può gestire articoli da bagaglio e borse','perm.actionHint.collab_edit': 'Chi può creare note, sondaggi e inviare messaggi','perm.actionHint.share_manage': 'Chi può creare o eliminare link di condivisione pubblici',++ // Undo+ 'undo.button': 'Annulla',+ 'undo.tooltip': 'Annulla: {action}',+ 'undo.assignPlace': 'Luogo assegnato al giorno',+ 'undo.removeAssignment': 'Luogo rimosso dal giorno',+ 'undo.reorder': 'Luoghi riordinati',+ 'undo.optimize': 'Percorso ottimizzato',+ 'undo.deletePlace': 'Luogo eliminato',+ 'undo.moveDay': 'Luogo spostato in altro giorno',+ 'undo.lock': 'Blocco luogo modificato',+ 'undo.importGpx': 'Importazione GPX',+ 'undo.importGoogleList': 'Importazione Google Maps',+ 'undo.addPlace': 'Luogo aggiunto',+ 'undo.done': 'Annullato: {action}',}export default itdiff --git a/client/src/i18n/translations/nl.ts b/client/src/i18n/translations/nl.tsindex f7d2bb06e..8bdcee8e7 100644--- a/client/src/i18n/translations/nl.ts+++ b/client/src/i18n/translations/nl.ts@@ -1484,6 +1484,19 @@ const nl: Record<string, string> = {'perm.actionHint.packing_edit': 'Wie kan pakitems en tassen beheren','perm.actionHint.collab_edit': 'Wie kan notities, polls aanmaken en berichten versturen','perm.actionHint.share_manage': 'Wie kan openbare deellinks aanmaken of verwijderen',+ // Undo+ 'undo.button': 'Undo',+ 'undo.tooltip': 'Undo: {action}',+ 'undo.assignPlace': 'Place assigned to day',+ 'undo.removeAssignment': 'Place removed from day',+ 'undo.reorder': 'Places reordered',+ 'undo.optimize': 'Route optimized',+ 'undo.deletePlace': 'Place deleted',+ 'undo.moveDay': 'Place moved to another day',+ 'undo.lock': 'Place lock toggled',+ 'undo.importGpx': 'GPX import',+ 'undo.importGoogleList': 'Google Maps import',+}export default nldiff --git a/client/src/i18n/translations/ru.ts b/client/src/i18n/translations/ru.tsindex 876e9d140..c4a56e415 100644--- a/client/src/i18n/translations/ru.ts+++ b/client/src/i18n/translations/ru.ts@@ -1484,6 +1484,19 @@ const ru: Record<string, string> = {'perm.actionHint.packing_edit': 'Кто может управлять вещами для сборов и сумками','perm.actionHint.collab_edit': 'Кто может создавать заметки, опросы и отправлять сообщения','perm.actionHint.share_manage': 'Кто может создавать или удалять публичные ссылки для обмена',+ // Undo+ 'undo.button': 'Undo',+ 'undo.tooltip': 'Undo: {action}',+ 'undo.assignPlace': 'Place assigned to day',+ 'undo.removeAssignment': 'Place removed from day',+ 'undo.reorder': 'Places reordered',+ 'undo.optimize': 'Route optimized',+ 'undo.deletePlace': 'Place deleted',+ 'undo.moveDay': 'Place moved to another day',+ 'undo.lock': 'Place lock toggled',+ 'undo.importGpx': 'GPX import',+ 'undo.importGoogleList': 'Google Maps import',+}export default rudiff --git a/client/src/i18n/translations/zh.ts b/client/src/i18n/translations/zh.tsindex 92ac82175..285375f00 100644--- a/client/src/i18n/translations/zh.ts+++ b/client/src/i18n/translations/zh.ts@@ -1484,6 +1484,19 @@ const zh: Record<string, string> = {'perm.actionHint.packing_edit': '谁可以管理行李物品和包袋','perm.actionHint.collab_edit': '谁可以创建笔记、投票和发送消息','perm.actionHint.share_manage': '谁可以创建或删除公开分享链接',+ // Undo+ 'undo.button': 'Undo',+ 'undo.tooltip': 'Undo: {action}',+ 'undo.assignPlace': 'Place assigned to day',+ 'undo.removeAssignment': 'Place removed from day',+ 'undo.reorder': 'Places reordered',+ 'undo.optimize': 'Route optimized',+ 'undo.deletePlace': 'Place deleted',+ 'undo.moveDay': 'Place moved to another day',+ 'undo.lock': 'Place lock toggled',+ 'undo.importGpx': 'GPX import',+ 'undo.importGoogleList': 'Google Maps import',+}export default zhdiff --git a/client/src/pages/TripPlannerPage.tsx b/client/src/pages/TripPlannerPage.tsxindex 4bd511b38..61e0877c0 100644--- a/client/src/pages/TripPlannerPage.tsx+++ b/client/src/pages/TripPlannerPage.tsx@@ -30,6 +30,7 @@ import { useResizablePanels } from '../hooks/useResizablePanels'import { useTripWebSocket } from '../hooks/useTripWebSocket'import { useRouteCalculation } from '../hooks/useRouteCalculation'import { usePlaceSelection } from '../hooks/usePlaceSelection'+import { usePlannerHistory } from '../hooks/usePlannerHistory'import type { Accommodation, TripMember, Day, Place, Reservation } from '../types'export default function TripPlannerPage(): React.ReactElement | null {@@ -53,6 +54,13 @@ export default function TripPlannerPage(): React.ReactElement | null {const tripActions = useRef(useTripStore.getState()).currentconst can = useCanDo()const canUploadFiles = can('file_upload', trip)+ const { pushUndo, undo, canUndo, lastActionLabel } = usePlannerHistory()++ const handleUndo = useCallback(async () => {+ const label = lastActionLabel+ await undo()+ toast.info(t('undo.done', { action: label ?? '' }))+ }, [undo, lastActionLabel, toast])const [enabledAddons, setEnabledAddons] = useState<Record<string, boolean>>({ packing: true, budget: true, documents: true })const [tripAccommodations, setTripAccommodations] = useState<Accommodation[]>([])@@ -267,8 +275,14 @@ export default function TripPlannerPage(): React.ReactElement | null {}}toast.success(t('trip.toast.placeAdded'))+ if (place?.id) {+ const capturedId = place.id+ pushUndo(t('undo.addPlace'), async () => {+ await tripActions.deletePlace(tripId, capturedId)+ })+ }}- }, [editingPlace, editingAssignmentId, tripId, toast])+ }, [editingPlace, editingAssignmentId, tripId, toast, pushUndo])const handleDeletePlace = useCallback((placeId) => {setDeletePlaceId(placeId)@@ -276,33 +290,83 @@ export default function TripPlannerPage(): React.ReactElement | null {const confirmDeletePlace = useCallback(async () => {if (!deletePlaceId) return+ const state = useTripStore.getState()+ const capturedPlace = state.places.find(p => p.id === deletePlaceId)+ const capturedAssignments = Object.entries(state.assignments).flatMap(([dayId, as]) =>+ as.filter(a => a.place?.id === deletePlaceId).map(a => ({ dayId: Number(dayId), orderIndex: a.order_index }))+ )try {await tripActions.deletePlace(tripId, deletePlaceId)if (selectedPlaceId === deletePlaceId) setSelectedPlaceId(null)toast.success(t('trip.toast.placeDeleted'))+ if (capturedPlace) {+ pushUndo(t('undo.deletePlace'), async () => {+ const newPlace = await tripActions.addPlace(tripId, {+ name: capturedPlace.name,+ description: capturedPlace.description,+ lat: capturedPlace.lat,+ lng: capturedPlace.lng,+ address: capturedPlace.address,+ category_id: capturedPlace.category_id,+ icon: capturedPlace.icon,+ price: capturedPlace.price,+ })+ for (const { dayId, orderIndex } of capturedAssignments) {+ await tripActions.assignPlaceToDay(tripId, dayId, newPlace.id, orderIndex)+ }+ })+ }} catch (err: unknown) { toast.error(err instanceof Error ? err.message : 'Unknown error') }- }, [deletePlaceId, tripId, toast, selectedPlaceId])+ }, [deletePlaceId, tripId, toast, selectedPlaceId, pushUndo])const handleAssignToDay = useCallback(async (placeId, dayId, position) => {const target = dayId || selectedDayIdif (!target) { toast.error(t('trip.toast.selectDay')); return }try {- await tripActions.assignPlaceToDay(tripId, target, placeId, position)+ const assignment = await tripActions.assignPlaceToDay(tripId, target, placeId, position)toast.success(t('trip.toast.assignedToDay'))updateRouteForDay(target)+ if (assignment?.id) {+ const capturedAssignmentId = assignment.id+ const capturedTarget = target+ pushUndo(t('undo.assignPlace'), async () => {+ await tripActions.removeAssignment(tripId, capturedTarget, capturedAssignmentId)+ })+ }} catch (err: unknown) { toast.error(err instanceof Error ? err.message : 'Unknown error') }- }, [selectedDayId, tripId, toast, updateRouteForDay])+ }, [selectedDayId, tripId, toast, updateRouteForDay, pushUndo])const handleRemoveAssignment = useCallback(async (dayId, assignmentId) => {+ const state = useTripStore.getState()+ const capturedAssignment = (state.assignments[String(dayId)] || []).find(a => a.id === assignmentId)+ const capturedPlaceId = capturedAssignment?.place?.id+ const capturedOrderIndex = capturedAssignment?.order_index ?? 0try {await tripActions.removeAssignment(tripId, dayId, assignmentId)+ if (capturedPlaceId != null) {+ const capturedDayId = dayId+ const capturedPos = capturedOrderIndex+ pushUndo(t('undo.removeAssignment'), async () => {+ await tripActions.assignPlaceToDay(tripId, capturedDayId, capturedPlaceId, capturedPos)+ })+ }}catch (err: unknown) { toast.error(err instanceof Error ? err.message : 'Unknown error') }- }, [tripId, toast, updateRouteForDay])+ }, [tripId, toast, updateRouteForDay, pushUndo])const handleReorder = useCallback((dayId, orderedIds) => {+ const prevIds = (useTripStore.getState().assignments[String(dayId)] || [])+ .slice().sort((a, b) => a.order_index - b.order_index).map(a => a.id)try {- tripActions.reorderAssignments(tripId, dayId, orderedIds).catch(() => {})+ tripActions.reorderAssignments(tripId, dayId, orderedIds)+ .then(() => {+ const capturedDayId = dayId+ const capturedPrevIds = prevIds+ pushUndo(t('undo.reorder'), async () => {+ await tripActions.reorderAssignments(tripId, capturedDayId, capturedPrevIds)+ })+ })+ .catch(() => {})// Update route immediately from orderedIdsconst dayItems = useTripStore.getState().assignments[String(dayId)] || []const ordered = orderedIds.map(id => dayItems.find(a => a.id === id)).filter(Boolean)@@ -312,7 +376,7 @@ export default function TripPlannerPage(): React.ReactElement | null {setRouteInfo(null)}catch { toast.error(t('trip.toast.reorderError')) }- }, [tripId, toast])+ }, [tripId, toast, pushUndo])const handleUpdateDayTitle = useCallback(async (dayId, title) => {try { await tripActions.updateDayTitle(tripId, dayId, title) }@@ -550,6 +614,10 @@ export default function TripPlannerPage(): React.ReactElement | null {accommodations={tripAccommodations}onNavigateToFiles={() => handleTabChange('dateien')}onExpandedDaysChange={setExpandedDayIds}+ pushUndo={pushUndo}+ canUndo={canUndo}+ lastActionLabel={lastActionLabel}+ onUndo={handleUndo}/>{!leftCollapsed && (<div@@ -610,6 +678,7 @@ export default function TripPlannerPage(): React.ReactElement | null {onEditPlace={(place) => { setEditingPlace(place); setEditingAssignmentId(null); setShowPlaceForm(true) }}onDeletePlace={(placeId) => handleDeletePlace(placeId)}onCategoryFilterChange={setMapCategoryFilter}+ pushUndo={pushUndo}/></div></div>@@ -762,8 +831,8 @@ export default function TripPlannerPage(): React.ReactElement | null {</div><div style={{ flex: 1, overflow: 'auto' }}>{mobileSidebarOpen === 'left'- ? <DayPlanSidebar tripId={tripId} trip={trip} days={days} places={places} categories={categories} assignments={assignments} selectedDayId={selectedDayId} selectedPlaceId={selectedPlaceId} selectedAssignmentId={selectedAssignmentId} onSelectDay={(id) => { handleSelectDay(id); setMobileSidebarOpen(null) }} onPlaceClick={(placeId, assignmentId) => { handlePlaceClick(placeId, assignmentId); setMobileSidebarOpen(null) }} onReorder={handleReorder} onUpdateDayTitle={handleUpdateDayTitle} onAssignToDay={handleAssignToDay} onRouteCalculated={(r) => { if (r) { setRoute(r.coordinates); setRouteInfo({ distance: r.distanceText, duration: r.durationText }) } }} reservations={reservations} onAddReservation={(dayId) => { setEditingReservation(null); tripActions.setSelectedDay(dayId); setShowReservationModal(true); setMobileSidebarOpen(null) }} onDayDetail={(day) => { setShowDayDetail(day); setSelectedPlaceId(null); setSelectedAssignmentId(null); setMobileSidebarOpen(null) }} accommodations={tripAccommodations} onNavigateToFiles={() => { setMobileSidebarOpen(null); handleTabChange('dateien') }} onExpandedDaysChange={setExpandedDayIds} />- : <PlacesSidebar tripId={tripId} places={places} categories={categories} assignments={assignments} selectedDayId={selectedDayId} selectedPlaceId={selectedPlaceId} onPlaceClick={(placeId) => { handlePlaceClick(placeId); setMobileSidebarOpen(null) }} onAddPlace={() => { setEditingPlace(null); setShowPlaceForm(true); setMobileSidebarOpen(null) }} onAssignToDay={handleAssignToDay} onEditPlace={(place) => { setEditingPlace(place); setEditingAssignmentId(null); setShowPlaceForm(true); setMobileSidebarOpen(null) }} onDeletePlace={(placeId) => handleDeletePlace(placeId)} days={days} isMobile onCategoryFilterChange={setMapCategoryFilter} />+ ? <DayPlanSidebar tripId={tripId} trip={trip} days={days} places={places} categories={categories} assignments={assignments} selectedDayId={selectedDayId} selectedPlaceId={selectedPlaceId} selectedAssignmentId={selectedAssignmentId} onSelectDay={(id) => { handleSelectDay(id); setMobileSidebarOpen(null) }} onPlaceClick={(placeId, assignmentId) => { handlePlaceClick(placeId, assignmentId); setMobileSidebarOpen(null) }} onReorder={handleReorder} onUpdateDayTitle={handleUpdateDayTitle} onAssignToDay={handleAssignToDay} onRouteCalculated={(r) => { if (r) { setRoute(r.coordinates); setRouteInfo({ distance: r.distanceText, duration: r.durationText }) } }} reservations={reservations} onAddReservation={(dayId) => { setEditingReservation(null); tripActions.setSelectedDay(dayId); setShowReservationModal(true); setMobileSidebarOpen(null) }} onDayDetail={(day) => { setShowDayDetail(day); setSelectedPlaceId(null); setSelectedAssignmentId(null); setMobileSidebarOpen(null) }} accommodations={tripAccommodations} onNavigateToFiles={() => { setMobileSidebarOpen(null); handleTabChange('dateien') }} onExpandedDaysChange={setExpandedDayIds} pushUndo={pushUndo} canUndo={canUndo} lastActionLabel={lastActionLabel} onUndo={handleUndo} />+ : <PlacesSidebar tripId={tripId} places={places} categories={categories} assignments={assignments} selectedDayId={selectedDayId} selectedPlaceId={selectedPlaceId} onPlaceClick={(placeId) => { handlePlaceClick(placeId); setMobileSidebarOpen(null) }} onAddPlace={() => { setEditingPlace(null); setShowPlaceForm(true); setMobileSidebarOpen(null) }} onAssignToDay={handleAssignToDay} onEditPlace={(place) => { setEditingPlace(place); setEditingAssignmentId(null); setShowPlaceForm(true); setMobileSidebarOpen(null) }} onDeletePlace={(placeId) => handleDeletePlace(placeId)} days={days} isMobile onCategoryFilterChange={setMapCategoryFilter} pushUndo={pushUndo} />}</div></div>