basic booking load behavior

This commit is contained in:
Roland Schneider
2025-12-16 15:31:45 +01:00
parent fe30561a40
commit c26abee957
6 changed files with 82 additions and 19 deletions

View File

@@ -10,6 +10,7 @@ import {
ParseIntPipe,
UseGuards,
ValidationPipe,
ParseDatePipe,
} from '@nestjs/common';
import { CalendarService } from './calendar.service';
import { GetCalendarDto } from './dto/get-calendar.dto';
@@ -99,4 +100,17 @@ export class CalendarController {
) {
return this.calendarService.cancelBooking(bookingId, cancelBookingDto);
}
@Get('bookings/:eventId/:startTime')
getBookings(
@User() user: types.AppUser,
@Param('eventId', ParseIntPipe) eventId: number,
@Param('startTime', new ParseDatePipe()) startTime: Date,
) {
return this.calendarService.getBookings(
user.user!.userId,
eventId,
startTime,
);
}
}

View File

@@ -590,6 +590,31 @@ export class CalendarService {
return this.bookingRepository.save(booking);
}
async getBookings(
userId: number,
eventId: number,
startTime: Date,
): Promise<Booking[]> {
console.info('getBookings', userId, eventId, startTime);
await Promise.resolve();
// const booking = await this.bookingRepository.findOneBy({ id: bookingId });
// if (!booking) {
// throw new NotFoundException(`Booking with ID ${bookingId} not found.`);
// }
// if (booking.canceledAt) {
// throw new BadRequestException('This booking has already been cancelled.');
// }
//
// // Update the booking with cancellation details
// booking.canceledAt = new Date();
// booking.canceledReason = cancelBookingDto.canceledReason || null;
// booking.canceledByUserId = cancelBookingDto.canceledByUserId;
//
// return this.bookingRepository.save(booking);
return [];
}
private isValidOccurrence(event: Event, occurrenceTime: Date): boolean {
console.info(
'[CalendarService] isValidOccurrence called with event:',