This commit is contained in:
Matthias Hochmeister
2026-03-16 15:01:09 +01:00
parent 3c72fe627f
commit f3ad989a9e
28 changed files with 794 additions and 52 deletions

View File

@@ -1,6 +1,7 @@
import { Request, Response } from 'express';
import { ZodError } from 'zod';
import bookingService from '../services/booking.service';
import vehicleService from '../services/vehicle.service';
import {
CreateBuchungSchema,
UpdateBuchungSchema,
@@ -52,12 +53,13 @@ class BookingController {
res.status(400).json({ success: false, message: 'from und to sind erforderlich' });
return;
}
const bookings = await bookingService.getBookingsByRange(
new Date(from as string),
new Date(to as string),
fahrzeugId as string | undefined
);
res.json({ success: true, data: bookings });
const fromDate = new Date(from as string);
const toDate = new Date(to as string);
const [bookings, maintenanceWindows] = await Promise.all([
bookingService.getBookingsByRange(fromDate, toDate, fahrzeugId as string | undefined),
vehicleService.getMaintenanceWindows(fromDate, toDate),
]);
res.json({ success: true, data: { bookings, maintenanceWindows } });
} catch (error) {
logger.error('Booking getCalendarRange error', { error });
res.status(500).json({ success: false, message: 'Buchungen konnten nicht geladen werden' });