remove monitorHooks

This commit is contained in:
Alex Holliday committed 2026-02-09 23:16:14 +00:00
1 parent 3d1bd94279
commit 2091d8dcd7
7 files changed
+48 -609

No files matched your search

+34
View File
@@ -179,3 +179,37 @@ export const useDelete = <R = any>() => {
return { deleteFn, loading, error };
};
export const useLazyGet = <R = any>() => {
const [loading, setLoading] = useState(false);
const [error, setError] = useState<string | null>(null);
const { toastError } = useToast();
const getFn = async (
endpoint: string,
config?: AxiosRequestConfig
): Promise<ApiResponse<R> | null> => {
setLoading(true);
setError(null);
try {
const res = await get<ApiResponse<R>>(endpoint, {
...config,
headers: {
...config?.headers,
},
});
return res.data;
} catch (err: any) {
console.error(err);
const errMsg = err?.response?.data?.msg || err.message || "An error occurred";
toastError(errMsg);
setError(errMsg);
return null;
} finally {
setLoading(false);
}
};
return { get: getFn, loading, error };
};