Skip to content

Commit 00464ef

Browse files
fix(den-web): stop forcing checkout on uncertain signup routing (#1290)
Only send auth and checkout-return flows to /checkout when billing explicitly says the base plan is required. If billing is still loading or temporarily unavailable, fall back to the org dashboard instead of forcing a checkout screen.
1 parent 380db2e commit 00464ef

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

ee/apps/den-web/app/(den)/_providers/den-flow-provider.tsx

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,14 @@ export function DenFlowProvider({ children }: { children: ReactNode }) {
344344
});
345345
}
346346

347+
function shouldRouteToCheckout(summary: BillingSummary | null | undefined) {
348+
if (!summary) {
349+
return false;
350+
}
351+
352+
return summary.featureGateEnabled && summary.checkoutRequired && !summary.hasActivePlan;
353+
}
354+
347355
function setAuthMode(mode: AuthMode) {
348356
setAuthModeState(mode);
349357
setVerificationRequired(false);
@@ -1057,11 +1065,8 @@ export function DenFlowProvider({ children }: { children: ReactNode }) {
10571065

10581066
persistOnboardingIntent(intent);
10591067
const summary = await refreshBilling({ includeCheckout: true, quiet: true });
1060-
if (!summary) {
1061-
return "checkout" as const;
1062-
}
10631068

1064-
return !summary.featureGateEnabled || summary.hasActivePlan ? ("dashboard" as const) : ("checkout" as const);
1069+
return shouldRouteToCheckout(summary) ? ("checkout" as const) : ("dashboard" as const);
10651070
}
10661071

10671072
async function resolveUserLandingRoute() {
@@ -1084,11 +1089,7 @@ export function DenFlowProvider({ children }: { children: ReactNode }) {
10841089
billingSummary ??
10851090
(billingBusy || billingCheckoutBusy ? null : await refreshBilling({ includeCheckout: true, quiet: true }));
10861091

1087-
if (!summary) {
1088-
return "/checkout";
1089-
}
1090-
1091-
return !summary.featureGateEnabled || summary.hasActivePlan ? (dashboardRoute ?? "/") : "/checkout";
1092+
return shouldRouteToCheckout(summary) ? "/checkout" : (dashboardRoute ?? "/");
10921093
}
10931094

10941095
async function submitAuth(event: FormEvent<HTMLFormElement>) {
@@ -1744,15 +1745,10 @@ export function DenFlowProvider({ children }: { children: ReactNode }) {
17441745
}
17451746

17461747
const summary = await refreshBilling({ includeCheckout: false, quiet: true });
1747-
if (!summary) {
1748-
return "/checkout" as const;
1749-
}
1750-
1751-
if (!summary.featureGateEnabled || summary.hasActivePlan) {
1752-
return (await resolveDashboardRoute()) ?? "/";
1753-
}
17541748

1755-
return "/checkout" as const;
1749+
return shouldRouteToCheckout(summary)
1750+
? ("/checkout" as const)
1751+
: ((await resolveDashboardRoute()) ?? "/");
17561752
}
17571753

17581754
function selectWorker(item: WorkerListItem) {

0 commit comments

Comments
 (0)