refactor: streamline Booking module and service by removing unused imports and consolidating space validation logic

This commit is contained in:
faris Aljohari
2025-06-18 01:49:00 -06:00
parent df59e9a4a3
commit 274cdf741f
3 changed files with 55 additions and 75 deletions

View File

@ -1,7 +1,6 @@
// dtos/bookable-space.dto.ts
import { DaysEnum } from '@app/common/constants/days.enum';
import { ApiProperty } from '@nestjs/swagger';
import { Type } from 'class-transformer';
import {
IsArray,
IsEnum,
@ -9,15 +8,26 @@ import {
IsString,
IsUUID,
IsInt,
ValidateNested,
ArrayMinSize,
ArrayMaxSize,
Min,
Max,
Min,
Matches,
} from 'class-validator';
export class BookingSlotDto {
export class CreateBookableSpaceDto {
@ApiProperty({
type: 'string',
isArray: true,
example: [
'3fa85f64-5717-4562-b3fc-2c963f66afa6',
'4fa85f64-5717-4562-b3fc-2c963f66afa7',
],
})
@IsArray()
@ArrayMinSize(1, { message: 'At least one space must be selected' })
@IsUUID('all', { each: true, message: 'Invalid space UUID provided' })
spaceUuids: string[];
@ApiProperty({
enum: DaysEnum,
isArray: true,
@ -25,7 +35,6 @@ export class BookingSlotDto {
})
@IsArray()
@ArrayMinSize(1, { message: 'At least one day must be selected' })
@ArrayMaxSize(7, { message: 'Cannot select more than 7 days' })
@IsEnum(DaysEnum, { each: true, message: 'Invalid day provided' })
daysAvailable: DaysEnum[];
@ -45,31 +54,9 @@ export class BookingSlotDto {
})
endTime: string;
@ApiProperty({ example: 10, minimum: 0 })
@ApiProperty({ example: 10 })
@IsInt()
@Min(0, { message: 'Points cannot be negative' })
@Max(1000, { message: 'Points cannot exceed 1000' })
points: number;
}
export class CreateBookableSpaceDto {
@ApiProperty({
type: 'string',
isArray: true,
example: [
'3fa85f64-5717-4562-b3fc-2c963f66afa6',
'4fa85f64-5717-4562-b3fc-2c963f66afa7',
],
})
@IsArray()
@ArrayMinSize(1, { message: 'At least one space must be selected' })
@IsUUID('all', { each: true, message: 'Invalid space UUID provided' })
spaceUuids: string[];
@ApiProperty({ type: BookingSlotDto, isArray: true })
@IsArray()
@ArrayMinSize(1, { message: 'At least one booking slot must be provided' })
@ValidateNested({ each: true })
@Type(() => BookingSlotDto)
slots: BookingSlotDto[];
}