Skip to content

Commit 48535e1

Browse files
committed
isLegacyBusinessPlan
1 parent 39c9d38 commit 48535e1

File tree

4 files changed

+25
-3
lines changed

4 files changed

+25
-3
lines changed

apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/plan-usage.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
INFINITY_NUMBER,
2626
nFormatter,
2727
} from "@dub/utils";
28+
import { isLegacyBusinessPlan } from "@dub/utils/src/constants/pricing";
2829
import NumberFlow from "@number-flow/react";
2930
import Link from "next/link";
3031
import { CSSProperties, useMemo } from "react";
@@ -112,7 +113,12 @@ export default function PlanUsage() {
112113
<div className="rounded-lg border border-neutral-200 bg-white">
113114
<div className="flex flex-col items-start justify-between gap-y-4 p-6 md:px-8 lg:flex-row">
114115
<div>
115-
<h2 className="text-xl font-medium">{capitalize(plan)} Plan</h2>
116+
<h2 className="text-xl font-medium">
117+
{plan && isLegacyBusinessPlan(plan, payoutsLimit ?? 0)
118+
? "Business (Legacy)"
119+
: capitalize(plan)}{" "}
120+
Plan
121+
</h2>
116122
{billingStart && billingEnd && (
117123
<p className="mt-1.5 text-balance text-sm font-medium leading-normal text-neutral-700">
118124
<>

apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/upgrade/page-client.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
Users2,
1616
} from "@dub/ui";
1717
import { cn, isDowngradePlan, PLAN_COMPARE_FEATURES, PLANS } from "@dub/utils";
18+
import { isLegacyBusinessPlan } from "@dub/utils/src/constants/pricing";
1819
import NumberFlow from "@number-flow/react";
1920
import { ChevronLeft, ChevronRight } from "lucide-react";
2021
import Link from "next/link";
@@ -38,7 +39,7 @@ const plans = ["Pro", "Business", "Advanced", "Enterprise"].map(
3839
);
3940

4041
export function WorkspaceBillingUpgradePageClient() {
41-
const { slug, plan: currentPlan, stripeId } = useWorkspace();
42+
const { slug, plan: currentPlan, stripeId, payoutsLimit } = useWorkspace();
4243

4344
const [mobilePlanIndex, setMobilePlanIndex] = useState(0);
4445
const [period, setPeriod] = useState<"monthly" | "yearly">("yearly");
@@ -91,8 +92,13 @@ export function WorkspaceBillingUpgradePageClient() {
9192
{plans.map((plan, idx) => {
9293
// disable upgrade button if user has a Stripe ID and is on the current plan
9394
// (if there's no stripe id, they could be on a free trial so they should be able to upgrade)
95+
// edge case:
96+
// if the user is on the business plan and has a payout limit of 0,
97+
// it means they're on the legacy business plan – prompt them to upgrade to the new business plan
9498
const disableCurrentPlan = Boolean(
95-
stripeId && plan.name.toLowerCase() === currentPlan,
99+
stripeId &&
100+
plan.name.toLowerCase() === currentPlan &&
101+
!isLegacyBusinessPlan(currentPlan, payoutsLimit ?? 0),
96102
);
97103

98104
// show downgrade button if user has a stripe id and is on the current plan

apps/web/ui/layout/sidebar/workspace-dropdown.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
} from "@dub/ui";
1212
import { Check2, Gear, Plus, UserPlus } from "@dub/ui/icons";
1313
import { cn } from "@dub/utils";
14+
import { isLegacyBusinessPlan } from "@dub/utils/src/constants/pricing";
1415
import { useSession } from "next-auth/react";
1516
import Link from "next/link";
1617
import { useParams, usePathname } from "next/navigation";
@@ -45,6 +46,12 @@ export function WorkspaceDropdown() {
4546
if (slug && workspaces && selectedWorkspace) {
4647
return {
4748
...selectedWorkspace,
49+
plan: isLegacyBusinessPlan(
50+
selectedWorkspace.plan,
51+
selectedWorkspace.payoutsLimit ?? 0,
52+
)
53+
? "business (legacy)"
54+
: selectedWorkspace.plan,
4855
image:
4956
selectedWorkspace.logo ||
5057
`https://avatar.vercel.sh/${selectedWorkspace.id}`,

packages/utils/src/constants/pricing.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,3 +370,6 @@ export const isDowngradePlan = (currentPlan: string, newPlan: string) => {
370370
);
371371
return currentPlanIndex > newPlanIndex;
372372
};
373+
374+
export const isLegacyBusinessPlan = (plan: string, payoutsLimit: number) =>
375+
plan === "business" && payoutsLimit === 0;

0 commit comments

Comments
 (0)