/**
 * Customer-facing transfer label — mirrors the frontend
 * `formatTransportRowLabel`: "From → To", or "City · 4 h Disposal" for
 * hourly disposal services.
 */
export function transportServiceLabel(
  ts:
    | {
        from_city?: string | null;
        to_city?: string | null;
        duty_type?: string | null;
        duration_hours?: number | string | null;
      }
    | null
    | undefined,
): string {
  if (!ts) return 'Transfer';
  if (ts.duty_type) {
    const hours = ts.duration_hours != null ? Number(ts.duration_hours) : NaN;
    const where = ts.from_city || 'Disposal';
    return Number.isNaN(hours) ? `${where} · Disposal` : `${where} · ${hours} h Disposal`;
  }
  const label = [ts.from_city, ts.to_city].filter(Boolean).join(' → ');
  return label || 'Transfer';
}
