import {
  IsUUID,
  IsNotEmpty,
  IsOptional,
  IsDateString,
  IsInt,
  IsBoolean,
  Min,
  Max,
} from 'class-validator';
import { Type } from 'class-transformer';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';

export class CreateTrainingDto {
  @ApiProperty({
    description: 'UUID of the client for this training',
    example: '550e8400-e29b-41d4-a716-446655440000',
  })
  @IsUUID()
  @IsNotEmpty()
  clientId: string;

  @ApiPropertyOptional({
    description:
      'UUID of the trainer. Required for receptionist/coordinator/manager roles',
    example: '550e8400-e29b-41d4-a716-446655440003',
  })
  @IsUUID()
  @IsOptional()
  trainerId?: string;

  @ApiPropertyOptional({
    description: 'UUID of the service type',
    example: '550e8400-e29b-41d4-a716-446655440001',
  })
  @IsUUID()
  @IsOptional()
  serviceId?: string;

  @ApiPropertyOptional({
    description: 'UUID of the room',
    example: '550e8400-e29b-41d4-a716-446655440002',
  })
  @IsUUID()
  @IsOptional()
  roomId?: string;

  @ApiProperty({
    description: 'Scheduled date and time in ISO format',
    example: '2026-03-01T10:00:00.000Z',
  })
  @IsDateString()
  @IsNotEmpty()
  scheduledAt: string;

  @ApiPropertyOptional({
    description: 'Duration in minutes (15-480)',
    default: 60,
    minimum: 15,
    maximum: 480,
  })
  @Type(() => Number)
  @IsInt()
  @Min(15)
  @Max(480)
  @IsOptional()
  duration?: number = 60;

  @ApiPropertyOptional({
    description: 'Whether this training repeats weekly',
    default: false,
  })
  @IsBoolean()
  @IsOptional()
  isRepeating?: boolean = false;

  @ApiPropertyOptional({
    description: 'Number of weekly repetitions (1-52)',
    minimum: 1,
    maximum: 52,
  })
  @Type(() => Number)
  @IsInt()
  @Min(1)
  @Max(52)
  @IsOptional()
  repeatCount?: number;
}
