import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import {
  IsString,
  IsOptional,
  IsInt,
  Min,
  Max,
  IsDateString,
  IsArray,
  ValidateNested,
  ArrayMinSize,
  MaxLength,
} from 'class-validator';
import { Type } from 'class-transformer';

/**
 * Single entry in a bulk assessment
 */
export class BulkSkillEntryItem {
  @ApiProperty({
    description: 'Employee ID being assessed',
    example: 'clx123abc',
  })
  @IsString()
  employeeId: string;

  @ApiProperty({
    description: 'Skill ID being assessed',
    example: 'clx456def',
  })
  @IsString()
  skillId: string;

  @ApiProperty({
    description: 'Skill level (0-4)',
    example: 2,
    minimum: 0,
    maximum: 4,
  })
  @IsInt()
  @Min(0)
  @Max(4)
  level: number;

  @ApiPropertyOptional({
    description: 'Assessment notes',
    maxLength: 1000,
  })
  @IsOptional()
  @IsString()
  @MaxLength(1000)
  notes?: string;

  @ApiPropertyOptional({
    description: 'Date for next review',
  })
  @IsOptional()
  @IsDateString()
  nextReview?: string;
}

/**
 * DTO for bulk creating/updating skill matrix entries
 */
export class BulkSkillEntryDto {
  @ApiProperty({
    description: 'Array of skill entries to create or update',
    type: [BulkSkillEntryItem],
  })
  @IsArray()
  @ValidateNested({ each: true })
  @ArrayMinSize(1)
  @Type(() => BulkSkillEntryItem)
  entries: BulkSkillEntryItem[];
}
