diff --git a/client/src/components/Planner/DayPlanSidebar.tsx b/client/src/components/Planner/DayPlanSidebar.tsx index 53bcb9c23..5f0ad3f2f 100644 --- a/client/src/components/Planner/DayPlanSidebar.tsx +++ b/client/src/components/Planner/DayPlanSidebar.tsx @@ -1293,6 +1293,30 @@ const DayPlanSidebar = React.memo(function DayPlanSidebar(props: DayPlanSidebarP { label: t('dayplan.transportMode.useDefault'), icon: RotateCcw, onClick: () => setLegMode(assignmentId, dayId, null) }, ]) } + + // Set the mode of the leg ENTERING this stop (a booking arrival or the morning + // hotel bookend). Optimistic, then persisted with direction:'incoming'. + const setIncomingLegMode = (assignmentId: number, dayId: number, mode: string | null) => { + const key = String(dayId) + if (assignments[key]) { + tripActions.setAssignments({ + ...assignments, + [key]: assignments[key].map(a => (a.id === assignmentId ? { ...a, incoming_leg_transport_mode: mode } : a)), + }) + } + assignmentsApi.updateTransport(tripId, assignmentId, mode, 'incoming').catch((err: unknown) => { + toast.error(err instanceof Error ? err.message : t('common.unknownError')) + tripActions.refreshDays(tripId) + }) + } + + const openIncomingLegModeMenu = (e: React.MouseEvent, assignmentId: number, dayId: number) => { + ctxMenu.open(e, [ + ...routeProfileOptions.map(o => ({ label: o.label, icon: modeIcon(o.key), onClick: () => setIncomingLegMode(assignmentId, dayId, o.key) })), + { divider: true }, + { label: t('dayplan.transportMode.useDefault'), icon: RotateCcw, onClick: () => setIncomingLegMode(assignmentId, dayId, null) }, + ]) + } return (
{/* Toolbar */} @@ -1614,9 +1638,15 @@ const DayPlanSidebar = React.memo(function DayPlanSidebar(props: DayPlanSidebarP handleMergedDrop(day.id, 'note', Number(noteId), lastItem.type, lastItem.data.id, true) }} > - {hotelLegs[day.id]?.top && ( - - )} + {hotelLegs[day.id]?.top && (() => { + const firstPlaceId = merged.find(i => i.type === 'place')?.data.id + const connector = + return canEditDays && firstPlaceId != null ? ( +
openIncomingLegModeMenu(e, Number(firstPlaceId), day.id)} style={{ cursor: 'pointer' }}> + {connector} +
+ ) : connector + })()} {daySchedule.byPosition[day.id]?.start.map(si => )} {merged.length === 0 && !dayNoteUi ? (
)} {daySchedule.byReservation[day.id]?.[res.id]?.map(si => )} - {routeLegs[day.id]?.[res.id] && } + {routeLegs[day.id]?.[res.id] && (() => { + const nextPlaceId = merged.slice(idx + 1).find(i => i.type === 'place')?.data.id + const connector = + return canEditDays && nextPlaceId != null ? ( +
openIncomingLegModeMenu(e, Number(nextPlaceId), day.id)} style={{ cursor: 'pointer' }}> + {connector} +
+ ) : connector + })()} ) } @@ -2343,9 +2381,15 @@ const DayPlanSidebar = React.memo(function DayPlanSidebar(props: DayPlanSidebarP }) )} {daySchedule.byPosition[day.id]?.end.map(si => )} - {hotelLegs[day.id]?.bottom && ( - - )} + {hotelLegs[day.id]?.bottom && (() => { + const lastPlaceId = [...merged].reverse().find(i => i.type === 'place')?.data.id + const connector = + return canEditDays && lastPlaceId != null ? ( +
openLegModeMenu(e, Number(lastPlaceId), day.id)} style={{ cursor: 'pointer' }}> + {connector} +
+ ) : connector + })()} {/* Drop-Zone am Listenende — immer vorhanden als Drop-Target */}