import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { Transform } from 'class-transformer';
import { IsBoolean, IsInt, IsNumber, IsOptional, IsString, IsUUID, Max, MaxLength, Min } from 'class-validator';

export class CreateContainerTypeDto {
  @ApiProperty({ description: 'Customer-facing label, e.g. "20ft Dry Container"', maxLength: 100 })
  @IsString()
  @MaxLength(100)
  label!: string;

  @ApiProperty({ description: 'Container size in feet: 20 or 40', enum: [20, 40] })
  @IsInt()
  @Min(20)
  @Max(40)
  sizeFt!: number;

  @ApiProperty({ description: 'Wagon fraction per container: 0.50 for 20ft, 1.00 for 40ft' })
  @IsNumber()
  @Min(0.01)
  @Transform(({ value }) => Number(value))
  wagonsPerUnit!: number;

  @ApiPropertyOptional({ default: false, description: 'True if this is a reefer (refrigerated) container' })
  @IsOptional()
  @IsBoolean()
  isReefer?: boolean;

  @ApiPropertyOptional({ default: false, description: 'True if this is an open-top container' })
  @IsOptional()
  @IsBoolean()
  isOpenTop?: boolean;

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

  @ApiPropertyOptional({ default: 1, description: 'UI display sort order' })
  @IsOptional()
  @IsInt()
  @Min(1)
  displayOrder?: number;

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