import prisma from "@documenso/prisma";
import { sendMail } from "./sendMail";
import { SendStatus, DocumentStatus } from "@prisma/client";
import { NEXT_PUBLIC_WEBAPP_URL } from "../constants";
export const sendSigningRequest = async (recipient: any, document: any) => {
// todo errror handling
await sendMail(
"timur.ercan31+234234@gmail.com",
`Please sign ${document.title}`,
`

${document.User.name} (${document.User.email}) has sent you a document to sign.
Sign Document
Click the button to view and sign ${document.title}.
If you have questions about this document, your should ask ${document.User.name}.
Do not forward.
This email contains a link to a secure document. Keep it secret and do not forward this email.
`
);
await prisma.recipient.update({
where: {
id: recipient.id,
},
data: { sendStatus: SendStatus.SENT },
});
await prisma.document.update({
where: {
id: document.id,
},
data: { status: DocumentStatus.PENDING },
});
};