import { useCallback, useState } from "react"; import useSWR, { mutate, useSWRConfig } from "swr"; import type { Template, TemplateMeta, TemplateImage } from "./types"; import { fetchApi, type ApiError } from "@/api"; function useTemplates() { return useSWR( "/templates", async (): Promise => fetchApi("/templates").then((res) => res.json()), ); } function useTemplate(name: string) { return useSWR( ["/templates", name], async (): Promise