cal/packages/emails/templates/disabled-app-email.ts
Benny Joo ca78be011c
chore: [app-router-migration-1] migrate the pages in `settings/admin` to the app directory (#12561)
Co-authored-by: Dmytro Hryshyn <dev.dmytroh@gmail.com>
Co-authored-by: DmytroHryshyn <125881252+DmytroHryshyn@users.noreply.github.com>
Co-authored-by: zomars <zomars@me.com>
2023-12-01 13:07:26 -07:00

58 lines
1.6 KiB
TypeScript

import type { TFunction } from "next-i18next";
import { renderEmail } from "..";
import BaseEmail from "./_base-email";
export default class DisabledAppEmail extends BaseEmail {
email: string;
appName: string;
appType: string[];
t: TFunction;
title?: string;
eventTypeId?: number;
constructor(
email: string,
appName: string,
appType: string[],
t: TFunction,
title?: string,
eventTypeId?: number
) {
super();
this.email = email;
this.appName = appName;
this.appType = appType;
this.t = t;
this.title = title;
this.eventTypeId = eventTypeId;
}
protected async getNodeMailerPayload(): Promise<Record<string, unknown>> {
return {
from: `Cal.com <${this.getMailerOptions().from}>`,
to: this.email,
subject:
this.title && this.eventTypeId
? this.t("disabled_app_affects_event_type", { appName: this.appName, eventType: this.title })
: this.t("admin_has_disabled", { appName: this.appName }),
html: await renderEmail("DisabledAppEmail", {
title: this.title,
appName: this.appName,
eventTypeId: this.eventTypeId,
appType: this.appType,
t: this.t,
}),
text: this.getTextBody(),
};
}
protected getTextBody(): string {
return this.appType.some((type) => type === "payment")
? this.t("disable_payment_app", { appName: this.appName, title: this.title })
: this.appType.some((type) => type === "video")
? this.t("app_disabled_video", { appName: this.appName })
: this.t("app_disabled", { appName: this.appName });
}
}