The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
plan guards
Steven Teyeb0954f3531e
diff --git a/apps/web/app/api/workspaces/[idOrSlug]/billing/cancel/route.ts b/apps/web/app/api/workspaces/[idOrSlug]/billing/cancel/route.tsindex 99d8cee98b..973929ced0 100644--- a/apps/web/app/api/workspaces/[idOrSlug]/billing/cancel/route.ts+++ b/apps/web/app/api/workspaces/[idOrSlug]/billing/cancel/route.ts@@ -14,6 +14,14 @@ export const POST = withWorkspace(});}+ if (workspace.plan === "enterprise") {+ throw new DubApiError({+ code: "forbidden",+ message:+ "Since you're on an Enterprise plan, billing is managed by your account team. Please reach out to them to manage your subscription.",+ });+ }+try {const { data } = await stripe.subscriptions.list({customer: workspace.stripeId,diff --git a/apps/web/app/api/workspaces/[idOrSlug]/billing/manage/route.ts b/apps/web/app/api/workspaces/[idOrSlug]/billing/manage/route.tsindex 0bfe706007..dea771f30d 100644--- a/apps/web/app/api/workspaces/[idOrSlug]/billing/manage/route.ts+++ b/apps/web/app/api/workspaces/[idOrSlug]/billing/manage/route.ts@@ -10,6 +10,15 @@ export const POST = withWorkspace(if (!workspace.stripeId) {return new Response("No Stripe customer ID", { status: 400 });}++ if (workspace.plan === "enterprise") {+ throw new DubApiError({+ code: "forbidden",+ message:+ "Since you're on an Enterprise plan, billing is managed by your account team. Please reach out to them to manage your subscription.",+ });+ }+try {const { url } = await stripe.billingPortal.sessions.create({customer: workspace.stripeId,diff --git a/apps/web/ui/workspaces/subscription-menu.tsx b/apps/web/ui/workspaces/subscription-menu.tsxindex c7172bb452..c4e0734427 100644--- a/apps/web/ui/workspaces/subscription-menu.tsx+++ b/apps/web/ui/workspaces/subscription-menu.tsx@@ -139,6 +139,10 @@ export default function SubscriptionMenu() {}};+ if (plan === "enterprise") {+ return null;+ }+return (<><PlanChangeConfirmationModal />@@ -155,18 +159,16 @@ export default function SubscriptionMenu() {onSelect={() => openBillingPortal()}disabledTooltip={permissionsError}/>- {plan !== "enterprise" && (- <MenuItem- icon={SquareXmark}- label="Cancel subscription"- onSelect={handleCancelSubscription}- disabledTooltip={- subscriptionCanceledAt- ? "Your subscription has already been scheduled for cancellation."- : permissionsError- }- />- )}+ <MenuItem+ icon={SquareXmark}+ label="Cancel subscription"+ onSelect={handleCancelSubscription}+ disabledTooltip={+ subscriptionCanceledAt+ ? "Your subscription has already been scheduled for cancellation."+ : permissionsError+ }+ /></Command.List></Command>}