import { IsArray, IsNumber, IsNotEmpty, ValidateNested } from "class-validator"
import { Type } from "class-transformer"
import { ApiProperty } from "@nestjs/swagger"

export class UpdateLeaveBalanceItem {
  @ApiProperty({
    description: "Leave Type ID",
    example: 1,
  })
  @IsNumber()
  @IsNotEmpty()
  leave_type_id: number

  @ApiProperty({
    description: "Year for the leave balance",
    example: 2026,
  })
  @IsNumber()
  @IsNotEmpty()
  year: number

  @ApiProperty({
    description: "Total allocated days",
    example: 10,
  })
  @IsNumber()
  @IsNotEmpty()
  total_allocated: number
}

export class UpdateLeaveBalancesDto {
  @ApiProperty({
    description: "Array of leave balance updates",
    type: [UpdateLeaveBalanceItem],
    example: [
      {
        leave_type_id: 1,
        year: 2026,
        total_allocated: 10,
      },
    ],
  })
  @IsArray()
  @ValidateNested({ each: true })
  @Type(() => UpdateLeaveBalanceItem)
  leave_balances: UpdateLeaveBalanceItem[]
}
