From c4cd566da067b46f6c28bfd3c65957dde5fbff0c Mon Sep 17 00:00:00 2001 From: elpatron Date: Sun, 31 May 2026 13:44:49 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20Tank-Nachf=C3=BCll-Clamping=20und=20Deak?= =?UTF-8?q?tivierung=20bei=20vollem=20Tank?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Korrigiert fehlende useEffect-Dependencies beim Auto-Clamping und deaktiviert Refill-Eingaben, wenn der Morgenstand die Tankkapazität erreicht. Co-authored-by: Cursor --- client/src/components/LogEntryEditor.tsx | 35 +++++++++++++++++------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/client/src/components/LogEntryEditor.tsx b/client/src/components/LogEntryEditor.tsx index f6fe772..2ace57d 100644 --- a/client/src/components/LogEntryEditor.tsx +++ b/client/src/components/LogEntryEditor.tsx @@ -574,13 +574,23 @@ export default function LogEntryEditor({ setFuelConsumption(cons >= 0 ? String(cons) : '0') }, [fuelMorning, fuelRefilled, fuelEvening]) + const fwRefilledNoCapacity = + (tankCapacities.freshwaterCapacityL ?? 0) > 0 && fwRefilledMax == null + const fuelRefilledNoCapacity = + (tankCapacities.fuelCapacityL ?? 0) > 0 && fuelRefilledMax == null + useEffect(() => { - if (fwRefilledMax == null) return const refilled = parseFloat(fwRefilled) || 0 + if (fwRefilledMax == null) { + if (fwRefilledNoCapacity && refilled > 0) { + setFwRefilled(formatTankLitersForInput(0)) + } + return + } if (refilled > fwRefilledMax) { setFwRefilled(formatTankLitersForInput(fwRefilledMax)) } - }, [fwRefilledMax, fwMorning]) + }, [fwRefilledMax, fwRefilled, fwRefilledNoCapacity]) useEffect(() => { if (fwEveningMax == null) return @@ -588,15 +598,20 @@ export default function LogEntryEditor({ if (evening > fwEveningMax) { setFwEvening(formatTankLitersForInput(fwEveningMax)) } - }, [fwEveningMax, fwMorning, fwRefilled]) + }, [fwEveningMax, fwEvening]) useEffect(() => { - if (fuelRefilledMax == null) return const refilled = parseFloat(fuelRefilled) || 0 + if (fuelRefilledMax == null) { + if (fuelRefilledNoCapacity && refilled > 0) { + setFuelRefilled(formatTankLitersForInput(0)) + } + return + } if (refilled > fuelRefilledMax) { setFuelRefilled(formatTankLitersForInput(fuelRefilledMax)) } - }, [fuelRefilledMax, fuelMorning]) + }, [fuelRefilledMax, fuelRefilled, fuelRefilledNoCapacity]) useEffect(() => { if (fuelEveningMax == null) return @@ -604,7 +619,7 @@ export default function LogEntryEditor({ if (evening > fuelEveningMax) { setFuelEvening(formatTankLitersForInput(fuelEveningMax)) } - }, [fuelEveningMax, fuelMorning, fuelRefilled]) + }, [fuelEveningMax, fuelEvening]) // Load yacht sails and tank capacities useEffect(() => { @@ -1317,8 +1332,8 @@ export default function LogEntryEditor({ label={t('logs.refilled')} value={fwRefilled} onChange={setFwRefilled} - maxLiters={fwRefilledMax ?? tankCapacities.freshwaterCapacityL} - disabled={saving || readOnly} + maxLiters={fwRefilledMax} + disabled={saving || readOnly || fwRefilledNoCapacity} titleTooltip={tankCapacityTooltip} />