Files
documenso/packages/lib/api/signDocument.ts
Timur Ercan 9741959d09 ♻️ sig document to api
2023-02-28 19:53:22 +01:00

26 lines
606 B
TypeScript

import { useRouter } from "next/router";
import toast from "react-hot-toast";
export const signDocument = (
document: any,
signatures: any[],
token: string
): Promise<any> => {
const body = { documentId: document.id, signatures };
return toast.promise(
fetch(`/api/documents/${document.id}/sign?token=${token}`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(body),
}),
{
loading: "Signing...",
success: `"${document.title}" signed successfully.`,
error: "Could not sign :/",
}
);
};