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:
25
src/client/stores/uiStore.ts
Normal file
25
src/client/stores/uiStore.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { create } from "zustand";
|
||||
|
||||
interface UIState {
|
||||
panelMode: "closed" | "add" | "edit";
|
||||
editingItemId: number | null;
|
||||
confirmDeleteItemId: number | null;
|
||||
|
||||
openAddPanel: () => void;
|
||||
openEditPanel: (itemId: number) => void;
|
||||
closePanel: () => void;
|
||||
openConfirmDelete: (itemId: number) => void;
|
||||
closeConfirmDelete: () => void;
|
||||
}
|
||||
|
||||
export const useUIStore = create<UIState>((set) => ({
|
||||
panelMode: "closed",
|
||||
editingItemId: null,
|
||||
confirmDeleteItemId: null,
|
||||
|
||||
openAddPanel: () => set({ panelMode: "add", editingItemId: null }),
|
||||
openEditPanel: (itemId) => set({ panelMode: "edit", editingItemId: itemId }),
|
||||
closePanel: () => set({ panelMode: "closed", editingItemId: null }),
|
||||
openConfirmDelete: (itemId) => set({ confirmDeleteItemId: itemId }),
|
||||
closeConfirmDelete: () => set({ confirmDeleteItemId: null }),
|
||||
}));
|
||||
Reference in New Issue
Block a user