fix: Tank-Nachfüll-Clamping und Deaktivierung bei vollem Tank
Korrigiert fehlende useEffect-Dependencies beim Auto-Clamping und deaktiviert Refill-Eingaben, wenn der Morgenstand die Tankkapazität erreicht. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -574,13 +574,23 @@ export default function LogEntryEditor({
|
|||||||
setFuelConsumption(cons >= 0 ? String(cons) : '0')
|
setFuelConsumption(cons >= 0 ? String(cons) : '0')
|
||||||
}, [fuelMorning, fuelRefilled, fuelEvening])
|
}, [fuelMorning, fuelRefilled, fuelEvening])
|
||||||
|
|
||||||
|
const fwRefilledNoCapacity =
|
||||||
|
(tankCapacities.freshwaterCapacityL ?? 0) > 0 && fwRefilledMax == null
|
||||||
|
const fuelRefilledNoCapacity =
|
||||||
|
(tankCapacities.fuelCapacityL ?? 0) > 0 && fuelRefilledMax == null
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (fwRefilledMax == null) return
|
|
||||||
const refilled = parseFloat(fwRefilled) || 0
|
const refilled = parseFloat(fwRefilled) || 0
|
||||||
|
if (fwRefilledMax == null) {
|
||||||
|
if (fwRefilledNoCapacity && refilled > 0) {
|
||||||
|
setFwRefilled(formatTankLitersForInput(0))
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
if (refilled > fwRefilledMax) {
|
if (refilled > fwRefilledMax) {
|
||||||
setFwRefilled(formatTankLitersForInput(fwRefilledMax))
|
setFwRefilled(formatTankLitersForInput(fwRefilledMax))
|
||||||
}
|
}
|
||||||
}, [fwRefilledMax, fwMorning])
|
}, [fwRefilledMax, fwRefilled, fwRefilledNoCapacity])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (fwEveningMax == null) return
|
if (fwEveningMax == null) return
|
||||||
@@ -588,15 +598,20 @@ export default function LogEntryEditor({
|
|||||||
if (evening > fwEveningMax) {
|
if (evening > fwEveningMax) {
|
||||||
setFwEvening(formatTankLitersForInput(fwEveningMax))
|
setFwEvening(formatTankLitersForInput(fwEveningMax))
|
||||||
}
|
}
|
||||||
}, [fwEveningMax, fwMorning, fwRefilled])
|
}, [fwEveningMax, fwEvening])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (fuelRefilledMax == null) return
|
|
||||||
const refilled = parseFloat(fuelRefilled) || 0
|
const refilled = parseFloat(fuelRefilled) || 0
|
||||||
|
if (fuelRefilledMax == null) {
|
||||||
|
if (fuelRefilledNoCapacity && refilled > 0) {
|
||||||
|
setFuelRefilled(formatTankLitersForInput(0))
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
if (refilled > fuelRefilledMax) {
|
if (refilled > fuelRefilledMax) {
|
||||||
setFuelRefilled(formatTankLitersForInput(fuelRefilledMax))
|
setFuelRefilled(formatTankLitersForInput(fuelRefilledMax))
|
||||||
}
|
}
|
||||||
}, [fuelRefilledMax, fuelMorning])
|
}, [fuelRefilledMax, fuelRefilled, fuelRefilledNoCapacity])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (fuelEveningMax == null) return
|
if (fuelEveningMax == null) return
|
||||||
@@ -604,7 +619,7 @@ export default function LogEntryEditor({
|
|||||||
if (evening > fuelEveningMax) {
|
if (evening > fuelEveningMax) {
|
||||||
setFuelEvening(formatTankLitersForInput(fuelEveningMax))
|
setFuelEvening(formatTankLitersForInput(fuelEveningMax))
|
||||||
}
|
}
|
||||||
}, [fuelEveningMax, fuelMorning, fuelRefilled])
|
}, [fuelEveningMax, fuelEvening])
|
||||||
|
|
||||||
// Load yacht sails and tank capacities
|
// Load yacht sails and tank capacities
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -1317,8 +1332,8 @@ export default function LogEntryEditor({
|
|||||||
label={t('logs.refilled')}
|
label={t('logs.refilled')}
|
||||||
value={fwRefilled}
|
value={fwRefilled}
|
||||||
onChange={setFwRefilled}
|
onChange={setFwRefilled}
|
||||||
maxLiters={fwRefilledMax ?? tankCapacities.freshwaterCapacityL}
|
maxLiters={fwRefilledMax}
|
||||||
disabled={saving || readOnly}
|
disabled={saving || readOnly || fwRefilledNoCapacity}
|
||||||
titleTooltip={tankCapacityTooltip}
|
titleTooltip={tankCapacityTooltip}
|
||||||
/>
|
/>
|
||||||
<TankLiterInput
|
<TankLiterInput
|
||||||
@@ -1366,8 +1381,8 @@ export default function LogEntryEditor({
|
|||||||
label={t('logs.refilled')}
|
label={t('logs.refilled')}
|
||||||
value={fuelRefilled}
|
value={fuelRefilled}
|
||||||
onChange={setFuelRefilled}
|
onChange={setFuelRefilled}
|
||||||
maxLiters={fuelRefilledMax ?? tankCapacities.fuelCapacityL}
|
maxLiters={fuelRefilledMax}
|
||||||
disabled={saving || readOnly}
|
disabled={saving || readOnly || fuelRefilledNoCapacity}
|
||||||
titleTooltip={tankCapacityTooltip}
|
titleTooltip={tankCapacityTooltip}
|
||||||
/>
|
/>
|
||||||
<TankLiterInput
|
<TankLiterInput
|
||||||
|
|||||||
Reference in New Issue
Block a user