vehicle booking bug resolve
This commit is contained in:
@@ -294,6 +294,11 @@ function FahrzeugBuchungen() {
|
||||
setDialogLoading(false);
|
||||
return;
|
||||
}
|
||||
if (endeDate <= beginnDate) {
|
||||
setDialogError('Ende muss nach dem Beginn liegen.');
|
||||
setDialogLoading(false);
|
||||
return;
|
||||
}
|
||||
const payload: CreateBuchungInput = {
|
||||
...form,
|
||||
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 ────────────────────────────────────────────────────────────────
|
||||
return (
|
||||
<DashboardLayout>
|
||||
@@ -870,6 +884,11 @@ function FahrzeugBuchungen() {
|
||||
|
||||
{/* Availability indicator */}
|
||||
{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 }}>
|
||||
{availability === null ? (
|
||||
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
|
||||
@@ -923,6 +942,7 @@ function FahrzeugBuchungen() {
|
||||
/>
|
||||
)}
|
||||
</Box>
|
||||
)
|
||||
) : (
|
||||
<Typography variant="body2" color="text.secondary" sx={{ fontSize: '0.75rem' }}>
|
||||
Wähle Fahrzeug und Zeitraum für Verfügbarkeitsprüfung
|
||||
|
||||
Reference in New Issue
Block a user