feat: Zielhafen des Vortags als Start-Hafen für neuen Reisetag übernehmen
Erweitert die bestehende Vortags-Übernahme um den Starthafen im gleichen Bestätigungsdialog. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -11,11 +11,12 @@ import LogEntryEditor from './LogEntryEditor.tsx'
|
|||||||
import { useDialog } from './ModalDialog.tsx'
|
import { useDialog } from './ModalDialog.tsx'
|
||||||
import { FileText, Plus, Trash2, ChevronRight, Calendar, Download, Share2 } from 'lucide-react'
|
import { FileText, Plus, Trash2, ChevronRight, Calendar, Download, Share2 } from 'lucide-react'
|
||||||
import {
|
import {
|
||||||
carryOverTankLevelsFromPreviousDay,
|
carryOverFromPreviousDay,
|
||||||
compareTravelDaysChronological,
|
compareTravelDaysChronological,
|
||||||
emptyTankLevels,
|
emptyTankLevels,
|
||||||
formatTankLiters,
|
formatTankLiters,
|
||||||
getNextTravelDayNumber,
|
getNextTravelDayNumber,
|
||||||
|
hasCarryOverFromPreviousDay,
|
||||||
type LogEntryTankSource,
|
type LogEntryTankSource,
|
||||||
type TravelDaySortable
|
type TravelDaySortable
|
||||||
} from '../utils/logEntryTankLevels.js'
|
} from '../utils/logEntryTankLevels.js'
|
||||||
@@ -228,11 +229,12 @@ export default function LogEntriesList({
|
|||||||
|
|
||||||
decryptedEntries.sort(compareTravelDaysChronological)
|
decryptedEntries.sort(compareTravelDaysChronological)
|
||||||
const previousEntry = decryptedEntries.at(-1) ?? null
|
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(
|
const confirmed = await showConfirm(
|
||||||
t('logs.carry_over_tanks_confirm', {
|
t('logs.carry_over_tanks_confirm', {
|
||||||
|
departure: departure || '—',
|
||||||
fw: formatTankLiters(freshwater.morning),
|
fw: formatTankLiters(freshwater.morning),
|
||||||
fuel: formatTankLiters(fuel.morning)
|
fuel: formatTankLiters(fuel.morning)
|
||||||
}),
|
}),
|
||||||
@@ -243,6 +245,7 @@ export default function LogEntriesList({
|
|||||||
if (!confirmed) {
|
if (!confirmed) {
|
||||||
freshwater = emptyTankLevels()
|
freshwater = emptyTankLevels()
|
||||||
fuel = emptyTankLevels()
|
fuel = emptyTankLevels()
|
||||||
|
departure = ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -255,7 +258,7 @@ export default function LogEntriesList({
|
|||||||
const initialPayload = {
|
const initialPayload = {
|
||||||
date: todayStr,
|
date: todayStr,
|
||||||
dayOfTravel: getNextTravelDayNumber(decryptedEntries),
|
dayOfTravel: getNextTravelDayNumber(decryptedEntries),
|
||||||
departure: '',
|
departure,
|
||||||
destination: '',
|
destination: '',
|
||||||
freshwater,
|
freshwater,
|
||||||
fuel,
|
fuel,
|
||||||
|
|||||||
@@ -159,8 +159,8 @@
|
|||||||
"loading": "Journal wird geladen...",
|
"loading": "Journal wird geladen...",
|
||||||
"delete_entry": "Tag löschen",
|
"delete_entry": "Tag löschen",
|
||||||
"delete_confirm": "Sind Sie sicher, dass Sie diesen Reisetag unwiderruflich löschen möchten?",
|
"delete_confirm": "Sind Sie sicher, dass Sie diesen Reisetag unwiderruflich löschen möchten?",
|
||||||
"carry_over_tanks_title": "Tankstände übernehmen?",
|
"carry_over_tanks_title": "Daten vom Vortag übernehmen?",
|
||||||
"carry_over_tanks_confirm": "Morgenstände vom letzten Reisetag als Startwerte übernehmen?\n\nFrischwasser: {{fw}} L\nKraftstoff: {{fuel}} L",
|
"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_yes": "Übernehmen",
|
||||||
"carry_over_tanks_no": "Mit 0 starten",
|
"carry_over_tanks_no": "Mit 0 starten",
|
||||||
"event_title": "Chronologisches Ereignisprotokoll",
|
"event_title": "Chronologisches Ereignisprotokoll",
|
||||||
|
|||||||
@@ -159,8 +159,8 @@
|
|||||||
"loading": "Loading journal...",
|
"loading": "Loading journal...",
|
||||||
"delete_entry": "Delete Day",
|
"delete_entry": "Delete Day",
|
||||||
"delete_confirm": "Are you sure you want to permanently delete this travel 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_title": "Carry over from previous day?",
|
||||||
"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_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_yes": "Carry over",
|
||||||
"carry_over_tanks_no": "Start at 0",
|
"carry_over_tanks_no": "Start at 0",
|
||||||
"event_title": "Chronological Event Logbook",
|
"event_title": "Chronological Event Logbook",
|
||||||
|
|||||||
@@ -41,6 +41,13 @@ export function getClosingTankLevel(tank?: Partial<TankLevels> | null): number {
|
|||||||
export interface LogEntryTankSource {
|
export interface LogEntryTankSource {
|
||||||
freshwater?: Partial<TankLevels>
|
freshwater?: Partial<TankLevels>
|
||||||
fuel?: Partial<TankLevels>
|
fuel?: Partial<TankLevels>
|
||||||
|
destination?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CarryOverFromPreviousDay {
|
||||||
|
freshwater: TankLevels
|
||||||
|
fuel: TankLevels
|
||||||
|
departure: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export function emptyTankLevels(morning = 0): TankLevels {
|
export function emptyTankLevels(morning = 0): TankLevels {
|
||||||
@@ -62,3 +69,14 @@ export function carryOverTankLevelsFromPreviousDay(previousEntry?: LogEntryTankS
|
|||||||
fuel: emptyTankLevels(getClosingTankLevel(previousEntry.fuel))
|
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
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user