import useSWR, { mutate } from "swr"; import { fetcher } from "./fetcher"; type FileDifference = { type: string; value: { type: string; path: string; }[]; }; export function useDifferenceDoc() { return useSWR("/api/diff/list", fetcher); } export async function commit(path: string, type: string) { const data = await fetcher("/api/diff/commit", { method: "POST", body: JSON.stringify([{ path, type }]), headers: { "Content-Type": "application/json", }, }); mutate("/api/diff/list"); return data; } export async function commitAll(type: string) { const data = await fetcher("/api/diff/commitall", { method: "POST", body: JSON.stringify({ type }), headers: { "Content-Type": "application/json", }, }); mutate("/api/diff/list"); return data; }