mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 08:13:56 +10:00
♻️ sig document to api
This commit is contained in:
25
packages/lib/api/signDocument.ts
Normal file
25
packages/lib/api/signDocument.ts
Normal file
@ -0,0 +1,25 @@
|
||||
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 :/",
|
||||
}
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user