cal.pub0.org/packages/app-store/routing-forms/emails/templates/response-email.ts

43 lines
1.1 KiB
TypeScript
Raw Normal View History

import type { App_RoutingForms_Form } from "@prisma/client";
import { renderEmail } from "@calcom/emails";
import BaseEmail from "@calcom/emails/templates/_base-email";
import type { OrderedResponses } from "../../types/types";
type Form = Pick<App_RoutingForms_Form, "id" | "name">;
export default class ResponseEmail extends BaseEmail {
orderedResponses: OrderedResponses;
toAddresses: string[];
form: Form;
constructor({
toAddresses,
orderedResponses,
form,
}: {
form: Form;
toAddresses: string[];
orderedResponses: OrderedResponses;
}) {
super();
this.form = form;
this.orderedResponses = orderedResponses;
this.toAddresses = toAddresses;
}
protected getNodeMailerPayload(): Record<string, unknown> {
const toAddresses = this.toAddresses;
const subject = `${this.form.name} has a new response`;
return {
from: `Cal.com <${this.getMailerOptions().from}>`,
to: toAddresses.join(","),
subject,
html: renderEmail("ResponseEmail", {
form: this.form,
orderedResponses: this.orderedResponses,
subject,
}),
};
}
}