From 4541f0d7141e4a89758ff8176294d43ce7352016 Mon Sep 17 00:00:00 2001 From: Rajiv Sahal Date: Thu, 16 May 2024 13:21:20 +0530 Subject: [PATCH] fix: platform onboarding improvements (#15053) * allow stripe to display promo codes option * fix layout issues for tablet devices * redirect platform users to new platform onboarding --- .../billing/services/billing.service.ts | 1 + .../platform/pricing/billing-card/index.tsx | 4 +- .../pricing/platform-pricing/index.tsx | 42 ++++++++++--------- apps/web/pages/signup.tsx | 36 ++++++++++++---- 4 files changed, 54 insertions(+), 29 deletions(-) diff --git a/apps/api/v2/src/modules/billing/services/billing.service.ts b/apps/api/v2/src/modules/billing/services/billing.service.ts index 445c9208e7..aa0f4b0cab 100644 --- a/apps/api/v2/src/modules/billing/services/billing.service.ts +++ b/apps/api/v2/src/modules/billing/services/billing.service.ts @@ -75,6 +75,7 @@ export class BillingService { plan: plan.toString(), }, }, + allow_promotion_codes: true, }); if (!url) throw new InternalServerErrorException("Failed to create Stripe session."); diff --git a/apps/web/components/settings/platform/pricing/billing-card/index.tsx b/apps/web/components/settings/platform/pricing/billing-card/index.tsx index 6c4260df2e..e277bdd263 100644 --- a/apps/web/components/settings/platform/pricing/billing-card/index.tsx +++ b/apps/web/components/settings/platform/pricing/billing-card/index.tsx @@ -18,9 +18,9 @@ export const PlatformBillingCard = ({ handleSubscribe, }: PlatformBillingCardProps) => { return ( -
+
-

{plan}

+

{plan}

{description}

{pricing && ( diff --git a/apps/web/components/settings/platform/pricing/platform-pricing/index.tsx b/apps/web/components/settings/platform/pricing/platform-pricing/index.tsx index 9e10216e46..580ca5420c 100644 --- a/apps/web/components/settings/platform/pricing/platform-pricing/index.tsx +++ b/apps/web/components/settings/platform/pricing/platform-pricing/index.tsx @@ -27,26 +27,28 @@ export const PlatformPricing = ({ teamId }: PlatformPricingProps) => {

Subscribe to Platform

-
- {platformPlans.map((plan) => { - return ( -
- { - !!teamId && - (plan.plan === "Enterprise" - ? router.push("https://i.cal.com/sales/exploration") - : mutateAsync({ plan: plan.plan.toLocaleUpperCase() })); - }} - /> -
- ); - })} +
+
+ {platformPlans.map((plan) => { + return ( +
+ { + !!teamId && + (plan.plan === "Enterprise" + ? router.push("https://i.cal.com/sales/exploration") + : mutateAsync({ plan: plan.plan.toLocaleUpperCase() })); + }} + /> +
+ ); + })} +
); diff --git a/apps/web/pages/signup.tsx b/apps/web/pages/signup.tsx index 9c182c0608..aa7f51a432 100644 --- a/apps/web/pages/signup.tsx +++ b/apps/web/pages/signup.tsx @@ -234,6 +234,7 @@ export default function Signup({ }; const isOrgInviteByLink = orgSlug && !prepopulateFormValues?.username; + const isPlatformUser = redirectUrl?.includes("platform") && redirectUrl?.includes("new"); const signUp: SubmitHandler = async (_data) => { const { cfToken, ...data } = _data; @@ -255,14 +256,35 @@ export default function Signup({ pushGTMEvent("create_account", { email: data.email, user: data.username, lang: data.language }); telemetry.event(telemetryEventTypes.signup, collectPageParameters()); + const verifyOrGettingStarted = emailVerificationEnabled ? "auth/verify-email" : "getting-started"; - const callBackUrl = `${ - searchParams?.get("callbackUrl") - ? isOrgInviteByLink - ? `${WEBAPP_URL}/${searchParams.get("callbackUrl")}` - : addOrUpdateQueryParam(`${WEBAPP_URL}/${searchParams.get("callbackUrl")}`, "from", "signup") - : `${WEBAPP_URL}/${verifyOrGettingStarted}?from=signup` - }`; + const gettingStartedWithPlatform = "settings/platform/new"; + + const constructCallBackIfUrlPresent = () => { + if (isOrgInviteByLink) { + return `${WEBAPP_URL}/${searchParams.get("callbackUrl")}`; + } + + return addOrUpdateQueryParam(`${WEBAPP_URL}/${searchParams.get("callbackUrl")}`, "from", "signup"); + }; + + const constructCallBackIfUrlNotPresent = () => { + if (!!isPlatformUser) { + return `${WEBAPP_URL}/${gettingStartedWithPlatform}?from=signup`; + } + + return `${WEBAPP_URL}/${verifyOrGettingStarted}?from=signup`; + }; + + const constructCallBackUrl = () => { + const callbackUrlSearchParams = searchParams?.get("callbackUrl"); + + return !!callbackUrlSearchParams + ? constructCallBackIfUrlPresent() + : constructCallBackIfUrlNotPresent(); + }; + + const callBackUrl = constructCallBackUrl(); await signIn<"credentials">("credentials", { ...data,