update
This commit is contained in:
@@ -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' });
|
||||
|
||||
Reference in New Issue
Block a user