refactor: add useFormatters hook to reduce boilerplate across 14 components
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>
This commit is contained in:
@@ -7,8 +7,8 @@ import {
|
||||
ResponsiveContainer,
|
||||
Tooltip,
|
||||
} from "recharts";
|
||||
import { useFormatters } from "../hooks/useFormatters";
|
||||
import type { SetupItemWithCategory } from "../hooks/useSetups";
|
||||
import { useWeightUnit } from "../hooks/useWeightUnit";
|
||||
import { formatWeight, type WeightUnit } from "../lib/formatters";
|
||||
import { LucideIcon } from "../lib/iconData";
|
||||
|
||||
@@ -143,7 +143,7 @@ function LegendRow({
|
||||
}
|
||||
|
||||
export function WeightSummaryCard({ items }: WeightSummaryCardProps) {
|
||||
const unit = useWeightUnit();
|
||||
const { unit } = useFormatters();
|
||||
const [viewMode, setViewMode] = useState<ViewMode>("category");
|
||||
|
||||
const baseWeight = items.reduce(
|
||||
|
||||
Reference in New Issue
Block a user