feat(01-03): add data hooks, utilities, UI store, and foundational components

- API fetch wrapper with error handling and multipart upload
- Weight/price formatters for display
- TanStack Query hooks for items, categories, and totals with cache invalidation
- Zustand UI store for panel and confirm dialog state
- TotalsBar, CategoryHeader, ItemCard, ConfirmDialog, ImageUpload components

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-14 22:44:48 +01:00
parent a5df33a2d8
commit b099a47eb4
11 changed files with 647 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
import { useQuery } from "@tanstack/react-query";
import { apiGet } from "../lib/api";
interface CategoryTotals {
categoryId: number;
categoryName: string;
categoryEmoji: string;
totalWeight: number;
totalCost: number;
itemCount: number;
}
interface GlobalTotals {
totalWeight: number;
totalCost: number;
itemCount: number;
}
interface TotalsResponse {
categories: CategoryTotals[];
global: GlobalTotals;
}
export type { CategoryTotals, GlobalTotals, TotalsResponse };
export function useTotals() {
return useQuery({
queryKey: ["totals"],
queryFn: () => apiGet<TotalsResponse>("/api/totals"),
});
}