mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-01 17:53:11 +00:00
22 lines
726 B
TypeScript
22 lines
726 B
TypeScript
import type { VendorDropdownItem } from "@/domain/work-orders/types/work-order-common";
|
|
|
|
export function formatVendorDistance(miles: number | null | undefined): string {
|
|
if (miles == null || Number.isNaN(miles)) {
|
|
return "";
|
|
}
|
|
|
|
const rounded = Number.isInteger(miles) ? String(miles) : miles.toFixed(1);
|
|
return `${rounded} mi`;
|
|
}
|
|
|
|
/** Dropdown label: `contactName · companyName` (matches technician select UI). */
|
|
export function formatVendorTechnicianLabel(vendor: VendorDropdownItem): string {
|
|
const contact = vendor.contactName.trim();
|
|
const company = vendor.companyName.trim();
|
|
|
|
if (contact && company && contact !== company) {
|
|
return `${contact} · ${company}`;
|
|
}
|
|
|
|
return contact || company;
|
|
}
|