import type { Freight } from "@edr/types";

/** Human-readable label for a contract unit-rate's charge unit. */
export function formatRateUnit(unit: Freight.ContractRateUnit | string): string {
  const map: Record<string, string> = {
    per_container: "container",
    per_wagon: "wagon",
    per_ton: "ton",
    per_item: "item",
    per_km: "km",
    flat: "flat",
  };
  return map[unit] ?? unit.replace(/_/g, " ").replace(/^per /, "");
}
