import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { IsString, IsNotEmpty, IsNumber, IsOptional } from 'class-validator';

/**
 * DTO for updating a commission contract.
 *
 * This DTO allows partial updates to a commission contract's details,
 * such as its name, order, and active status. All fields are optional,
 * so only the fields provided in the request will be updated.
 */
export class UpdateCommissionContractDto {
  /**
   * Name of the commission contract.
   * Optional field. If provided, it must be a string.
   *
   * Example: "Standard Commission Contract"
   */
  @IsOptional()
  @IsString({ message: 'Name must be a string' })
  @ApiPropertyOptional({
    description: 'Name of the commission contract',
    example: 'Standard Commission Contract',
  })
  name?: string;

  /**
   * Display or processing order of the commission contract.
   * Optional field. If provided, it must be a number.
   * Default value is 0.
   *
   * Example: 5
   */
  @IsOptional()
  @IsNumber({}, { message: 'Order must be a number' })
  @ApiPropertyOptional({
    description: 'Order of the commission contract',
    example: 5,
    default: 0,
  })
  order?: number;

  /**
   * Status indicating whether the contract is active.
   * Optional field. If provided, it must be a number (e.g., 0 for inactive, 1 for active).
   * Default value is 0 (inactive).
   *
   * Example: 1
   */
  @IsOptional()
  @IsNumber({}, { message: 'Active must be a number' })
  @ApiPropertyOptional({
    description: 'Active status of the contract (0 = inactive, 1 = active)',
    example: 1,
    default: 0,
  })
  active?: number;
}
