new features
This commit is contained in:
@@ -234,22 +234,31 @@ function FahrzeugBuchungen() {
|
||||
setAvailability(null);
|
||||
return;
|
||||
}
|
||||
const beginn = new Date(form.beginn);
|
||||
const ende = new Date(form.ende);
|
||||
if (isNaN(beginn.getTime()) || isNaN(ende.getTime()) || ende <= beginn) {
|
||||
setAvailability(null);
|
||||
return;
|
||||
}
|
||||
let cancelled = false;
|
||||
bookingApi
|
||||
.checkAvailability(
|
||||
form.fahrzeugId,
|
||||
new Date(form.beginn),
|
||||
new Date(form.ende),
|
||||
editingBooking?.id
|
||||
)
|
||||
.then((result) => {
|
||||
if (!cancelled) setAvailability(result);
|
||||
})
|
||||
.catch(() => {
|
||||
if (!cancelled) setAvailability(null);
|
||||
});
|
||||
const timer = setTimeout(() => {
|
||||
bookingApi
|
||||
.checkAvailability(
|
||||
form.fahrzeugId,
|
||||
beginn,
|
||||
ende,
|
||||
editingBooking?.id
|
||||
)
|
||||
.then((result) => {
|
||||
if (!cancelled) setAvailability(result);
|
||||
})
|
||||
.catch(() => {
|
||||
if (!cancelled) setAvailability(null);
|
||||
});
|
||||
}, 300);
|
||||
return () => {
|
||||
cancelled = true;
|
||||
clearTimeout(timer);
|
||||
};
|
||||
}, [form.fahrzeugId, form.beginn, form.ende, editingBooking?.id]);
|
||||
|
||||
@@ -698,6 +707,23 @@ function FahrzeugBuchungen() {
|
||||
Von: {detailBooking.gebucht_von_name}
|
||||
</Typography>
|
||||
)}
|
||||
{(() => {
|
||||
const mw = maintenanceWindows.find((w) => w.id === detailBooking.fahrzeug_id);
|
||||
if (mw?.ausser_dienst_von && mw?.ausser_dienst_bis) {
|
||||
const bookingStart = new Date(detailBooking.beginn);
|
||||
const bookingEnd = new Date(detailBooking.ende);
|
||||
const serviceStart = new Date(mw.ausser_dienst_von);
|
||||
const serviceEnd = new Date(mw.ausser_dienst_bis);
|
||||
if (bookingStart < serviceEnd && bookingEnd > serviceStart) {
|
||||
return (
|
||||
<Alert severity="warning" sx={{ mt: 1, py: 0, fontSize: '0.75rem' }}>
|
||||
Fahrzeug außer Dienst: {format(serviceStart, 'dd.MM.')} – {format(serviceEnd, 'dd.MM.yyyy')}
|
||||
</Alert>
|
||||
);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
})()}
|
||||
{(canWrite || (canCancelOwn && detailBooking.gebucht_von === user?.id)) && (
|
||||
<Box sx={{ mt: 1.5, display: 'flex', gap: 1 }}>
|
||||
{canWrite && (
|
||||
|
||||
Reference in New Issue
Block a user