user management ui

This commit is contained in:
yaschalew
2026-07-10 10:41:48 +03:00
parent dcb2d98503
commit 28a20923ff
595 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
import { useQuery } from "@tanstack/react-query";
import { toast } from "sonner";
import { getDashboardStats } from "@/super-admin/services/api/dashboardApi";
import { DashboardStatsDto } from "../types/dashboardStatsDto";
export const useDashboardStats = () => {
const {
data: stats,
isLoading,
isError,
refetch,
} = useQuery({
queryKey: ["dashboardStats"],
queryFn: async (): Promise<DashboardStatsDto> => {
try {
return await getDashboardStats();
} catch (err) {
toast("Failed to fetch dashboard stats. Using mock data.");
return err instanceof Error
? Promise.reject(new Error(err.message))
: Promise.reject(new Error("Failed to fetch dashboard stats."));
// Fallback to mock data if API call fails
}
},
staleTime: 5 * 60 * 1000,
});
return {
stats,
isLoading,
isError,
refetch,
};
};