import type { WeightUnit } from "../lib/formatters";
import { useSetting } from "./useSettings";

const VALID_UNITS: WeightUnit[] = ["g", "oz", "lb", "kg"];

export function useWeightUnit(): WeightUnit {
	const { data } = useSetting("weightUnit");
	if (data && VALID_UNITS.includes(data as WeightUnit)) {
		return data as WeightUnit;
	}
	return "g";
}
