Files
calendar/packages/emails/templates/credit-balance-limit-reached-email.ts
2df2868b20 fix: cal ai webhook (#24368)
* fix: cal ai email

* fix: remove

* fix: org

* replace Cal AI with Cal.ai

* fix: use

* fix: feedback

* fix: types

* fix: types

* fix: types

* fix: tests

* Merge branch 'main' into fix/cal-ai-credits

* refactor: feedback

* refactor: imporvement

* fix: type

* refactor: feedback

* fix: tests

* fix: use pbac

---------

Co-authored-by: CarinaWolli <[email protected]>
2025-11-05 13:31:55 +04:00

57 lines
1.5 KiB
TypeScript

import type { TFunction } from "i18next";
import { EMAIL_FROM_NAME } from "@calcom/lib/constants";
import type { CreditUsageType } from "@calcom/prisma/enums";
import renderEmail from "../src/renderEmail";
import BaseEmail from "./_base-email";
export default class CreditBalanceLimitReachedEmail extends BaseEmail {
user: {
id: number;
name: string;
email: string;
t: TFunction;
};
team?: {
id: number;
name: string;
};
creditFor?: CreditUsageType;
constructor({
user,
team,
creditFor,
}: {
user: { id: number; name: string | null; email: string; t: TFunction };
team?: { id: number; name: string | null };
creditFor?: CreditUsageType;
}) {
super();
this.user = { ...user, name: user.name || "" };
this.team = team ? { ...team, name: team.name || "" } : undefined;
this.creditFor = creditFor;
}
protected async getNodeMailerPayload(): Promise<Record<string, unknown>> {
return {
from: `${EMAIL_FROM_NAME} <${this.getMailerOptions().from}>`,
to: this.user.email,
subject: this.team
? this.user.t("action_required_out_of_credits", { teamName: this.team.name })
: this.user.t("action_required_user_out_of_credits"),
html: await renderEmail("CreditBalanceLimitReachedEmail", {
team: this.team,
user: this.user,
creditFor: this.creditFor,
}),
text: this.getTextBody(),
};
}
protected getTextBody(): string {
return "Your team ran out of credits. Please buy more credits.";
}
}