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