mirror of
https://github.com/hanzoai/dataroom.git
synced 2026-10-30 18:41:07 +00:00
41 lines
923 B
TypeScript
41 lines
923 B
TypeScript
import { sendEmail } from "@/lib/resend";
|
|
|
|
import ViewedDocumentPausedEmail from "@/components/emails/viewed-document-paused";
|
|
|
|
export const sendViewedDocumentPausedEmail = async ({
|
|
ownerEmail,
|
|
documentName,
|
|
linkName,
|
|
teamMembers,
|
|
}: {
|
|
ownerEmail: string | null;
|
|
documentName: string;
|
|
linkName: string;
|
|
teamMembers?: string[];
|
|
}) => {
|
|
const emailTemplate = ViewedDocumentPausedEmail({
|
|
documentName,
|
|
linkName,
|
|
});
|
|
try {
|
|
if (!ownerEmail) {
|
|
throw new Error("Document Owner not found");
|
|
}
|
|
|
|
const subjectLine = `Your document has been viewed: ${documentName}`;
|
|
|
|
const data = await sendEmail({
|
|
to: ownerEmail,
|
|
cc: teamMembers,
|
|
subject: subjectLine,
|
|
react: emailTemplate,
|
|
test: process.env.NODE_ENV === "development",
|
|
system: true,
|
|
});
|
|
|
|
return { success: true, data };
|
|
} catch (error) {
|
|
return { success: false, error };
|
|
}
|
|
};
|