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

import { WAREHOUSE_YARD_TYPES, WarehouseYardType } from '../entities/warehouse-yard.entity';

export class CreateWarehouseYardDto {
  @ApiPropertyOptional({ format: 'uuid', description: 'Optional — taken from the route param when omitted' })
  @IsOptional()
  @IsUUID()
  warehouseId?: string;

  @ApiProperty()
  @IsString()
  @MaxLength(160)
  name!: string;

  @ApiProperty()
  @IsString()
  @MaxLength(40)
  code!: string;

  @ApiProperty({ enum: WAREHOUSE_YARD_TYPES })
  @IsEnum(WAREHOUSE_YARD_TYPES)
  type!: WarehouseYardType;

  @ApiPropertyOptional()
  @IsOptional()
  @IsNumber()
  @Min(0)
  capacityWeight?: number;

  @ApiPropertyOptional()
  @IsOptional()
  @IsNumber()
  @Min(0)
  capacityContainers?: number;

  @ApiPropertyOptional({ description: 'Max weight capacity (kg). Defaults to capacityWeight.' })
  @IsOptional()
  @IsNumber()
  @Min(0)
  maxWeight?: number;

  @ApiPropertyOptional({ description: 'Max volume capacity (m³).' })
  @IsOptional()
  @IsNumber()
  @Min(0)
  maxVolume?: number;
}
