다시 작업. 디자인도 바꾸고 서버도 바꿈. Co-authored-by: monoid <jaeung@prelude.duckdns.org> Reviewed-on: https://git.prelude.duckdns.org/monoid/ionian/pulls/6
38 lines
No EOL
914 B
TypeScript
38 lines
No EOL
914 B
TypeScript
import useSWR, { mutate } from "swr";
|
|
import { fetcher } from "./fetcher";
|
|
|
|
type FileDifference = {
|
|
type: string;
|
|
value: {
|
|
type: string;
|
|
path: string;
|
|
}[];
|
|
};
|
|
|
|
export function useDifferenceDoc() {
|
|
return useSWR<FileDifference[]>("/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;
|
|
} |