feat(07-01): create useWeightUnit convenience hook
- Wraps useSetting("weightUnit") with typed WeightUnit return
- Validates stored value against known units (g, oz, lb, kg)
- Defaults to "g" when no setting exists (backward compatible)
- Fix config.json formatting (tabs per biome config)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
"commit_docs": true,
|
"commit_docs": true,
|
||||||
"model_profile": "quality",
|
"model_profile": "quality",
|
||||||
"workflow": {
|
"workflow": {
|
||||||
"research": false,
|
"research": true,
|
||||||
"plan_check": true,
|
"plan_check": true,
|
||||||
"verifier": true,
|
"verifier": true,
|
||||||
"nyquist_validation": true,
|
"nyquist_validation": true,
|
||||||
|
|||||||
12
src/client/hooks/useWeightUnit.ts
Normal file
12
src/client/hooks/useWeightUnit.ts
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
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";
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user