vehicle booking bug resolve

This commit is contained in:
Matthias Hochmeister
2026-03-25 15:17:54 +01:00
parent 0bb2feaba2
commit 51d8777d66

View File

@@ -294,6 +294,11 @@ function FahrzeugBuchungen() {
setDialogLoading(false); setDialogLoading(false);
return; return;
} }
if (endeDate <= beginnDate) {
setDialogError('Ende muss nach dem Beginn liegen.');
setDialogLoading(false);
return;
}
const payload: CreateBuchungInput = { const payload: CreateBuchungInput = {
...form, ...form,
beginn: beginnDate.toISOString(), beginn: beginnDate.toISOString(),
@@ -413,6 +418,15 @@ function FahrzeugBuchungen() {
} }
}; };
// ── Derived date validity (used in availability section + save guard) ─────
const formBeginnDate = form.beginn ? new Date(form.beginn) : null;
const formEndeDate = form.ende ? new Date(form.ende) : null;
const formDatesValid = !!(
formBeginnDate && formEndeDate &&
!isNaN(formBeginnDate.getTime()) && !isNaN(formEndeDate.getTime()) &&
formEndeDate > formBeginnDate
);
// ── Render ──────────────────────────────────────────────────────────────── // ── Render ────────────────────────────────────────────────────────────────
return ( return (
<DashboardLayout> <DashboardLayout>
@@ -870,6 +884,11 @@ function FahrzeugBuchungen() {
{/* Availability indicator */} {/* Availability indicator */}
{form.fahrzeugId && form.beginn && form.ende ? ( {form.fahrzeugId && form.beginn && form.ende ? (
!formDatesValid ? (
<Typography variant="body2" color="error" sx={{ fontSize: '0.75rem' }}>
Ende muss nach dem Beginn liegen
</Typography>
) : (
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}> <Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
{availability === null ? ( {availability === null ? (
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}> <Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
@@ -923,6 +942,7 @@ function FahrzeugBuchungen() {
/> />
)} )}
</Box> </Box>
)
) : ( ) : (
<Typography variant="body2" color="text.secondary" sx={{ fontSize: '0.75rem' }}> <Typography variant="body2" color="text.secondary" sx={{ fontSize: '0.75rem' }}>
Wähle Fahrzeug und Zeitraum für Verfügbarkeitsprüfung Wähle Fahrzeug und Zeitraum für Verfügbarkeitsprüfung