import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { IsArray, IsBoolean, IsInt, 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;

  @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({
    type: [String],
    format: 'uuid',
    description:
      'Wagon types that can carry this container. Drives train scheduling wagon-type resolution; at least one is required when this container type is scheduled.',
  })
  @IsOptional()
  @IsArray()
  @IsUUID('4', { each: true })
  wagonTypeIds?: string[];

  @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;
}
