import type { VehicleGroup } from "@/lib/fleet/types";

export const GROUP_LABELS: Record<VehicleGroup, string> = {
  bestand: "Bestand",
  vorfuehr: "Vorführwagen",
  ersatz_miet: "Ersatz / Miet",
  pool: "Pool",
};

export const POWERTRAIN_LABELS = {
  BEV: "Elektro",
  PHEV: "Plug-in-Hybrid",
  ICE: "Verbrennung",
} as const;

export function formatKm(meters: number): string {
  return `${Math.round(meters / 1000).toLocaleString("de-DE")} km`;
}

export function formatRelative(iso: string, now = Date.now()): string {
  const mins = Math.round((now - new Date(iso).getTime()) / 60_000);
  if (mins < 1) return "gerade eben";
  if (mins < 60) return `vor ${mins} Min.`;
  const hours = Math.round(mins / 60);
  if (hours < 48) return `vor ${hours} Std.`;
  return `vor ${Math.round(hours / 24)} Tagen`;
}

export function formatPercent(n: number): string {
  return `${Math.round(n)} %`;
}
