community templates (#691)

This commit is contained in:
Will Chen
2025-07-23 10:11:16 -07:00
committed by GitHub
parent 9edd0fa80f
commit e947eede7a
37 changed files with 544 additions and 135 deletions

24
src/hooks/useTemplates.ts Normal file
View File

@@ -0,0 +1,24 @@
import { useQuery } from "@tanstack/react-query";
import { IpcClient } from "@/ipc/ipc_client";
import { localTemplatesData, type Template } from "@/shared/templates";
export function useTemplates() {
const query = useQuery({
queryKey: ["templates"],
queryFn: async (): Promise<Template[]> => {
const ipcClient = IpcClient.getInstance();
return ipcClient.getTemplates();
},
initialData: localTemplatesData,
meta: {
showErrorToast: true,
},
});
return {
templates: query.data,
isLoading: query.isLoading,
error: query.error,
refetch: query.refetch,
};
}