import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { IsBoolean, IsIn, IsOptional, IsString, IsUUID, MaxLength } from 'class-validator';

const TRIGGER_CONDITIONS = [
  'CARGO_FLAG_HAZARDOUS',
  'CARGO_FLAG_REEFER',
  'VGM_EXCEEDS_LIMIT',
  'SHIPPING_LINE_MAPPED',
  'CONSOLIDATION_ENABLED',
] as const;

export class CreateSurchargeTypeDto {
  @ApiProperty({ description: 'Human-readable label', maxLength: 100 })
  @IsString()
  @MaxLength(100)
  label!: string;

  @ApiProperty({ enum: TRIGGER_CONDITIONS, description: 'Condition that auto-fires this surcharge' })
  @IsIn([...TRIGGER_CONDITIONS])
  triggerCondition!: string;

  @ApiProperty({ description: 'FK to rates.id — the LIVE rate used to price this surcharge' })
  @IsUUID()
  rateId!: string;

  @ApiPropertyOptional({ default: true })
  @IsOptional()
  @IsBoolean()
  isActive?: boolean;
}
