Skip to content

armgit / TREK

Public Imported from GitHub
0

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.

feat(dashboard): add pre-copy confirmation modal showing what will and won't be copied

jubnl09431f725cd5
diff --git a/client/src/components/shared/CopyTripDialog.tsx b/client/src/components/shared/CopyTripDialog.tsx
new file mode 100644
index 000000000..efea7afbd
--- /dev/null
+++ b/client/src/components/shared/CopyTripDialog.tsx
@@ -0,0 +1,108 @@
+import React, { useEffect, useCallback } from 'react'
+import { Check, X } from 'lucide-react'
+import { useTranslation } from '../../i18n'
+
+interface CopyTripDialogProps {
+ isOpen: boolean
+ tripTitle: string
+ onClose: () => void
+ onConfirm: () => void
+}
+
+const WILL_COPY_KEYS = [
+ 'dashboard.confirm.copy.will1',
+ 'dashboard.confirm.copy.will2',
+ 'dashboard.confirm.copy.will3',
+ 'dashboard.confirm.copy.will4',
+ 'dashboard.confirm.copy.will5',
+ 'dashboard.confirm.copy.will6',
+]
+
+const WONT_COPY_KEYS = [
+ 'dashboard.confirm.copy.wont1',
+ 'dashboard.confirm.copy.wont2',
+ 'dashboard.confirm.copy.wont3',
+ 'dashboard.confirm.copy.wont4',
+]
+
+export default function CopyTripDialog({ isOpen, tripTitle, onClose, onConfirm }: CopyTripDialogProps) {
+ const { t } = useTranslation()
+
+ const handleEsc = useCallback((e: KeyboardEvent) => {
+ if (e.key === 'Escape') onClose()
+ }, [onClose])
+
+ useEffect(() => {
+ if (isOpen) document.addEventListener('keydown', handleEsc)
+ return () => document.removeEventListener('keydown', handleEsc)
+ }, [isOpen, handleEsc])
+
+ if (!isOpen) return null
+
+ return (
+ <div
+ className="fixed inset-0 z-[10000] flex items-center justify-center px-4 trek-backdrop-enter"
+ style={{ backgroundColor: 'rgba(15, 23, 42, 0.5)' }}
+ onClick={onClose}
+ >
+ <div
+ className="trek-modal-enter rounded-2xl shadow-2xl w-full max-w-md p-6"
+ style={{ background: 'var(--bg-card)' }}
+ onClick={e => e.stopPropagation()}
+ >
+ <h3 className="text-base font-semibold mb-1" style={{ color: 'var(--text-primary)' }}>
+ {t('dashboard.confirm.copy.title')}
+ </h3>
+ <p className="text-sm mb-4" style={{ color: 'var(--text-secondary)' }}>
+ {tripTitle}
+ </p>
+
+ <div className="flex flex-col gap-3">
+ <div className="rounded-xl p-3" style={{ background: 'var(--bg-subtle)', border: '1px solid var(--border-secondary)' }}>
+ <p className="text-xs font-semibold uppercase tracking-wide mb-2" style={{ color: '#16a34a' }}>
+ {t('dashboard.confirm.copy.willCopy')}
+ </p>
+ <ul className="flex flex-col gap-1">
+ {WILL_COPY_KEYS.map(key => (
+ <li key={key} className="flex items-center gap-2 text-sm" style={{ color: 'var(--text-secondary)' }}>
+ <Check size={13} className="flex-shrink-0" style={{ color: '#16a34a' }} />
+ {t(key)}
+ </li>
+ ))}
+ </ul>
+ </div>
+
+ <div className="rounded-xl p-3" style={{ background: 'var(--bg-subtle)', border: '1px solid var(--border-secondary)' }}>
+ <p className="text-xs font-semibold uppercase tracking-wide mb-2" style={{ color: 'var(--text-muted)' }}>
+ {t('dashboard.confirm.copy.wontCopy')}
+ </p>
+ <ul className="flex flex-col gap-1">
+ {WONT_COPY_KEYS.map(key => (
+ <li key={key} className="flex items-center gap-2 text-sm" style={{ color: 'var(--text-secondary)' }}>
+ <X size={13} className="flex-shrink-0" style={{ color: 'var(--text-muted)' }} />
+ {t(key)}
+ </li>
+ ))}
+ </ul>
+ </div>
+ </div>
+
+ <div className="flex justify-end gap-3 mt-5">
+ <button
+ onClick={onClose}
+ className="px-4 py-2 text-sm font-medium rounded-lg transition-colors"
+ style={{ color: 'var(--text-secondary)', border: '1px solid var(--border-secondary)' }}
+ >
+ {t('common.cancel')}
+ </button>
+ <button
+ onClick={() => { onConfirm(); onClose() }}
+ className="px-4 py-2 text-sm font-medium rounded-lg transition-colors text-white bg-blue-600 hover:bg-blue-700"
+ >
+ {t('dashboard.confirm.copy.confirm')}
+ </button>
+ </div>
+ </div>
+ </div>
+ )
+}
diff --git a/client/src/i18n/translations/en.ts b/client/src/i18n/translations/en.ts
index e444d957b..a50ffcc35 100644
--- a/client/src/i18n/translations/en.ts
+++ b/client/src/i18n/translations/en.ts
@@ -122,6 +122,20 @@ const en: Record<string, string | { name: string; category: string }[]> = {
'dashboard.toast.copied': 'Trip copied!',
'dashboard.toast.copyError': 'Failed to copy trip',
'dashboard.confirm.delete': 'Delete trip "{title}"? All places and plans will be permanently deleted.',
+ 'dashboard.confirm.copy.title': 'Copy this trip?',
+ 'dashboard.confirm.copy.willCopy': 'Will be copied',
+ 'dashboard.confirm.copy.will1': 'Days, places & day assignments',
+ 'dashboard.confirm.copy.will2': 'Accommodations & reservations',
+ 'dashboard.confirm.copy.will3': 'Budget items & category order',
+ 'dashboard.confirm.copy.will4': 'Packing lists (unchecked)',
+ 'dashboard.confirm.copy.will5': 'TODOs (unassigned & unchecked)',
+ 'dashboard.confirm.copy.will6': 'Day notes',
+ 'dashboard.confirm.copy.wontCopy': "Won't be copied",
+ 'dashboard.confirm.copy.wont1': 'Collaborators & member assignments',
+ 'dashboard.confirm.copy.wont2': 'Collab notes, polls & messages',
+ 'dashboard.confirm.copy.wont3': 'Files & photos',
+ 'dashboard.confirm.copy.wont4': 'Share tokens',
+ 'dashboard.confirm.copy.confirm': 'Copy trip',
'dashboard.editTrip': 'Edit Trip',
'dashboard.createTrip': 'Create New Trip',
'dashboard.tripTitle': 'Title',
diff --git a/client/src/pages/DashboardPage.test.tsx b/client/src/pages/DashboardPage.test.tsx
index 4aac3121f..2a3530ee2 100644
--- a/client/src/pages/DashboardPage.test.tsx
+++ b/client/src/pages/DashboardPage.test.tsx
@@ -401,6 +401,10 @@ describe('DashboardPage', () => {
const copyButtons = screen.getAllByRole('button', { name: /copy/i });
await user.click(copyButtons[0]);
+ // Confirm the copy dialog
+ const confirmButton = await screen.findByRole('button', { name: /copy trip/i });
+ await user.click(confirmButton);
+
await waitFor(() => {
expect(screen.getAllByText('Paris Adventure (Copy)')[0]).toBeInTheDocument();
});
@@ -766,6 +770,10 @@ describe('DashboardPage', () => {
expect(copyButtons.length).toBeGreaterThan(0);
await user.click(copyButtons[0]);
+ // Confirm the copy dialog
+ const confirmButton = await screen.findByRole('button', { name: /copy trip/i });
+ await user.click(confirmButton);
+
await waitFor(() => {
expect(screen.getAllByText('Paris Adventure (Copy)').length).toBeGreaterThan(0);
});
diff --git a/client/src/pages/DashboardPage.tsx b/client/src/pages/DashboardPage.tsx
index 321ba3ef3..c3e4fa850 100644
--- a/client/src/pages/DashboardPage.tsx
+++ b/client/src/pages/DashboardPage.tsx
@@ -12,6 +12,7 @@ import CurrencyWidget from '../components/Dashboard/CurrencyWidget'
import TimezoneWidget from '../components/Dashboard/TimezoneWidget'
import TripFormModal from '../components/Trips/TripFormModal'
import ConfirmDialog from '../components/shared/ConfirmDialog'
+import CopyTripDialog from '../components/shared/CopyTripDialog'
import { useToast } from '../components/shared/Toast'
import { useCountUp } from '../hooks/useCountUp'
import {
@@ -699,6 +700,7 @@ export default function DashboardPage(): React.ReactElement {
const [showWidgetSettings, setShowWidgetSettings] = useState<boolean | 'mobile' | 'mobile-currency' | 'mobile-timezone'>(false)
const [viewMode, setViewMode] = useState<'grid' | 'list'>(() => (localStorage.getItem('trek_dashboard_view') as 'grid' | 'list') || 'grid')
const [deleteTrip, setDeleteTrip] = useState<DashboardTrip | null>(null)
+ const [copyTrip, setCopyTrip] = useState<DashboardTrip | null>(null)
const toggleViewMode = () => {
setViewMode(prev => {
@@ -815,14 +817,18 @@ export default function DashboardPage(): React.ReactElement {
setArchivedTrips(prev => prev.map(update))
}
- const handleCopy = async (trip: DashboardTrip) => {
+ const handleCopy = (trip: DashboardTrip) => setCopyTrip(trip)
+
+ const confirmCopy = async () => {
+ if (!copyTrip) return
try {
- const data = await tripsApi.copy(trip.id, { title: `${trip.title} (${t('dashboard.copySuffix')})` })
+ const data = await tripsApi.copy(copyTrip.id, { title: `${copyTrip.title} (${t('dashboard.copySuffix')})` })
setTrips(prev => sortTrips([data.trip, ...prev]))
toast.success(t('dashboard.toast.copied'))
} catch {
toast.error(t('dashboard.toast.copyError'))
}
+ setCopyTrip(null)
}
const today = new Date().toISOString().split('T')[0]
@@ -1205,6 +1211,13 @@ export default function DashboardPage(): React.ReactElement {
message={t('dashboard.confirm.delete', { title: deleteTrip?.title || '' })}
/>
+ <CopyTripDialog
+ isOpen={!!copyTrip}
+ tripTitle={copyTrip?.title || ''}
+ onClose={() => setCopyTrip(null)}
+ onConfirm={confirmCopy}
+ />
+
<style>{`
@keyframes pulse {
0%, 100% { opacity: 1 }