Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

improve isLegacyBusinessPlan, upgrade dub, fix typo filename

Steven Teyc6a2f0b78c58
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/auth.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/auth.tsx
index 3dcab7f8cf..6c0e86f97e 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/auth.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/auth.tsx
@@ -4,13 +4,15 @@ import { getPlanCapabilities } from "@/lib/plan-capabilities";
import useWorkspace from "@/lib/swr/use-workspace";
import LayoutLoader from "@/ui/layout/layout-loader";
import { PageContent } from "@/ui/layout/page-content";
+import { isLegacyBusinessPlan } from "@dub/utils";
import { ReactNode, useEffect, useState } from "react";
-import { PartnersUpgradeCTA } from "./partners-ugrade-cta";
+import { PartnersUpgradeCTA } from "./partners-upgrade-cta";
export default function ProgramAuth({ children }: { children: ReactNode }) {
const {
plan,
defaultProgramId,
+ payoutsLimit,
loading,
mutate: mutateWorkspace,
} = useWorkspace();
@@ -28,7 +30,11 @@ export default function ProgramAuth({ children }: { children: ReactNode }) {
return <LayoutLoader />;
}
- if (!getPlanCapabilities(plan).canManageProgram || !defaultProgramId) {
+ if (
+ !defaultProgramId ||
+ !getPlanCapabilities(plan).canManageProgram ||
+ isLegacyBusinessPlan({ plan, payoutsLimit })
+ ) {
return (
<PageContent>
<PartnersUpgradeCTA />
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners-ugrade-cta.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners-upgrade-cta.tsx
similarity index 94%
rename from apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners-ugrade-cta.tsx
rename to apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners-upgrade-cta.tsx
index 7cd2936ec6..23f183a2c7 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners-ugrade-cta.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners-upgrade-cta.tsx
@@ -3,7 +3,7 @@
import { getPlanCapabilities } from "@/lib/plan-capabilities";
import useWorkspace from "@/lib/swr/use-workspace";
import { buttonVariants } from "@dub/ui";
-import { capitalize, cn, nFormatter } from "@dub/utils";
+import { capitalize, cn, isLegacyBusinessPlan, nFormatter } from "@dub/utils";
import Link from "next/link";
import { useMemo } from "react";
@@ -14,12 +14,12 @@ export function PartnersUpgradeCTA({
title?: string;
description?: string;
}) {
- const { slug, plan, store } = useWorkspace();
+ const { slug, plan, store, payoutsLimit } = useWorkspace();
const { canManageProgram } = getPlanCapabilities(plan);
const { cta, href } = useMemo(() => {
- if (!canManageProgram) {
+ if (!canManageProgram || isLegacyBusinessPlan({ plan, payoutsLimit })) {
return {
cta: "Upgrade plan",
href: `/${slug}/upgrade`,
@@ -30,7 +30,7 @@ export function PartnersUpgradeCTA({
href: `/${slug}/program/new`,
};
}
- }, [canManageProgram, slug]);
+ }, [canManageProgram, slug, payoutsLimit]);
return (
<div className="flex min-h-[calc(100vh-60px)] flex-col items-center justify-center gap-6 overflow-hidden px-4 py-10">
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/plan-usage.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/plan-usage.tsx
index ea4b5f1101..e6517da6ad 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/plan-usage.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/plan-usage.tsx
@@ -114,7 +114,7 @@ export default function PlanUsage() {
<div className="flex flex-col items-start justify-between gap-y-4 p-6 md:px-8 lg:flex-row">
<div>
<h2 className="text-xl font-medium">
- {plan && isLegacyBusinessPlan(plan, payoutsLimit ?? 0)
+ {plan && isLegacyBusinessPlan({ plan, payoutsLimit })
? "Business (Legacy)"
: capitalize(plan)}{" "}
Plan
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/upgrade/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/upgrade/page-client.tsx
index 3ece94de5e..60ce06b91d 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/upgrade/page-client.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/upgrade/page-client.tsx
@@ -98,7 +98,10 @@ export function WorkspaceBillingUpgradePageClient() {
const disableCurrentPlan = Boolean(
stripeId &&
plan.name.toLowerCase() === currentPlan &&
- !isLegacyBusinessPlan(currentPlan, payoutsLimit ?? 0),
+ !isLegacyBusinessPlan({
+ plan: currentPlan,
+ payoutsLimit,
+ }),
);
// show downgrade button if user has a stripe id and is on the current plan
diff --git a/apps/web/app/app.dub.co/(dashboard)/account/settings/security/request-set-password.tsx b/apps/web/app/app.dub.co/(dashboard)/account/settings/security/request-set-password.tsx
index 1bea121a6d..a11cb08c2b 100644
--- a/apps/web/app/app.dub.co/(dashboard)/account/settings/security/request-set-password.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/account/settings/security/request-set-password.tsx
@@ -43,7 +43,10 @@ export const RequestSetPassword = () => {
{user?.provider && (
<>
Your account is managed by{" "}
- <span className="uppercase">{user?.provider}</span>.{" "}
+ <span className="font-medium capitalize text-neutral-700">
+ {user?.provider}
+ </span>
+ .{" "}
</>
)}
You can set a password to use with your Dub account.
diff --git a/apps/web/package.json b/apps/web/package.json
index 3b45ca23d4..5e1ddcc5f4 100644
--- a/apps/web/package.json
+++ b/apps/web/package.json
@@ -69,7 +69,7 @@
"cmdk": "^1.1.1",
"concurrently": "^8.0.1",
"date-fns": "^3.6.0",
- "dub": "^0.65.0",
+ "dub": "^0.65.1",
"fast-xml-parser": "^5.0.6",
"file-type": "^20.4.1",
"framer-motion": "^10.16.16",
diff --git a/apps/web/ui/layout/sidebar/workspace-dropdown.tsx b/apps/web/ui/layout/sidebar/workspace-dropdown.tsx
index 5a8d5d2ac8..833e279e6d 100644
--- a/apps/web/ui/layout/sidebar/workspace-dropdown.tsx
+++ b/apps/web/ui/layout/sidebar/workspace-dropdown.tsx
@@ -46,10 +46,10 @@ export function WorkspaceDropdown() {
if (slug && workspaces && selectedWorkspace) {
return {
...selectedWorkspace,
- plan: isLegacyBusinessPlan(
- selectedWorkspace.plan,
- selectedWorkspace.payoutsLimit ?? 0,
- )
+ plan: isLegacyBusinessPlan({
+ plan: selectedWorkspace.plan,
+ payoutsLimit: selectedWorkspace.payoutsLimit,
+ })
? "business (legacy)"
: selectedWorkspace.plan,
image:
diff --git a/packages/utils/src/constants/pricing.tsx b/packages/utils/src/constants/pricing.tsx
index 363bb3a732..d2d6b66d9a 100644
--- a/packages/utils/src/constants/pricing.tsx
+++ b/packages/utils/src/constants/pricing.tsx
@@ -387,5 +387,10 @@ export const isDowngradePlan = (currentPlan: string, newPlan: string) => {
return currentPlanIndex > newPlanIndex;
};
-export const isLegacyBusinessPlan = (plan: string, payoutsLimit: number) =>
- plan === "business" && payoutsLimit === 0;
+export const isLegacyBusinessPlan = ({
+ plan = "business",
+ payoutsLimit = 0,
+}: {
+ plan?: string;
+ payoutsLimit?: number;
+}) => plan === "business" && payoutsLimit === 0;
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 0f02059127..91aca9dcc9 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -197,8 +197,8 @@ importers:
specifier: ^3.6.0
version: 3.6.0
dub:
- specifier: ^0.65.0
- version: 0.65.0
+ specifier: ^0.65.1
+ version: 0.65.1
fast-xml-parser:
specifier: ^5.0.6
version: 5.0.6
@@ -6031,8 +6031,8 @@ packages:
peerDependencies:
zod: '>= 3'
- resolution: {integrity: sha512-y8rSHVhcPlnJXV9kkHiz5Zrk7SgMZIAwdQZQWJ99YIld3Ky+ssKJUEX+EX10eYDX27Jxvob37V0VoIvkwkN2AQ==}
+ resolution: {integrity: sha512-ePXPCZh+EbKUwnXi2vjZ8U78jUU9SlGNiXiLDWJZnyKo/2vwFwjFej4HHKDrw2kn2IpW4JOQ1Qp0b6Uy1/Bmmw==}
resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==}
@@ -16746,7 +16746,7 @@ snapshots:
dependencies:
zod: 3.23.8
dependencies:
zod: 3.23.8