mirror of
https://github.com/documenso/documenso.git
synced 2025-11-23 05:01:54 +10:00
chore: refactor sendMail to make it reusable
This commit is contained in:
@ -90,12 +90,12 @@ export const DocumensoEmail = ({
|
||||
</Text>
|
||||
)}
|
||||
|
||||
<Text className="mx-0 mb-0 text-center text-[18px] font-semibold text-[#27272A]">
|
||||
<Text className="mx-0 mb-0 text-center text-[16px] font-semibold text-[#27272A]">
|
||||
{type === 'invite'
|
||||
? `${name} has invited you to sign “${documentName}”`
|
||||
: `“${documentName}” was signed by ${name}`}
|
||||
</Text>
|
||||
<Text className="my-1 text-center text-[16px] text-[#AFAFAF]">
|
||||
<Text className="my-1 text-center text-[14px] text-[#AFAFAF]">
|
||||
{type === 'invite'
|
||||
? 'Continue by signing the document.'
|
||||
: 'Continue by downloading or reviewing the document.'}
|
||||
@ -105,7 +105,7 @@ export const DocumensoEmail = ({
|
||||
<Button
|
||||
pX={20}
|
||||
pY={12}
|
||||
className="rounded bg-[#A2E771] px-10 text-center text-[14px] font-medium text-black no-underline"
|
||||
className="rounded bg-[#A2E771] text-center text-[14px] font-medium text-black no-underline"
|
||||
href={documentSigningLink}
|
||||
>
|
||||
Sign Document
|
||||
|
||||
@ -1,9 +1,19 @@
|
||||
import nodemailer from 'nodemailer';
|
||||
import nodemailerSendgrid from 'nodemailer-sendgrid';
|
||||
|
||||
import { TSendMailMutationSchema } from '@documenso/trpc/server/mail-router/schema';
|
||||
|
||||
import { emailHtml, emailText } from '../../mail/template';
|
||||
|
||||
export const sendMail = async ({ email }: { email: string }) => {
|
||||
interface SendMail {
|
||||
template: TSendMailMutationSchema;
|
||||
mail: {
|
||||
from: string;
|
||||
subject: string;
|
||||
};
|
||||
}
|
||||
|
||||
export const sendMail = async ({ template, mail }: SendMail) => {
|
||||
let transporter;
|
||||
|
||||
if (process.env.NEXT_PRIVATE_SENDGRID_API_KEY) {
|
||||
@ -31,25 +41,11 @@ export const sendMail = async ({ email }: { email: string }) => {
|
||||
);
|
||||
}
|
||||
|
||||
const html = emailHtml({
|
||||
email: 'lucas@documenso.com',
|
||||
name: 'Lucas Smith',
|
||||
documentName: 'NDA.pdf',
|
||||
firstName: 'Lucas',
|
||||
type: 'signed',
|
||||
});
|
||||
|
||||
await transporter.sendMail({
|
||||
from: 'Documenso <hi@documenso.com>',
|
||||
to: email,
|
||||
subject: 'Welcome to Documenso!',
|
||||
text: emailText({
|
||||
email: 'lucas@documenso.com',
|
||||
name: 'Lucas Smith',
|
||||
documentName: 'NDA.pdf',
|
||||
firstName: 'Lucas',
|
||||
type: 'completed',
|
||||
}),
|
||||
html,
|
||||
from: mail.from,
|
||||
to: template.email,
|
||||
subject: mail.subject,
|
||||
text: emailText({ ...template }),
|
||||
html: emailHtml({ ...template }),
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user