2023-01-27 20:14:32 +01:00
import prisma from "@documenso/prisma" ;
2023-01-26 16:20:48 +01:00
import { sendMail } from "./sendMail" ;
2023-01-27 20:14:32 +01:00
import { SendStatus , DocumentStatus } from "@prisma/client" ;
export const sendSigningRequest = async ( recipient : any , document : any ) = > {
// todo errror handling
2023-01-27 18:15:41 +01:00
await sendMail (
2023-01-26 16:20:48 +01:00
recipient . email ,
` Please sign ${ document . title } ` ,
2023-01-27 18:15:41 +01:00
` ${ document . User . name } has sent you a document to sign. Click <b><a href=" ${ process . env . NEXT_PUBLIC_WEBAPP_URL } /documents/ ${ document . id } /sign">SIGN DOCUMENT</a></b> to sign it now. `
2023-01-26 16:20:48 +01:00
) ;
2023-01-27 20:14:32 +01:00
await prisma . recipient . update ( {
where : {
id : recipient.id ,
} ,
data : { sendStatus : SendStatus.SENT } ,
} ) ;
await prisma . document . update ( {
where : {
id : document.id ,
} ,
data : { status : DocumentStatus.PENDING } ,
} ) ;
2023-01-26 16:20:48 +01:00
} ;