Created useFormatters() combining useWeightUnit + useCurrency + formatWeight/formatPrice into a single hook returning weight(grams) and price(cents) bound functions plus raw unit and currency values. Updated all 14 consumer files to use the new hook, removing the repeated 4-import + 2-hook-call pattern from each. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
15 lines
420 B
TypeScript
15 lines
420 B
TypeScript
import { formatPrice, formatWeight } from "../lib/formatters";
|
|
import { useCurrency } from "./useCurrency";
|
|
import { useWeightUnit } from "./useWeightUnit";
|
|
|
|
export function useFormatters() {
|
|
const unit = useWeightUnit();
|
|
const currency = useCurrency();
|
|
return {
|
|
weight: (grams: number | null) => formatWeight(grams, unit),
|
|
price: (cents: number | null) => formatPrice(cents, currency),
|
|
unit,
|
|
currency,
|
|
};
|
|
}
|