import { unitOptions } from "@/utils/data";

/** Default UoM value when company has none set (Sq. Yard) */
export const DEFAULT_UOM_VALUE = "sqyard";

const UOM_DISPLAY_LABELS: Record<string, string> = {
  sqft: "Sq. Ft",
  sqm: "Sq. M",
  sqyard: "Sq. Yard",
  bigha: "Bigha",
  acre: "Acre",
  hectare: "Hectare",
};

/**
 * Returns display label for UoM value (e.g. "Sq. Yard", "Sq. Ft") for use in labels/placeholders.
 * Uses DEFAULT_UOM_VALUE if value is empty.
 */
export function getDefaultUomDisplayLabel(value: string | undefined | null): string {
  const key = (value || DEFAULT_UOM_VALUE).toLowerCase();
  return UOM_DISPLAY_LABELS[key] ?? unitOptions.find((o) => o.value === key)?.label ?? "Sq. Yard";
}

export { unitOptions };
