import {
  IsUUID,
  IsNotEmpty,
  IsOptional,
  IsDateString,
  IsBoolean,
  Matches,
} from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';

export class CreateWorkScheduleDto {
  @ApiPropertyOptional({
    description:
      'UUID of the trainer. Defaults to current user for TRAINER role.',
    example: '550e8400-e29b-41d4-a716-446655440000',
  })
  @IsUUID()
  @IsOptional()
  trainerId?: string;

  @ApiProperty({
    description: 'Date of the work schedule entry (ISO date string)',
    example: '2026-03-01',
  })
  @IsDateString()
  @IsNotEmpty()
  date: string;

  @ApiProperty({
    description: 'Start time in HH:mm format',
    example: '09:00',
  })
  @Matches(/^([01]\d|2[0-3]):([0-5]\d)$/, {
    message: 'startTime must be in HH:mm format (e.g. "09:00")',
  })
  @IsNotEmpty()
  startTime: string;

  @ApiProperty({
    description: 'End time in HH:mm format',
    example: '18:00',
  })
  @Matches(/^([01]\d|2[0-3]):([0-5]\d)$/, {
    message: 'endTime must be in HH:mm format (e.g. "18:00")',
  })
  @IsNotEmpty()
  endTime: string;

  @ApiPropertyOptional({
    description: 'Whether the trainer is available on this schedule',
    default: true,
  })
  @IsBoolean()
  @IsOptional()
  isAvailable?: boolean = true;
}
