Skip to content

Commit 91cea2d

Browse files
committed
[Dashboard] Fix stripe redirect for onboarding flow (#5499)
## Problem solved Short description of the bug fixed or feature added <!-- start pr-codex --> --- ## PR-Codex overview This PR focuses on adding a `redirectPath` prop across various components in the onboarding and billing sections of the application, enhancing navigation after specific actions. ### Detailed summary - Added `redirectPath` prop to `LazyOnboardingUI` in `LoginPage.tsx`. - Introduced `redirectPath` in `OnboardingChoosePlan` component. - Passed `redirectPath` from `OnboardingUI` to `OnboardingChoosePlan`. - Updated `PricingCard` to accept and utilize `redirectPath`. - Implemented `redirectPath` in the `BillingPricing` component for `PricingCard` instances. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent d9a63a6 commit 91cea2d

File tree

5 files changed

+18
-1
lines changed

5 files changed

+18
-1
lines changed

apps/dashboard/src/@/components/blocks/pricing-card.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ type PricingCardProps = {
3232
current?: boolean;
3333
canTrialGrowth?: boolean;
3434
activeTrialEndsAt?: string;
35+
redirectPath: string;
3536
};
3637

3738
export const PricingCard: React.FC<PricingCardProps> = ({
@@ -42,6 +43,7 @@ export const PricingCard: React.FC<PricingCardProps> = ({
4243
current = false,
4344
canTrialGrowth = false,
4445
activeTrialEndsAt,
46+
redirectPath,
4547
}) => {
4648
const plan = TEAM_PLANS[billingPlan];
4749
const isCustomPrice = typeof plan.price === "string";
@@ -129,6 +131,7 @@ export const PricingCard: React.FC<PricingCardProps> = ({
129131
variant={cta.variant || "outline"}
130132
teamSlug={teamSlug}
131133
sku={billingPlan === "starter" ? "plan:starter" : "plan:growth"}
134+
redirectPath={redirectPath}
132135
>
133136
{cta.title}
134137
</CheckoutButton>

apps/dashboard/src/app/login/LoginPage.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,11 @@ function PageContent(props: {
151151
if (screen.id === "onboarding") {
152152
return (
153153
<Suspense fallback={<LoadingCard />}>
154-
<LazyOnboardingUI account={screen.account} onComplete={onComplete} />
154+
<LazyOnboardingUI
155+
account={screen.account}
156+
onComplete={onComplete}
157+
redirectPath={props.nextPath || "/team"}
158+
/>
155159
</Suspense>
156160
);
157161
}

apps/dashboard/src/app/login/onboarding/ChoosePlan.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export function OnboardingChoosePlan(props: {
99
skipPlan: () => Promise<void>;
1010
canTrialGrowth: boolean;
1111
teamSlug: string;
12+
redirectPath: string;
1213
}) {
1314
return (
1415
<div>
@@ -29,6 +30,7 @@ export function OnboardingChoosePlan(props: {
2930
category: "account",
3031
},
3132
}}
33+
redirectPath={props.redirectPath}
3234
/>
3335

3436
<PricingCard
@@ -45,6 +47,7 @@ export function OnboardingChoosePlan(props: {
4547
}}
4648
canTrialGrowth={props.canTrialGrowth}
4749
highlighted
50+
redirectPath={props.redirectPath}
4851
/>
4952
</div>
5053

apps/dashboard/src/app/login/onboarding/on-boarding-ui.client.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ type OnboardingScreen =
2020
function OnboardingUI(props: {
2121
account: Account;
2222
onComplete: () => void;
23+
// path to redirect from stripe
24+
redirectPath: string;
2325
}) {
2426
const { account } = props;
2527
const [screen, setScreen] = useState<OnboardingScreen>({ id: "onboarding" });
@@ -128,6 +130,7 @@ function OnboardingUI(props: {
128130

129131
{screen.id === "plan" && (
130132
<OnboardingChoosePlan
133+
redirectPath={props.redirectPath}
131134
teamSlug={screen.team.slug}
132135
skipPlan={async () => {
133136
await skipOnboarding().catch(() => {});

apps/dashboard/src/components/settings/Account/Billing/Pricing.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export const BillingPricing: React.FC<BillingPricingProps> = ({
1818
team,
1919
trialPeriodEndedAt,
2020
}) => {
21+
const pagePath = `/team/${team.slug}/~/settings/billing`;
2122
const validTeamPlan = getValidTeamPlan(team);
2223
const contactUsHref = "/contact-us";
2324

@@ -102,6 +103,7 @@ export const BillingPricing: React.FC<BillingPricingProps> = ({
102103
<div className="grid grid-cols-1 gap-6 xl:grid-cols-3">
103104
{/* Starter */}
104105
<PricingCard
106+
redirectPath={pagePath}
105107
billingPlan="starter"
106108
current={validTeamPlan === "starter"}
107109
cta={
@@ -120,6 +122,7 @@ export const BillingPricing: React.FC<BillingPricingProps> = ({
120122

121123
{/* Growth */}
122124
<PricingCard
125+
redirectPath={pagePath}
123126
billingPlan="growth"
124127
activeTrialEndsAt={
125128
validTeamPlan === "growth" ? trialPeriodEndedAt : undefined
@@ -149,6 +152,7 @@ export const BillingPricing: React.FC<BillingPricingProps> = ({
149152
/>
150153

151154
<PricingCard
155+
redirectPath={pagePath}
152156
billingPlan="pro"
153157
teamSlug={team.slug}
154158
current={validTeamPlan === "pro"}

0 commit comments

Comments
 (0)