mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 16:23:06 +10:00
♻️ 🧹 upsert reciient, deleteRecipient, send
This commit is contained in:
32
packages/lib/api/sendSigningRequests.ts
Normal file
32
packages/lib/api/sendSigningRequests.ts
Normal file
@ -0,0 +1,32 @@
|
||||
import toast from "react-hot-toast";
|
||||
|
||||
export const sendSigningRequests = async (
|
||||
document: any,
|
||||
resendTo: number[] = []
|
||||
) => {
|
||||
if (!document || !document.id) return;
|
||||
try {
|
||||
const sent = await toast.promise(
|
||||
fetch(`/api/documents/${document.id}/send`, {
|
||||
body: JSON.stringify({ resendTo: resendTo }),
|
||||
headers: { "Content-Type": "application/json" },
|
||||
method: "POST",
|
||||
})
|
||||
.then((res: any) => {
|
||||
if (!res.ok) {
|
||||
throw new Error(res.status.toString());
|
||||
}
|
||||
})
|
||||
.finally(() => {
|
||||
location.reload();
|
||||
}),
|
||||
{
|
||||
loading: "Sending...",
|
||||
success: `Sent!`,
|
||||
error: "Could not send :/",
|
||||
}
|
||||
);
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user