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

import { WAREHOUSE_TYPES, WarehouseType } from '../entities/warehouse.entity';

export class CreateWarehouseDto {
  @ApiProperty()
  @IsString()
  @MaxLength(160)
  name!: string;

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

  @ApiProperty({ enum: WAREHOUSE_TYPES })
  @IsEnum(WAREHOUSE_TYPES)
  type!: WarehouseType;

  @ApiPropertyOptional({ format: 'uuid' })
  @IsOptional()
  @IsUUID()
  stationId?: string;

  @ApiPropertyOptional({ format: 'uuid', description: 'Parent facility / port this warehouse belongs to.' })
  @IsOptional()
  @IsUUID()
  facilityId?: string;

  @ApiPropertyOptional()
  @IsOptional()
  @IsString()
  @MaxLength(200)
  locationName?: string;

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