import { IsArray, IsNumber, IsOptional, IsString, IsUUID, Min, ValidateNested } from 'class-validator';
import { Type } from 'class-transformer';

export class FirstMileVehicleInput {
  @IsUUID()
  vehicleId!: string;

  @IsOptional()
  @IsString()
  containerNumber?: string;

  /** Bulk: tonnage this truck hauls. */
  @IsOptional()
  @IsNumber()
  @Min(0)
  tons?: number;

  /** Bulk: optional item/piece count. */
  @IsOptional()
  @IsNumber()
  @Min(0)
  quantity?: number;
}

/** Replace the full set of vehicles (with their container numbers) on a pickup. */
export class SetVehiclesDto {
  @IsArray()
  @ValidateNested({ each: true })
  @Type(() => FirstMileVehicleInput)
  vehicles!: FirstMileVehicleInput[];
}
