From 41fb106153af85687c9b37f69746c520fe6ab1cc Mon Sep 17 00:00:00 2001 From: elpatron Date: Fri, 29 May 2026 18:33:43 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20Zielhafen=20des=20Vortags=20als=20Start?= =?UTF-8?q?-Hafen=20f=C3=BCr=20neuen=20Reisetag=20=C3=BCbernehmen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Erweitert die bestehende Vortags-Übernahme um den Starthafen im gleichen Bestätigungsdialog. Co-authored-by: Cursor --- client/src/components/LogEntriesList.tsx | 11 +++++++---- client/src/i18n/locales/de.json | 4 ++-- client/src/i18n/locales/en.json | 4 ++-- client/src/utils/logEntryTankLevels.ts | 18 ++++++++++++++++++ 4 files changed, 29 insertions(+), 8 deletions(-) diff --git a/client/src/components/LogEntriesList.tsx b/client/src/components/LogEntriesList.tsx index 883f178..882129c 100644 --- a/client/src/components/LogEntriesList.tsx +++ b/client/src/components/LogEntriesList.tsx @@ -11,11 +11,12 @@ import LogEntryEditor from './LogEntryEditor.tsx' import { useDialog } from './ModalDialog.tsx' import { FileText, Plus, Trash2, ChevronRight, Calendar, Download, Share2 } from 'lucide-react' import { - carryOverTankLevelsFromPreviousDay, + carryOverFromPreviousDay, compareTravelDaysChronological, emptyTankLevels, formatTankLiters, getNextTravelDayNumber, + hasCarryOverFromPreviousDay, type LogEntryTankSource, type TravelDaySortable } from '../utils/logEntryTankLevels.js' @@ -228,11 +229,12 @@ export default function LogEntriesList({ decryptedEntries.sort(compareTravelDaysChronological) const previousEntry = decryptedEntries.at(-1) ?? null - let { freshwater, fuel } = carryOverTankLevelsFromPreviousDay(previousEntry) + let { freshwater, fuel, departure } = carryOverFromPreviousDay(previousEntry) - if (previousEntry && (freshwater.morning > 0 || fuel.morning > 0)) { + if (previousEntry && hasCarryOverFromPreviousDay({ freshwater, fuel, departure })) { const confirmed = await showConfirm( t('logs.carry_over_tanks_confirm', { + departure: departure || '—', fw: formatTankLiters(freshwater.morning), fuel: formatTankLiters(fuel.morning) }), @@ -243,6 +245,7 @@ export default function LogEntriesList({ if (!confirmed) { freshwater = emptyTankLevels() fuel = emptyTankLevels() + departure = '' } } @@ -255,7 +258,7 @@ export default function LogEntriesList({ const initialPayload = { date: todayStr, dayOfTravel: getNextTravelDayNumber(decryptedEntries), - departure: '', + departure, destination: '', freshwater, fuel, diff --git a/client/src/i18n/locales/de.json b/client/src/i18n/locales/de.json index 2089c2d..504d60b 100644 --- a/client/src/i18n/locales/de.json +++ b/client/src/i18n/locales/de.json @@ -159,8 +159,8 @@ "loading": "Journal wird geladen...", "delete_entry": "Tag löschen", "delete_confirm": "Sind Sie sicher, dass Sie diesen Reisetag unwiderruflich löschen möchten?", - "carry_over_tanks_title": "Tankstände übernehmen?", - "carry_over_tanks_confirm": "Morgenstände vom letzten Reisetag als Startwerte übernehmen?\n\nFrischwasser: {{fw}} L\nKraftstoff: {{fuel}} L", + "carry_over_tanks_title": "Daten vom Vortag übernehmen?", + "carry_over_tanks_confirm": "Start-Hafen, Frischwasser- und Kraftstoff-Morgenstände vom letzten Reisetag übernehmen?\n\nStart-Hafen: {{departure}}\nFrischwasser: {{fw}} L\nKraftstoff: {{fuel}} L", "carry_over_tanks_yes": "Übernehmen", "carry_over_tanks_no": "Mit 0 starten", "event_title": "Chronologisches Ereignisprotokoll", diff --git a/client/src/i18n/locales/en.json b/client/src/i18n/locales/en.json index 71f491c..4855c36 100644 --- a/client/src/i18n/locales/en.json +++ b/client/src/i18n/locales/en.json @@ -159,8 +159,8 @@ "loading": "Loading journal...", "delete_entry": "Delete Day", "delete_confirm": "Are you sure you want to permanently delete this travel day?", - "carry_over_tanks_title": "Carry over tank levels?", - "carry_over_tanks_confirm": "Use the previous travel day's closing levels as morning levels?\n\nFreshwater: {{fw}} L\nFuel: {{fuel}} L", + "carry_over_tanks_title": "Carry over from previous day?", + "carry_over_tanks_confirm": "Use the previous travel day's destination as departure port and closing tank levels as morning levels?\n\nDeparture port: {{departure}}\nFreshwater: {{fw}} L\nFuel: {{fuel}} L", "carry_over_tanks_yes": "Carry over", "carry_over_tanks_no": "Start at 0", "event_title": "Chronological Event Logbook", diff --git a/client/src/utils/logEntryTankLevels.ts b/client/src/utils/logEntryTankLevels.ts index c12fbe3..618b2c2 100644 --- a/client/src/utils/logEntryTankLevels.ts +++ b/client/src/utils/logEntryTankLevels.ts @@ -41,6 +41,13 @@ export function getClosingTankLevel(tank?: Partial | null): number { export interface LogEntryTankSource { freshwater?: Partial fuel?: Partial + destination?: string +} + +export interface CarryOverFromPreviousDay { + freshwater: TankLevels + fuel: TankLevels + departure: string } export function emptyTankLevels(morning = 0): TankLevels { @@ -62,3 +69,14 @@ export function carryOverTankLevelsFromPreviousDay(previousEntry?: LogEntryTankS fuel: emptyTankLevels(getClosingTankLevel(previousEntry.fuel)) } } + +export function carryOverFromPreviousDay(previousEntry?: LogEntryTankSource | null): CarryOverFromPreviousDay { + const { freshwater, fuel } = carryOverTankLevelsFromPreviousDay(previousEntry) + const departure = previousEntry?.destination?.trim() || '' + + return { freshwater, fuel, departure } +} + +export function hasCarryOverFromPreviousDay(carryOver: CarryOverFromPreviousDay): boolean { + return carryOver.freshwater.morning > 0 || carryOver.fuel.morning > 0 || carryOver.departure.length > 0 +}