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

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

  @IsNumber()
  @Min(0)
  distanceKm!: number;
}

/** Per-vehicle actual distances for a last-mile delivery (multi-truck). */
export class SetDistancesDto {
  @IsArray()
  @ValidateNested({ each: true })
  @Type(() => VehicleDistanceInput)
  distances!: VehicleDistanceInput[];

  /** Recomputed remaining payment (total km × rate), from the client. */
  @IsOptional()
  @IsNumber()
  remainingPayment?: number;
}
