feat(frontend): add React UI — procurement office, wizard, suppliers, inventory panel (dash port), role-based login

This commit is contained in:
ali_mohaghegh
2026-08-25 19:08:15 +03:30
parent 170aed66ea
commit 4e105c5cd5
103 changed files with 16352 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
// ============================================================
// پایه‌ی داده: یک query واحد که کل store را لود می‌کند
// ============================================================
import { useEffect } from "react";
import { useCallback } from "react";
import { useQuery, useQueryClient } from "@tanstack/react-query";
import { api } from "../lib/api";
import { useAppStore } from "../store";
export const STORE_KEY = ["store"] as const;
// یک بار در ریشه‌ی برنامه صدا زده می‌شود: لود + mirror در Zustand
export function useStoreData(): void {
const setData = useAppStore((s) => s.setData);
const { data } = useQuery({
queryKey: STORE_KEY,
queryFn: () => api.listAll(),
staleTime: Infinity,
});
useEffect(() => {
if (data) setData(data);
}, [data, setData]);
}
// بعد از هر mutation برای همگرایی با حقیقت
export function useInvalidateStore(): () => void {
const qc = useQueryClient();
return useCallback(() => {
void qc.invalidateQueries({ queryKey: STORE_KEY });
}, [qc]);
}