From 4ba6005ca327ba0169a828e7f0dfb946af5eebe7 Mon Sep 17 00:00:00 2001 From: Maurice Date: Mon, 6 Apr 2026 12:56:54 +0200 Subject: [PATCH] fix(dayplan): resolve duplicate reservation display, date off-by-one, and missing day_id on edit - Exclude place-assigned reservations from timeline to prevent duplicate display - Use selected day's date instead of today when entering time without date - Pass day_id when updating reservations, not only when creating --- client/src/components/Planner/DayPlanSidebar.tsx | 2 ++ client/src/components/Planner/ReservationModal.tsx | 3 ++- client/src/pages/TripPlannerPage.tsx | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/client/src/components/Planner/DayPlanSidebar.tsx b/client/src/components/Planner/DayPlanSidebar.tsx index 5393ec9..0352002 100644 --- a/client/src/components/Planner/DayPlanSidebar.tsx +++ b/client/src/components/Planner/DayPlanSidebar.tsx @@ -248,8 +248,10 @@ const DayPlanSidebar = React.memo(function DayPlanSidebar({ const getTransportForDay = (dayId: number) => { const day = days.find(d => d.id === dayId) if (!day?.date) return [] + const dayAssignmentIds = (assignments[String(dayId)] || []).map(a => a.id) return reservations.filter(r => { if (!r.reservation_time || r.type === 'hotel') return false + if (r.assignment_id && dayAssignmentIds.includes(r.assignment_id)) return false const startDate = r.reservation_time.split('T')[0] const endDate = getEndDate(r) diff --git a/client/src/components/Planner/ReservationModal.tsx b/client/src/components/Planner/ReservationModal.tsx index cbbfba6..461d700 100644 --- a/client/src/components/Planner/ReservationModal.tsx +++ b/client/src/components/Planner/ReservationModal.tsx @@ -385,7 +385,8 @@ export function ReservationModal({ isOpen, onClose, onSave, reservation, days, p value={(() => { const [, t] = (form.reservation_time || '').split('T'); return t || '' })()} onChange={t => { const [d] = (form.reservation_time || '').split('T') - const date = d || new Date().toISOString().split('T')[0] + const selectedDay = days.find(dy => dy.id === selectedDayId) + const date = d || selectedDay?.date || new Date().toISOString().split('T')[0] set('reservation_time', t ? `${date}T${t}` : date) }} /> diff --git a/client/src/pages/TripPlannerPage.tsx b/client/src/pages/TripPlannerPage.tsx index d2c0c2a..365131e 100644 --- a/client/src/pages/TripPlannerPage.tsx +++ b/client/src/pages/TripPlannerPage.tsx @@ -431,7 +431,7 @@ export default function TripPlannerPage(): React.ReactElement | null { const handleSaveReservation = async (data) => { try { if (editingReservation) { - const r = await tripActions.updateReservation(tripId, editingReservation.id, data) + const r = await tripActions.updateReservation(tripId, editingReservation.id, { ...data, day_id: selectedDayId || null }) toast.success(t('trip.toast.reservationUpdated')) setShowReservationModal(false) if (data.type === 'hotel') {