* added layouts for moving teams step * added admin section for org creation step * extended org creation to also move existing teams * wip * wip * wip * further changes * Add checkout for org in onboarding * Fix ts errors * Self review feedback * Self review addressed * Fix unit tests * Fix ts error * Seans feedback addressed * feat: fix correct accounts pending * fix: unit tests for new invite member permissions * tests: org admin onboarding tests for existing user * tests: Inital user self serve flow * chore: update teamAndUserFixture to create X amount of teams * chore: add testId to card actionButton * test: add test-Id to continue or checkout button * tests: add tests for migrating existing teams * feat: match new designs * fix: isAdminCheck * chore: fix pricing copy * fix: flacky tests * Fix tests? * More test fixes * Check all checkboxes * Fix type error * Fix failing test and typescript issues * Fix unpaid org allowing auto-add users * Add self-serve flag * Skip tests --------- Co-authored-by: Alex van Andel <me@alexvanandel.com> Co-authored-by: Hariom <hariombalhara@gmail.com> Co-authored-by: sean-brydon <sean@cal.com> Co-authored-by: Joe Au-Yeung <j.auyeung419@gmail.com> Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com> Co-authored-by: Omar López <zomars@me.com>
82 lines
2.3 KiB
TypeScript
82 lines
2.3 KiB
TypeScript
import type { TFunction } from "next-i18next";
|
|
|
|
import { APP_NAME } from "@calcom/lib/constants";
|
|
|
|
import { renderEmail } from "../";
|
|
import BaseEmail from "./_base-email";
|
|
|
|
export type TeamInvite = {
|
|
language: TFunction;
|
|
from: string;
|
|
to: string;
|
|
teamName: string;
|
|
joinLink: string;
|
|
isCalcomMember: boolean;
|
|
/**
|
|
* We ideally should have a separate email for auto-join(when a user is automatically accepted into a team/org), but we don't have one yet.
|
|
*/
|
|
isAutoJoin: boolean;
|
|
isOrg: boolean;
|
|
parentTeamName: string | undefined;
|
|
isExistingUserMovedToOrg: boolean;
|
|
prevLink: string | null;
|
|
newLink: string | null;
|
|
};
|
|
|
|
export function getTypeOfInvite(teamInviteEvent: TeamInvite) {
|
|
if (teamInviteEvent.isOrg) {
|
|
return "TO_ORG";
|
|
}
|
|
|
|
if (teamInviteEvent.parentTeamName) {
|
|
return "TO_SUBTEAM";
|
|
}
|
|
|
|
if (teamInviteEvent.isAutoJoin) {
|
|
throw new Error("Auto-join is not supported for regular teams");
|
|
}
|
|
|
|
return "TO_REGULAR_TEAM";
|
|
}
|
|
|
|
export const getSubject = (teamInviteEvent: TeamInvite) => {
|
|
const typeOfInvite = getTypeOfInvite(teamInviteEvent);
|
|
const type = teamInviteEvent.isAutoJoin ? "added" : "invited";
|
|
const variables = {
|
|
user: teamInviteEvent.from,
|
|
team: teamInviteEvent.teamName,
|
|
appName: APP_NAME,
|
|
parentTeamName: teamInviteEvent.parentTeamName,
|
|
entity: teamInviteEvent.language(teamInviteEvent.isOrg ? "organization" : "team").toLowerCase(),
|
|
};
|
|
|
|
if (typeOfInvite === "TO_ORG") {
|
|
return teamInviteEvent.language(`email_team_invite|subject|${type}_to_org`, variables);
|
|
}
|
|
|
|
if (typeOfInvite === "TO_SUBTEAM") {
|
|
return teamInviteEvent.language(`email_team_invite|subject|${type}_to_subteam`, variables);
|
|
}
|
|
|
|
return teamInviteEvent.language(`email_team_invite|subject|${type}_to_regular_team`, variables);
|
|
};
|
|
|
|
export default class TeamInviteEmail extends BaseEmail {
|
|
teamInviteEvent: TeamInvite;
|
|
constructor(teamInviteEvent: TeamInvite) {
|
|
super();
|
|
this.name = "SEND_TEAM_INVITE_EMAIL";
|
|
this.teamInviteEvent = teamInviteEvent;
|
|
}
|
|
|
|
protected async getNodeMailerPayload(): Promise<Record<string, unknown>> {
|
|
return {
|
|
to: this.teamInviteEvent.to,
|
|
from: `${APP_NAME} <${this.getMailerOptions().from}>`,
|
|
subject: getSubject(this.teamInviteEvent),
|
|
html: await renderEmail("TeamInviteEmail", this.teamInviteEvent),
|
|
text: "",
|
|
};
|
|
}
|
|
}
|