feat: add trpc route to send emails

This commit is contained in:
Ephraim Atta-Duncan
2023-06-19 16:33:30 +00:00
parent aa740864b8
commit bc11abda08
11 changed files with 1095 additions and 4 deletions

View File

@ -43,9 +43,7 @@ export default function RootLayout({ children }: { children: React.ReactNode })
</head>
<body>
<PlausibleProvider>
{children}
</PlausibleProvider>
<PlausibleProvider>{children}</PlausibleProvider>
<Toaster />
</body>
</html>

View File

@ -25,6 +25,8 @@
"next-auth": "^4.22.1",
"next-plausible": "^3.7.2",
"next-themes": "^0.2.1",
"nodemailer": "^6.9.3",
"nodemailer-sendgrid": "^1.0.3",
"perfect-freehand": "^1.2.0",
"react": "18.2.0",
"react-dom": "18.2.0",
@ -38,6 +40,8 @@
"devDependencies": {
"@types/formidable": "^2.0.6",
"@types/node": "20.1.0",
"@types/nodemailer": "^6.4.8",
"@types/nodemailer-sendgrid": "^1.0.0",
"@types/react": "18.2.6",
"@types/react-dom": "18.2.4"
}

View File

@ -11,5 +11,11 @@ declare namespace NodeJS {
NEXT_PRIVATE_STRIPE_WEBHOOK_SECRET: string;
NEXT_PUBLIC_SUBSCRIPTIONS_ENABLED: string;
NEXT_PRIVATE_SENDGRID_API_KEY: string;
NEXT_PRIVATE_SMTP_MAIL_HOST: string;
NEXT_PRIVATE_SMTP_MAIL_PORT: string;
NEXT_PRIVATE_SMTP_MAIL_USER: string;
NEXT_PRIVATE_SMTP_MAIL_PASSWORD: string;
}
}

View File

@ -0,0 +1,24 @@
'use client';
import React from 'react';
import { trpc } from '@documenso/trpc/react';
export default function Send() {
const { mutateAsync: sendMail } = trpc.document.sendEmail.useMutation();
return (
<div className="p-20">
<button
className="rounded-md border-2 border-solid border-black px-4 py-2 text-2xl"
onClick={async () => {
console.log('clicked');
await sendMail({ email: 'duncan@documenso.com' });
}}
>
Send
</button>
</div>
);
}