import { ApiPropertyOptional } from '@nestjs/swagger';
import {
  IsEnum,
  IsString,
  IsOptional,
  IsDateString,
  IsNumber,
  Min,
  MaxLength,
} from 'class-validator';
import { AbsenceType } from '@prisma/client';

export class UpdateAbsenceDto {
  @ApiPropertyOptional({
    description: 'Type of absence',
    enum: AbsenceType,
    example: AbsenceType.VACATION,
  })
  @IsOptional()
  @IsEnum(AbsenceType)
  type?: AbsenceType;

  @ApiPropertyOptional({
    description: 'Start date of the absence (ISO 8601 format)',
    example: '2024-03-15',
  })
  @IsOptional()
  @IsDateString()
  startDate?: string;

  @ApiPropertyOptional({
    description: 'End date of the absence (ISO 8601 format)',
    example: '2024-03-20',
  })
  @IsOptional()
  @IsDateString()
  endDate?: string;

  @ApiPropertyOptional({
    description: 'Number of days (recalculated if dates change)',
    example: 5,
    minimum: 0.5,
  })
  @IsOptional()
  @IsNumber()
  @Min(0.5)
  days?: number;

  @ApiPropertyOptional({
    description: 'Optional note or reason for the absence',
    example: 'Updated vacation reason',
    maxLength: 1000,
  })
  @IsOptional()
  @IsString()
  @MaxLength(1000)
  note?: string;
}
