mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 16:23:06 +10:00
37 lines
1.0 KiB
TypeScript
37 lines
1.0 KiB
TypeScript
import prisma from "@documenso/prisma";
|
|
import { sendMail } from "./sendMail";
|
|
import { SendStatus, DocumentStatus } from "@prisma/client";
|
|
import { NEXT_PUBLIC_WEBAPP_URL } from "../constants";
|
|
import { transactionEmailTemplate } from "@documenso/lib/mail";
|
|
|
|
export const sendSigningRequest = async (recipient: any, document: any) => {
|
|
// todo errror handling
|
|
await sendMail(
|
|
document.User.email,
|
|
`Please sign ${document.title}`,
|
|
transactionEmailTemplate(
|
|
`${document.User.name} (${document.User.email}) has sent you a document to sign. `,
|
|
document,
|
|
recipient,
|
|
`${NEXT_PUBLIC_WEBAPP_URL}/documents/${document.id}/sign?token=${recipient.token}`,
|
|
`Sign Document`
|
|
)
|
|
).catch((err) => {
|
|
console.log("catch 1");
|
|
throw err;
|
|
});
|
|
await prisma.recipient.update({
|
|
where: {
|
|
id: recipient.id,
|
|
},
|
|
data: { sendStatus: SendStatus.SENT },
|
|
});
|
|
|
|
await prisma.document.update({
|
|
where: {
|
|
id: document.id,
|
|
},
|
|
data: { status: DocumentStatus.PENDING },
|
|
});
|
|
};
|