import { ApiProperty } from '@nestjs/swagger';
import { IsEnum, IsNotEmpty, IsArray } from 'class-validator';
import { StatusAction } from 'src/utils/enums/enum';

/**
 * DTO for updating the status of one or more contracts.
 *
 * This DTO is used when performing bulk or single actions such as activating
 * or deactivating contracts based on their IDs.
 */
export class UpdateContractStatusDto {
  /**
   * The action to perform on the selected contracts.
   * Must be one of the values defined in the StatusAction enum.
   *
   * Example values: 'activate', 'deactivate'
   */
  @IsNotEmpty({ message: 'Action is required' })
  @IsEnum(StatusAction, {
    message: 'Action must be either "activate" or "deactivate"',
  })
  @ApiProperty({
    enum: StatusAction,
    description: 'Action to perform on contracts (activate/deactivate)',
  })
  action: StatusAction;

  /**
   * Array of contract IDs on which the action should be applied.
   * Must contain at least one numeric ID.
   *
   * Example: [1, 2, 3]
   */
  @IsNotEmpty({ message: 'At least one contract ID is required' })
  @IsArray({ message: 'IDs must be provided as an array' })
  @ApiProperty({
    type: [Number],
    description: 'Array of contract IDs to apply the action',
    example: [101, 102, 103],
  })
  ids: number[];
}
