mirror of
https://github.com/documenso/documenso.git
synced 2026-07-25 01:15:49 +10:00
wip: refresh design
This commit is contained in:
@@ -1,36 +0,0 @@
|
||||
import { NEXT_PUBLIC_WEBAPP_URL } from "../constants";
|
||||
|
||||
export const baseEmailTemplate = (message: string, content: string) => {
|
||||
const html = `
|
||||
<div style="background-color: #eaeaea; padding: 2%;">
|
||||
<div style="text-align:center; margin: auto; font-size: 14px; color: #353434; max-width: 500px; border-radius: 0.375rem; background: white; padding: 50px">
|
||||
<img src="${NEXT_PUBLIC_WEBAPP_URL}/logo_h.png" alt="Documenso Logo" style="width: 180px; display: block; margin: auto; margin-bottom: 14px;">
|
||||
${message}
|
||||
${content}
|
||||
</div>
|
||||
`;
|
||||
|
||||
const footer = `
|
||||
<div style="text-align: left; line-height: 18px; color: #666666; margin: 24px">
|
||||
<div>
|
||||
<b>Do not forward.</b>
|
||||
<br>
|
||||
This email gives access to a secure document. Keep it secret and do not forward this email.
|
||||
</div>
|
||||
<div style="margin-top: 12px">
|
||||
<b>Need help?</b>
|
||||
<br>
|
||||
Contact us at <a href="mailto:hi@documenso.com">hi@documenso.com</a>
|
||||
</div>
|
||||
<hr size="1" style="height: 1px; border: none; color: #D8D8D8; background-color: #D8D8D8">
|
||||
<div style="text-align: center">
|
||||
<small>Easy and beautiful document signing by Documenso.</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
return html + footer;
|
||||
};
|
||||
|
||||
export default baseEmailTemplate;
|
||||
@@ -1,8 +0,0 @@
|
||||
export { signingRequestTemplate } from "./signingRequestTemplate";
|
||||
export { signingCompleteTemplate } from "./signingCompleteTemplate";
|
||||
export { sendSigningRequest as sendSigningRequest } from "./sendSigningRequest";
|
||||
export { sendSigningDoneMail } from "./sendSigningDoneMail";
|
||||
export { resetPasswordTemplate } from "./resetPasswordTemplate";
|
||||
export { sendResetPassword } from "./sendResetPassword";
|
||||
export { resetPasswordSuccessTemplate } from "./resetPasswordSuccessTemplate";
|
||||
export { sendResetPasswordSuccessMail } from "./sendResetPasswordSuccessMail";
|
||||
@@ -1,47 +0,0 @@
|
||||
import nodemailer from "nodemailer";
|
||||
import nodemailerSendgrid from "nodemailer-sendgrid";
|
||||
|
||||
export const sendMail = async (
|
||||
to: string,
|
||||
subject: string,
|
||||
body: string,
|
||||
attachments: {
|
||||
filename: string;
|
||||
content: string | Buffer;
|
||||
}[] = []
|
||||
) => {
|
||||
let transport;
|
||||
if (process.env.SENDGRID_API_KEY)
|
||||
transport = nodemailer.createTransport(
|
||||
nodemailerSendgrid({
|
||||
apiKey: process.env.SENDGRID_API_KEY || "",
|
||||
})
|
||||
);
|
||||
|
||||
if (process.env.SMTP_MAIL_HOST)
|
||||
transport = nodemailer.createTransport({
|
||||
host: process.env.SMTP_MAIL_HOST || "",
|
||||
port: Number(process.env.SMTP_MAIL_PORT) || 587,
|
||||
auth: {
|
||||
user: process.env.SMTP_MAIL_USER || "",
|
||||
pass: process.env.SMTP_MAIL_PASSWORD || "",
|
||||
},
|
||||
});
|
||||
|
||||
if (!transport)
|
||||
throw new Error(
|
||||
"No valid transport for NodeMailer found. Probably Sendgrid API Key nor SMTP Mail host was set."
|
||||
);
|
||||
|
||||
await transport
|
||||
.sendMail({
|
||||
from: process.env.MAIL_FROM,
|
||||
to: to,
|
||||
subject: subject,
|
||||
html: body,
|
||||
attachments: attachments,
|
||||
})
|
||||
.catch((err) => {
|
||||
throw err;
|
||||
});
|
||||
};
|
||||
@@ -1,18 +0,0 @@
|
||||
import { signingCompleteTemplate } from "@documenso/lib/mail";
|
||||
import { addDigitalSignature } from "@documenso/signing/addDigitalSignature";
|
||||
import { sendMail } from "./sendMail";
|
||||
import { Document as PrismaDocument } from "@prisma/client";
|
||||
|
||||
export const sendSigningDoneMail = async (document: PrismaDocument, user: any) => {
|
||||
await sendMail(
|
||||
user.email,
|
||||
`Completed: "${document.title}"`,
|
||||
signingCompleteTemplate(`All recipients have signed "${document.title}".`),
|
||||
[
|
||||
{
|
||||
filename: document.title,
|
||||
content: Buffer.from(await addDigitalSignature(document.document), "base64"),
|
||||
},
|
||||
]
|
||||
);
|
||||
};
|
||||
@@ -1,47 +0,0 @@
|
||||
import { signingRequestTemplate } from "@documenso/lib/mail";
|
||||
import prisma from "@documenso/prisma";
|
||||
import { NEXT_PUBLIC_WEBAPP_URL } from "../constants";
|
||||
import { sendMail } from "./sendMail";
|
||||
import { DocumentStatus, ReadStatus, SendStatus } from "@prisma/client";
|
||||
|
||||
export const sendSigningRequest = async (recipient: any, document: any, user: any) => {
|
||||
const signingRequestMessage = user.name
|
||||
? `${user.name} (${user.email}) has sent you a document to sign. `
|
||||
: `${user.email} has sent you a document to sign. `;
|
||||
|
||||
await sendMail(
|
||||
recipient.email,
|
||||
`Please sign ${document.title}`,
|
||||
signingRequestTemplate(
|
||||
signingRequestMessage,
|
||||
document,
|
||||
recipient,
|
||||
`${NEXT_PUBLIC_WEBAPP_URL}/documents/${document.id}/sign?token=${recipient.token}`,
|
||||
`Sign Document`,
|
||||
user
|
||||
)
|
||||
).catch((err) => {
|
||||
throw err;
|
||||
});
|
||||
|
||||
const expiryDate = new Date();
|
||||
expiryDate.setDate(expiryDate.getDate() + 60);
|
||||
|
||||
await prisma.recipient.update({
|
||||
where: {
|
||||
id: recipient.id,
|
||||
},
|
||||
data: {
|
||||
sendStatus: SendStatus.SENT,
|
||||
readStatus: ReadStatus.NOT_OPENED,
|
||||
expired: expiryDate,
|
||||
},
|
||||
});
|
||||
|
||||
await prisma.document.update({
|
||||
where: {
|
||||
id: document.id,
|
||||
},
|
||||
data: { status: DocumentStatus.PENDING },
|
||||
});
|
||||
};
|
||||
@@ -1,27 +0,0 @@
|
||||
import { NEXT_PUBLIC_WEBAPP_URL } from "../constants";
|
||||
import { baseEmailTemplate } from "./baseTemplate";
|
||||
|
||||
export const signingCompleteTemplate = (message: string) => {
|
||||
const customContent = `
|
||||
<div style="
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
margin: auto;
|
||||
padding-top: 14px;
|
||||
">
|
||||
<img src="${NEXT_PUBLIC_WEBAPP_URL}/images/signed_100.png" alt="Documenso Logo" style="width: 100px; display: block;">
|
||||
</div>
|
||||
|
||||
<p style="margin-top: 14px;">
|
||||
A copy of the signed document has been attached to this email.
|
||||
</p>
|
||||
<p style="margin-top: 14px;">
|
||||
<small>Like Documenso? <a href="https://documenso.com">Hosted Documenso is here!</a>.</small>
|
||||
</p>`;
|
||||
|
||||
const html = baseEmailTemplate(message, customContent);
|
||||
|
||||
return html;
|
||||
};
|
||||
|
||||
export default signingCompleteTemplate;
|
||||
@@ -1,32 +0,0 @@
|
||||
import { NEXT_PUBLIC_WEBAPP_URL } from "../constants";
|
||||
import { baseEmailTemplate } from "./baseTemplate";
|
||||
import { Document as PrismaDocument } from "@prisma/client";
|
||||
|
||||
export const signingRequestTemplate = (
|
||||
message: string,
|
||||
document: any,
|
||||
recipient: any,
|
||||
ctaLink: string,
|
||||
ctaLabel: string,
|
||||
user: any
|
||||
) => {
|
||||
const customContent = `
|
||||
<p style="margin: 30px 0px; text-align: center">
|
||||
<a href="${ctaLink}" style="background-color: #37f095; white-space: nowrap; color: white; border-color: transparent; border-width: 1px; border-radius: 0.375rem; font-size: 18px; padding-left: 16px; padding-right: 16px; padding-top: 10px; padding-bottom: 10px; text-decoration: none; margin-top: 4px; margin-bottom: 4px;">
|
||||
${ctaLabel}
|
||||
</a>
|
||||
</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 ${user.name ?? user.email}.</small>
|
||||
<hr size="1" style="height:1px;border:none;color:#e0e0e0;background-color:#e0e0e0">
|
||||
<p style="margin-top: 14px;">
|
||||
<small>Want to send you own signing links? <a href="https://documenso.com">Hosted Documenso is here!</a>.</small>
|
||||
</p>`;
|
||||
|
||||
const html = baseEmailTemplate(message, customContent);
|
||||
|
||||
return html;
|
||||
};
|
||||
|
||||
export default signingRequestTemplate;
|
||||
Reference in New Issue
Block a user