feat: add CMS inquiries and group bookings
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
import { escapeHtml, paragraph, renderButton, renderEmailShell } from "./layout";
|
||||
|
||||
export function newConversationAdminEmail(args: {
|
||||
name: string;
|
||||
email: string;
|
||||
subject: string;
|
||||
body: string;
|
||||
adminUrl: string;
|
||||
threadKey: string;
|
||||
}): { subject: string; html: string } {
|
||||
return {
|
||||
subject: `Neue Anfrage: ${args.subject} [ANOUMA-${args.threadKey}]`,
|
||||
html: renderEmailShell({
|
||||
bodyHtml: [
|
||||
paragraph("Eine neue Anfrage ist eingegangen.", { italic: true }),
|
||||
`<p style="margin:0 0 20px;color:#66505f;font-size:14px;"><strong>${escapeHtml(args.name)}</strong> · ${escapeHtml(args.email)}<br /><strong>${escapeHtml(args.subject)}</strong></p>`,
|
||||
`<div style="padding:16px 20px;background:#fbf6f1;border-radius:16px;color:#66505f;font-size:15px;line-height:1.6;white-space:pre-wrap;">${escapeHtml(args.body)}</div>`,
|
||||
renderButton("Anfrage im CMS öffnen", args.adminUrl),
|
||||
].join("\n"),
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
export function conversationReplyEmail(args: {
|
||||
name: string;
|
||||
subject: string;
|
||||
body: string;
|
||||
senderName: string;
|
||||
threadKey: string;
|
||||
}): { subject: string; html: string } {
|
||||
return {
|
||||
subject: `Re: ${args.subject} [ANOUMA-${args.threadKey}]`,
|
||||
html: renderEmailShell({
|
||||
bodyHtml: [
|
||||
paragraph(`Hallo ${args.name},`),
|
||||
paragraph(`${args.senderName} hat auf deine Anfrage geantwortet.`, { italic: true }),
|
||||
`<div style="padding:16px 20px;background:#f2e2d6;border-radius:16px;color:#66505f;font-size:15px;line-height:1.6;white-space:pre-wrap;">${escapeHtml(args.body)}</div>`,
|
||||
paragraph("Du kannst einfach auf diese E-Mail antworten. Deine Antwort wird automatisch derselben Anfrage zugeordnet.", { small: true }),
|
||||
].join("\n"),
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
export function groupRegistrationEmail(args: {
|
||||
name: string;
|
||||
offerTitle: string;
|
||||
status: "received" | "admin";
|
||||
adminUrl?: string;
|
||||
}): { subject: string; html: string } {
|
||||
const isAdminMail = args.status === "admin";
|
||||
return {
|
||||
subject: isAdminMail ? `Neue Gruppenanmeldung: ${args.offerTitle}` : `Deine Anmeldung bei ANOUMA: ${args.offerTitle}`,
|
||||
html: renderEmailShell({
|
||||
bodyHtml: [
|
||||
paragraph(isAdminMail ? "Eine neue Gruppenanmeldung ist eingegangen." : `Hallo ${args.name},`),
|
||||
paragraph(isAdminMail ? `${args.name} hat sich für „${args.offerTitle}“ angemeldet.` : `Deine Anmeldung für „${args.offerTitle}“ wurde übermittelt. Anna meldet sich, sobald sie sie geprüft hat.`, { italic: true }),
|
||||
...(isAdminMail && args.adminUrl ? [renderButton("Anmeldung im CMS öffnen", args.adminUrl)] : []),
|
||||
].join("\n"),
|
||||
}),
|
||||
};
|
||||
}
|
||||
@@ -1,6 +1,16 @@
|
||||
import { getMailFrom, getMailTransport } from "./transport";
|
||||
|
||||
export async function sendEmail(to: string, template: { subject: string; html: string }) {
|
||||
export async function sendEmail(
|
||||
to: string,
|
||||
template: { subject: string; html: string },
|
||||
options: { replyTo?: string } = {},
|
||||
) {
|
||||
const transport = getMailTransport();
|
||||
await transport.sendMail({ from: getMailFrom(), to, subject: template.subject, html: template.html });
|
||||
await transport.sendMail({
|
||||
from: getMailFrom(),
|
||||
to,
|
||||
subject: template.subject,
|
||||
html: template.html,
|
||||
...(options.replyTo ? { replyTo: options.replyTo } : {}),
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user