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

export enum TrainingStatus {
  PLANNED = 'PLANNED',
  CONFIRMED = 'CONFIRMED',
  PAID = 'PAID',
  NOT_PAID = 'NOT_PAID',
  NO_SHOW = 'NO_SHOW',
  CANCELLED = 'CANCELLED',
}

export class FindTrainingsDto {
  @ApiPropertyOptional({
    description: 'Cursor for pagination (UUID of last item)',
    example: '550e8400-e29b-41d4-a716-446655440000',
  })
  @IsUUID()
  @IsOptional()
  cursor?: string;

  @ApiPropertyOptional({
    description: 'Number of items to return (1-100)',
    default: 20,
    minimum: 1,
    maximum: 100,
  })
  @Type(() => Number)
  @IsInt()
  @Min(1)
  @Max(100)
  @IsOptional()
  limit?: number = 20;

  @ApiPropertyOptional({
    description: 'Filter by trainer UUID',
    example: '550e8400-e29b-41d4-a716-446655440000',
  })
  @IsUUID()
  @IsOptional()
  trainerId?: string;

  @ApiPropertyOptional({
    description: 'Filter by client UUID',
    example: '550e8400-e29b-41d4-a716-446655440001',
  })
  @IsUUID()
  @IsOptional()
  clientId?: string;

  @ApiPropertyOptional({
    description: 'Filter trainings from this date (ISO)',
    example: '2026-03-01',
  })
  @IsDateString()
  @IsOptional()
  dateFrom?: string;

  @ApiPropertyOptional({
    description: 'Filter trainings up to this date (ISO)',
    example: '2026-03-31',
  })
  @IsDateString()
  @IsOptional()
  dateTo?: string;

  @ApiPropertyOptional({
    description: 'Filter by training status',
    enum: TrainingStatus,
  })
  @IsEnum(TrainingStatus)
  @IsOptional()
  status?: TrainingStatus;
}
