Finish basic list views

This commit is contained in:
hzrd149
2023-08-24 09:06:13 -05:00
parent d6f86d4511
commit 850e1914fb
21 changed files with 295 additions and 264 deletions

View File

@@ -0,0 +1,14 @@
import { useToast } from "@chakra-ui/react";
import { DependencyList, useCallback } from "react";
export default function useAsyncErrorHandler<T = any>(fn: () => Promise<T>, deps: DependencyList = []): () => Promise<T | undefined> {
const toast = useToast();
return useCallback(async () => {
try {
return await fn();
} catch (e) {
if (e instanceof Error) toast({ description: e.message, status: "error" });
}
}, deps);
}