import { Type } from "class-transformer";
import {
  ArrayMinSize,
  IsArray,
  IsDateString,
  IsOptional,
  ValidateNested,
} from "class-validator";
import { ApiPropertyOptional } from "@nestjs/swagger";
import { ManualPerformanceSetDto } from "./create-manual-performance.dto";

// Edit a single manual performance entry: re-submit the sets (only the best is
// kept) and/or change the date.
export class UpdateManualPerformanceDto {
  @ApiPropertyOptional({
    type: [ManualPerformanceSetDto],
    description: "One or more sets — only the strongest set is saved",
  })
  @IsOptional()
  @IsArray()
  @ArrayMinSize(1)
  @ValidateNested({ each: true })
  @Type(() => ManualPerformanceSetDto)
  sets?: ManualPerformanceSetDto[];

  @ApiPropertyOptional({ example: "2025-06-18", description: "New date for this entry" })
  @IsOptional()
  @IsDateString()
  date?: string;
}
