The Open Source DocuSign Alternative.
TypeScript digital-signaturedocument-signingdocusign-alternativee-signatureesignesignaturenext-authnextjsopen-sourcepades-standardpdfpdf-signpdf-signaturepostgresqlprismaself-hostedsigningtypescript
send fix, send error handling
Timur Ercan36df6be70303
diff --git a/apps/web/pages/documents/[id]/recipients.tsx b/apps/web/pages/documents/[id]/recipients.tsxindex d54b8c16c..d5e2c23d4 100644--- a/apps/web/pages/documents/[id]/recipients.tsx+++ b/apps/web/pages/documents/[id]/recipients.tsx@@ -430,24 +430,32 @@ async function send(document: any) {// todo toast// loadingif (!document || !document.id) return;- return toast- .promise(+ try {+ const sent = await toast.promise(fetch(`/api/documents/${document.id}/send`, {body: "",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: "Changes could not send :/",+ error: "Could not send :/",}- )- .finally(() => {- location.reload();- });+ );+ } catch (err) {+ console.log(err);+ }}export default RecipientsPage;diff --git a/packages/lib/mail/sendSignedMail.ts b/packages/lib/mail/sendSignedMail.tsindex f6798e7b4..220d58a06 100644--- a/packages/lib/mail/sendSignedMail.ts+++ b/packages/lib/mail/sendSignedMail.ts@@ -2,7 +2,11 @@ import { sendMail } from "./sendMail";import { NEXT_PUBLIC_WEBAPP_URL } from "@documenso/lib/constants";import { transactionEmailTemplate } from "@documenso/lib/mail";-export const sendSignedMail = async (recipient: any, document: any) => {+export const sendSignedMail = async (+ recipient: any,+ document: any,+ user: any+) => {// todo check if recipient has an accountawait sendMail(document.User.email,@@ -14,7 +18,8 @@ export const sendSignedMail = async (recipient: any, document: any) => {document,recipient,`${NEXT_PUBLIC_WEBAPP_URL}/documents/${document.id}`,- `View Document`+ `View Document`,+ user));};diff --git a/packages/lib/mail/sendSigningRequest.ts b/packages/lib/mail/sendSigningRequest.tsindex e46a4fe95..921d008c8 100644--- a/packages/lib/mail/sendSigningRequest.ts+++ b/packages/lib/mail/sendSigningRequest.ts@@ -18,7 +18,8 @@ export const sendSigningRequest = async (document,recipient,`${NEXT_PUBLIC_WEBAPP_URL}/documents/${document.id}/sign?token=${recipient.token}`,- `Sign Document`+ `Sign Document`,+ user)).catch((err) => {throw err;diff --git a/packages/lib/mail/transactionEmailTemplate.ts b/packages/lib/mail/transactionEmailTemplate.tsindex d65a0f750..53cdc7df1 100644--- a/packages/lib/mail/transactionEmailTemplate.ts+++ b/packages/lib/mail/transactionEmailTemplate.ts@@ -6,7 +6,8 @@ export const transactionEmailTemplate = (document: any,recipient: any,ctaLink: string,- ctaLabel: string+ ctaLabel: string,+ user: any) => {const html = `<div style="background-color: #eaeaea; padding: 2%;">@@ -20,7 +21,7 @@ export const transactionEmailTemplate = (</p><hr size="1" style="height:1px;border:none;color:#e0e0e0;background-color:#e0e0e0">Click the button to view "${document.title}".<br>- <small>If you have questions about this document, you should ask ${document.User.name}.</small>+ <small>If you have questions about this document, you should ask ${user.name}.</small><hr size="1" style="height:1px;border:none;color:#e0e0e0;background-color:#e0e0e0"></div>`;