refactor admin to use eventbus
This commit is contained in:
@@ -9,6 +9,7 @@ import {
|
||||
Query,
|
||||
ParseIntPipe,
|
||||
UseGuards,
|
||||
ValidationPipe,
|
||||
} from '@nestjs/common';
|
||||
import { CalendarService } from './calendar.service';
|
||||
import { GetCalendarDto } from './dto/get-calendar.dto';
|
||||
@@ -18,8 +19,9 @@ import { JwtAuthGuard } from '../auth/jwt-auth.guard';
|
||||
import { RolesGuard } from '../auth/roles.guard';
|
||||
import { Roles } from '../auth/roles.decorator';
|
||||
import { Role } from '../auth/role.enum';
|
||||
import { CreateBookingDto } from './dto/create-booking.dto';
|
||||
import { CalendarCreateBookingDto } from './dto/create-booking.dto';
|
||||
import { CancelBookingDto } from './dto/cancel-booking.dto';
|
||||
import { ApiBody } from '@nestjs/swagger';
|
||||
|
||||
@Controller('calendar')
|
||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||
@@ -73,9 +75,10 @@ export class CalendarController {
|
||||
|
||||
// Create a booking for a specific event occurrence
|
||||
@Post('events/:id/bookings')
|
||||
@ApiBody({ type: CalendarCreateBookingDto })
|
||||
createBooking(
|
||||
@Param('id', ParseIntPipe) eventId: number,
|
||||
@Body() createBookingDto: CreateBookingDto,
|
||||
@Body(new ValidationPipe()) createBookingDto: CalendarCreateBookingDto,
|
||||
) {
|
||||
return this.calendarService.createBooking(eventId, createBookingDto);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import { CreateEventDto } from './dto/create-event.dto';
|
||||
import { CreateExceptionDto } from './dto/create-exception.dto';
|
||||
import { Booking } from '../entity/booking.entity';
|
||||
import { CancelBookingDto } from './dto/cancel-booking.dto';
|
||||
import { CreateBookingDto } from './dto/create-booking.dto';
|
||||
import { CalendarCreateBookingDto } from './dto/create-booking.dto';
|
||||
import { EventType } from '../entity/event-type.entity';
|
||||
|
||||
// --- Type-Safe Maps ---
|
||||
@@ -520,7 +520,7 @@ export class CalendarService {
|
||||
|
||||
async createBooking(
|
||||
eventId: number,
|
||||
createBookingDto: CreateBookingDto,
|
||||
createBookingDto: CalendarCreateBookingDto,
|
||||
): Promise<Booking> {
|
||||
const { occurrenceStartTime, userId } = createBookingDto;
|
||||
|
||||
|
||||
@@ -7,23 +7,28 @@ import {
|
||||
Min,
|
||||
} from 'class-validator';
|
||||
import { Type } from 'class-transformer';
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
|
||||
export class CreateBookingDto {
|
||||
export class CalendarCreateBookingDto {
|
||||
@IsNotEmpty()
|
||||
@Type(() => Date)
|
||||
@IsDate()
|
||||
@ApiProperty()
|
||||
occurrenceStartTime: Date;
|
||||
|
||||
@IsNotEmpty()
|
||||
@IsInt()
|
||||
@ApiProperty()
|
||||
userId: number; // Replaces userName/userEmail
|
||||
|
||||
@IsOptional()
|
||||
@IsInt()
|
||||
@Min(1)
|
||||
@ApiProperty()
|
||||
reservedSeatsCount?: number = 1;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@ApiProperty()
|
||||
notes?: string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user