feat: new org onboarding wizard (#13139)

* 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 <[email protected]>
Co-authored-by: Hariom <[email protected]>
Co-authored-by: sean-brydon <[email protected]>
Co-authored-by: Joe Au-Yeung <[email protected]>
Co-authored-by: Joe Au-Yeung <[email protected]>
Co-authored-by: Omar López <[email protected]>
This commit is contained in:
authored and GitHub committed 2024-04-03 18:53:02 +05:30
1 parent c3b1de498d
commit b3f4cfab32
49 files changed
+1813 -755

No files matched your search

@@ -0,0 +1,105 @@
import { Trans } from "next-i18next";
import { APP_NAME, WEBAPP_URL } from "@calcom/lib/constants";
import type { OrganizationCreation } from "../../templates/organization-creation-email";
import { V2BaseEmailHtml } from "../components";
export const OrganizationCreationEmail = (
props: OrganizationCreation & Partial<React.ComponentProps<typeof V2BaseEmailHtml>>
) => {
const { prevLink, newLink, orgName: teamName } = props;
const prevLinkWithoutProtocol = props.prevLink?.replace(/https?:\/\//, "");
const newLinkWithoutProtocol = props.newLink?.replace(/https?:\/\//, "");
return (
<V2BaseEmailHtml subject={props.language(`email_organization_created|subject`)}>
<p style={{ fontSize: "24px", marginBottom: "16px", textAlign: "center" }}>
<>{props.language(`You have created ${props.orgName} organization.`)}</>
</p>
<img
style={{
borderRadius: "16px",
height: "270px",
display: "flex",
alignItems: "center",
justifyContent: "center",
}}
src={`${WEBAPP_URL}/emails/calendar-email-hero.png`}
alt=""
/>
<p
style={{
fontWeight: 400,
lineHeight: "24px",
marginBottom: "32px",
marginTop: "32px",
lineHeightStep: "24px",
}}>
<>
{props.language(`You have been added as an owner of the organization.`, {
invitedBy: props.from.toString(),
appName: APP_NAME,
})}
</>
</p>
<p
style={{
fontWeight: 400,
lineHeight: "24px",
marginBottom: "32px",
marginTop: "48px",
lineHeightStep: "24px",
}}>
<Trans i18nKey="email|existing_user_added_link_changed">
Your link has been changed from <a href={`https://${prevLink}`}>{prevLinkWithoutProtocol}</a> to{" "}
<a href={`https://${newLink}`}>{newLinkWithoutProtocol}</a> but don&apos;t worry, all previous links
still work and redirect appropriately.
<br />
<br />
Please note: All of your personal event types have been moved into the <strong>
{teamName}
</strong>{" "}
organisation, which may also include potential personal link.
<br />
<br />
Please log in and make sure you have no private events on your new organisational account.
<br />
<br />
For personal events we recommend creating a new account with a personal email address.
<br />
<br />
Enjoy your new clean link: <a href={`https://${newLink}`}>{newLinkWithoutProtocol}</a>
</Trans>
</p>
<div className="">
<p
style={{
fontWeight: 400,
lineHeight: "24px",
marginBottom: "32px",
marginTop: "32px",
lineHeightStep: "24px",
}}>
<>
{props.language("email_no_user_signoff", {
appName: APP_NAME,
})}
</>
</p>
</div>
<div style={{ borderTop: "1px solid #E1E1E1", marginTop: "32px", paddingTop: "32px" }}>
<p style={{ fontWeight: 400, margin: 0 }}>
<>
{props.language("have_any_questions")}{" "}
<a href="mailto:[email protected]" style={{ color: "#3E3E3E" }} target="_blank" rel="noreferrer">
<>{props.language("contact")}</>
</a>{" "}
{props.language("our_support_team")}
</>
</p>
</div>
</V2BaseEmailHtml>
);
};
+157 -72
View File
@@ -1,7 +1,9 @@
import type { TFunction } from "next-i18next";
import { Trans } from "next-i18next";
import { APP_NAME, WEBAPP_URL, IS_PRODUCTION } from "@calcom/lib/constants";
import { getSubject, getTypeOfInvite } from "../../templates/team-invite-email";
import { V2BaseEmailHtml, CallToAction } from "../components";
type TeamInvite = {
@@ -14,30 +16,22 @@ type TeamInvite = {
isAutoJoin: boolean;
isOrg: boolean;
parentTeamName: string | undefined;
isExistingUserMovedToOrg: boolean;
prevLink: string | null;
newLink: string | null;
};
export const TeamInviteEmail = (
props: TeamInvite & Partial<React.ComponentProps<typeof V2BaseEmailHtml>>
) => {
const typeOfInvite = getTypeOfInvite(props);
const heading = getHeading();
const content = getContent();
return (
<V2BaseEmailHtml
subject={props.language(`user_invited_you${props.parentTeamName ? "_to_subteam" : ""}`, {
user: props.from,
team: props.teamName,
appName: APP_NAME,
parentTeamName: props.parentTeamName,
entity: props.language(props.isOrg ? "organization" : "team").toLowerCase(),
})}>
<V2BaseEmailHtml subject={getSubject(props)}>
<p style={{ fontSize: "24px", marginBottom: "16px", textAlign: "center" }}>
<>
{props.language(
`email_no_user_invite_heading_${props.isOrg ? "org" : props.parentTeamName ? "subteam" : "team"}`,
{
appName: APP_NAME,
parentTeamName: props.parentTeamName,
}
)}
</>
<>{heading}</>
</p>
<img
style={{
@@ -62,17 +56,7 @@ export const TeamInviteEmail = (
marginTop: "32px",
lineHeightStep: "24px",
}}>
<>
{props.language(
`email_user_invite_subheading_${props.isOrg ? "org" : props.parentTeamName ? "subteam" : "team"}`,
{
invitedBy: props.from.toString(),
appName: APP_NAME,
teamName: props.teamName,
parentTeamName: props.parentTeamName,
}
)}
</>
<>{content}</>
</p>
<div style={{ display: "flex", justifyContent: "center" }}>
<CallToAction
@@ -90,50 +74,8 @@ export const TeamInviteEmail = (
marginBottom: "32px",
marginTop: "48px",
lineHeightStep: "24px",
}}>
{/* <>
{props.language("email_no_user_invite_steps_intro", {
entity: props.language(props.isOrg ? "organization" : "team").toLowerCase(),
})}
</> */}
</p>
{/*
{!props.isCalcomMember && (
<div style={{ display: "flex", flexDirection: "column", gap: "32px" }}>
<EmailStep
translationString={props.language("email_no_user_step_one")}
iconsrc={
IS_PRODUCTION
? `${WEBAPP_URL}/emails/[email protected]`
: "http://localhost:3000/emails/[email protected]"
}
/>
<EmailStep
translationString={props.language("email_no_user_step_two")}
iconsrc={
IS_PRODUCTION
? `${WEBAPP_URL}/emails/[email protected]`
: "http://localhost:3000/emails/[email protected]"
}
/>
<EmailStep
translationString={props.language("email_no_user_step_three")}
iconsrc={
IS_PRODUCTION
? `${WEBAPP_URL}/emails/[email protected]`
: "http://localhost:3000/emails/[email protected]"
}
/>
<EmailStep
translationString={props.language("email_no_user_step_four", { teamName: props.teamName })}
iconsrc={
IS_PRODUCTION
? `${WEBAPP_URL}/emails/[email protected]`
: "http://localhost:3000/emails/[email protected]"
}
/>
</div>
)} */}
}}
/>
<div className="">
<p
@@ -165,4 +107,147 @@ export const TeamInviteEmail = (
</div>
</V2BaseEmailHtml>
);
function getHeading() {
const autoJoinType = props.isAutoJoin ? "added" : "invited";
const variables = {
appName: APP_NAME,
parentTeamName: props.parentTeamName,
};
if (typeOfInvite === "TO_ORG") {
return props.language(`email_team_invite|heading|${autoJoinType}_to_org`, variables);
}
if (typeOfInvite === "TO_SUBTEAM") {
return props.language(`email_team_invite|heading|${autoJoinType}_to_subteam`, variables);
}
return props.language(`email_team_invite|heading|invited_to_regular_team`, variables);
}
function getContent() {
const autoJoinType = props.isAutoJoin ? "added" : "invited";
const variables = {
invitedBy: props.from.toString(),
appName: APP_NAME,
teamName: props.teamName,
parentTeamName: props.parentTeamName,
prevLink: props.prevLink,
newLink: props.newLink,
orgName: props.parentTeamName ?? props.isOrg ? props.teamName : "",
prevLinkWithoutProtocol: props.prevLink?.replace(/https?:\/\//, ""),
newLinkWithoutProtocol: props.newLink?.replace(/https?:\/\//, ""),
};
const {
prevLink,
newLink,
teamName,
invitedBy,
appName,
parentTeamName,
prevLinkWithoutProtocol,
newLinkWithoutProtocol,
} = variables;
if (typeOfInvite === "TO_ORG") {
if (props.isExistingUserMovedToOrg) {
return (
<>
{autoJoinType == "added" ? (
<>
<Trans i18nKey="email_team_invite|content|added_to_org">
{invitedBy} has added you to the <strong>{teamName}</strong> organization.
</Trans>{" "}
<Trans
i18nKey="email_team_invite|content_addition|existing_user_added"
values={{ prevLink: props.prevLink, newLink: props.newLink, teamName: props.teamName }}>
Your link has been changed from{" "}
<a href={`https://${prevLink}`}>{prevLinkWithoutProtocol}</a> to{" "}
<a href={`https://${newLink}`}>{newLinkWithoutProtocol}</a> but don&apos;t worry, all
previous links still work and redirect appropriately.
<br />
<br />
Please note: All of your personal event types have been moved into the{" "}
<strong>{teamName}</strong> organisation, which may also include potential personal link.
<br />
<br />
Please log in and make sure you have no private events on your new organisational account.
<br />
<br />
For personal events we recommend creating a new account with a personal email address.
<br />
<br />
Enjoy your new clean link: <a href={`https://${newLink}`}>{newLinkWithoutProtocol}</a>
</Trans>
</>
) : (
<>
<Trans i18nKey="email_team_invite|content|invited_to_org">
{invitedBy} has invited you to join the <strong>{teamName}</strong> organization.
</Trans>{" "}
<Trans
i18nKey="existing_user_added_link_will_change"
values={{ prevLink: props.prevLink, newLink: props.newLink, teamName: props.teamName }}>
On accepting the invite, your link will change to your organization domain but don&apos;t
worry, all previous links will still work and redirect appropriately.
<br />
<br />
Please note: All of your personal event types will be moved into the{" "}
<strong>{teamName}</strong> organisation, which may also include potential personal link.
<br />
<br />
For personal events we recommend creating a new account with a personal email address.
</Trans>
</>
)}
</>
);
}
return (
<>
{autoJoinType === "added" ? (
<Trans i18nKey="email_team_invite|content|added_to_org">
{invitedBy} has added you to the <strong>{teamName}</strong> organization.
</Trans>
) : (
<Trans i18nKey="email_team_invite|content|invited_to_org">
{invitedBy} has invited you to join the <strong>{teamName}</strong> organization.
</Trans>
)}{" "}
<Trans>
{appName} is the event-juggling scheduler that enables you and your team to schedule meetings
without the email tennis.
</Trans>
</>
);
}
if (typeOfInvite === "TO_SUBTEAM") {
return (
<>
(
{autoJoinType === "added" ? (
<Trans i18nKey="email_team_invite|content|added_to_subteam">
{invitedBy} has added you to the team <strong>{teamName}</strong> in their organization{" "}
<strong>{parentTeamName}</strong>
</Trans>
) : (
<Trans i18nKey="email_team_invite|content|invited_to_subteam">
{invitedBy} has added you to the team <strong>{teamName}</strong> in their organization{" "}
<strong>{parentTeamName}</strong>
</Trans>
)}
)
<Trans>
{appName} is the event-juggling scheduler that enables you and your team to schedule meetings
without the email tennis.
</Trans>
</>
);
}
// Regular team doesn't support auto-join. So, they have to be invited always
return props.language(`email_team_invite|content|invited_to_regular_team`, variables);
}
};
+1
View File
@@ -33,3 +33,4 @@ export { MonthlyDigestEmail } from "./MonthlyDigestEmail";
export { AdminOrganizationNotificationEmail } from "./AdminOrganizationNotificationEmail";
export { BookingRedirectEmailNotification } from "./BookingRedirectEmailNotification";
export { VerifyEmailChangeEmail } from "./VerifyEmailChangeEmail";
export { OrganizationCreationEmail } from "./OrganizationCreationEmail";