46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
import { Resend } from 'resend';
|
|
import { RESEND_API } from '$app/env/private';
|
|
|
|
const resend = new Resend(String(RESEND_API));
|
|
|
|
export async function sendPasswordResetEmail(opts: {
|
|
to: string;
|
|
resetLink: string;
|
|
famName: string;
|
|
}) {
|
|
const { to, resetLink, famName } = opts;
|
|
|
|
await resend.emails.send({
|
|
from: 'no-reply@famchamp.ai',
|
|
to,
|
|
subject: `Reset your password for ${famName}`,
|
|
html: `
|
|
<p>You requested a password reset for your <strong>${famName}</strong> account.</p>
|
|
<p><a href="${resetLink}">Click here to reset your password</a></p>
|
|
<p>This link expires in 1 hour.</p>
|
|
<p>If you didn't request this, you can ignore this email.</p>
|
|
`
|
|
});
|
|
}
|
|
|
|
export async function sendParentInviteEmail(opts: {
|
|
to: string;
|
|
inviteLink: string;
|
|
famName: string;
|
|
otp: string;
|
|
}) {
|
|
const { to, inviteLink, famName, otp } = opts;
|
|
|
|
await resend.emails.send({
|
|
from: 'no-reply@famchamp.ai',
|
|
to,
|
|
subject: `You're invited to ${famName} on FamDone`,
|
|
html: `
|
|
<p>You've been invited as a parent on <strong>${famName}</strong>.</p>
|
|
<p><a href="${inviteLink}">Click here to join</a> and set up your password.</p>
|
|
<p>Your code is <strong>${otp}</strong> (valid 20 minutes).</p>
|
|
<p>If you weren't expecting this, you can ignore this email.</p>
|
|
`
|
|
});
|
|
}
|