import { ApiProperty } from '@nestjs/swagger';
import { Transform } from 'class-transformer';
import { IsDateString, IsEnum } from 'class-validator';

import { ProgressReportDeadlineSlot } from '@/generated/prisma/client';

// This endpoint fills the later slots only. FIRST is created together with the
// progress report, so the service rejects it here.
export class CreateProgressReportDeadlineDto {
  @ApiProperty({
    enum: ProgressReportDeadlineSlot,
    description: 'Use SECOND or FINAL. FIRST comes from the report form.',
  })
  @Transform(({ value }) =>
    typeof value === 'string' ? value.trim().toUpperCase() : value,
  )
  @IsEnum(ProgressReportDeadlineSlot)
  slot!: ProgressReportDeadlineSlot;

  @ApiProperty({
    example: '2026-07-31',
    description: 'Deadline date in YYYY-MM-DD format.',
  })
  @IsDateString()
  deadline!: string;
}
