import { ApiProperty, ApiPropertyOptional, PartialType } from '@nestjs/swagger';
import { IsBoolean, IsInt, IsOptional, IsString } from 'class-validator';

export class CreateAllocationRuleDto {
  @ApiProperty()
  @IsString()
  name!: string;

  @ApiPropertyOptional({ default: 100 })
  @IsOptional()
  @IsInt()
  priority?: number;

  @ApiPropertyOptional()
  @IsOptional()
  @IsString()
  freightType?: string;

  @ApiPropertyOptional()
  @IsOptional()
  @IsString()
  tradeDirection?: string;

  @ApiPropertyOptional()
  @IsOptional()
  @IsString()
  cargoTypeCode?: string;

  @ApiPropertyOptional()
  @IsOptional()
  @IsString()
  containerStatus?: string;

  @ApiPropertyOptional()
  @IsOptional()
  @IsBoolean()
  requiresInspection?: boolean;

  @ApiPropertyOptional()
  @IsOptional()
  @IsString()
  targetFacilityCode?: string;

  @ApiProperty()
  @IsString()
  targetYardCode!: string;

  @ApiPropertyOptional()
  @IsOptional()
  @IsString()
  targetWarehouseCode?: string;

  @ApiPropertyOptional()
  @IsOptional()
  @IsString()
  targetZoneCode?: string;

  @ApiPropertyOptional()
  @IsOptional()
  @IsString()
  storageType?: string;

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

export class UpdateAllocationRuleDto extends PartialType(CreateAllocationRuleDto) {}

export class AllocationPreviewDto {
  @ApiPropertyOptional()
  @IsOptional()
  @IsString()
  freightType?: string;

  @ApiPropertyOptional()
  @IsOptional()
  @IsString()
  tradeDirection?: string;

  @ApiPropertyOptional()
  @IsOptional()
  @IsString()
  cargoTypeCode?: string;

  @ApiPropertyOptional()
  @IsOptional()
  @IsString()
  containerStatus?: string;

  @ApiPropertyOptional()
  @IsOptional()
  @IsBoolean()
  requiresInspection?: boolean;
}
