import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { CargoUnitOfMeasure } from '@edr/types';
import { IsBoolean, IsEnum, IsInt, IsOptional, IsString, IsUUID, MaxLength, Min } from 'class-validator';

export class CreateCargoTypeDto {
  @ApiProperty({ description: 'Cargo type display name', maxLength: 255 })
  @IsString()
  @MaxLength(255)
  cargoTypeName!: string;

  @ApiPropertyOptional({
    enum: CargoUnitOfMeasure,
    description: 'How this cargo is measured (PER_TON for bulk, PER_ITEM for break-bulk)',
  })
  @IsOptional()
  @IsEnum(CargoUnitOfMeasure)
  unitOfMeasure?: CargoUnitOfMeasure;

  @ApiPropertyOptional({ description: 'Parent group ID for hierarchical cargo types' })
  @IsOptional()
  @IsUUID()
  parentGroupId?: string;

  @ApiPropertyOptional({ default: false })
  @IsOptional()
  @IsBoolean()
  showFreeTextBox?: boolean;

  @ApiPropertyOptional({ default: false })
  @IsOptional()
  @IsBoolean()
  requiresDirectorApproval?: boolean;

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

  @ApiPropertyOptional({ default: 1 })
  @IsOptional()
  @IsInt()
  @Min(1)
  displayOrder?: number;

  @ApiPropertyOptional({ description: 'Insert after this record ID' })
  @IsOptional()
  @IsUUID('4')
  insertAfterId?: string;
}
