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.

fix upgrade state

Steven Tey6b4aab35a28d
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/programs/[programId]/auth.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/programs/[programId]/auth.tsx
index 940eb484b8..a1e5523808 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/programs/[programId]/auth.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/programs/[programId]/auth.tsx
@@ -1,21 +1,77 @@
"use client";
-import useProgram from "@/lib/swr/use-program";
+import { getPlanCapabilities } from "@/lib/plan-capabilities";
+import useWorkspace from "@/lib/swr/use-workspace";
import LayoutLoader from "@/ui/layout/layout-loader";
-import { redirect, useParams } from "next/navigation";
+import { buttonVariants } from "@dub/ui";
+import { cn } from "@dub/utils";
+import Image from "next/image";
+import Link from "next/link";
+import { redirect } from "next/navigation";
import { ReactNode } from "react";
export default function ProgramAuth({ children }: { children: ReactNode }) {
- const { slug } = useParams();
- const { loading, error } = useProgram();
+ const { slug, plan, defaultProgramId, partnersEnabled, loading } =
+ useWorkspace();
if (loading) {
return <LayoutLoader />;
}
- if (error && error.status === 404) {
+ // after Dub Partners goes GA, we can combine this with the upgrade CTA below
+ if (!partnersEnabled || !defaultProgramId) {
redirect(`/${slug}`);
}
+ if (!getPlanCapabilities(plan).canManageProgram) {
+ return (
+ <>
+ <div className="absolute inset-0 flex touch-pan-y flex-col items-center justify-center bg-gradient-to-t from-[#fff_75%] to-[#fff6] px-4 text-center">
+ <div className="h-40 w-full max-w-[480px] overflow-hidden [mask-image:linear-gradient(black,transparent)]">
+ <div className="relative h-96 w-full overflow-hidden rounded-lg border border-neutral-200">
+ <Image
+ src="https://assets.dub.co/misc/partners-screenshot.jpg"
+ fill
+ className="object-contain object-top"
+ alt="Dub Partners screenshot"
+ draggable={false}
+ />
+ </div>
+ </div>
+ <div className="relative -mt-4 flex flex-col items-center justify-center">
+ <span className="text-lg font-semibold text-neutral-700">
+ Dub Partners
+ </span>
+ <p className="mt-3 max-w-sm text-pretty text-sm text-neutral-500">
+ Kickstart viral product-led growth with powerful, branded referral
+ and affiliate programs.{" "}
+ <a
+ href="https://dub.co/partners"
+ target="_blank"
+ className="underline underline-offset-2 hover:text-neutral-800"
+ >
+ Learn more ↗
+ </a>
+ </p>
+ <div className="mt-4">
+ <Link
+ href={`/${slug}/upgrade`}
+ className={cn(
+ buttonVariants({ variant: "secondary" }),
+ "flex h-8 items-center justify-center gap-2 rounded-md border px-4 text-sm",
+ )}
+ >
+ <span className="bg-gradient-to-r from-violet-600 to-pink-600 bg-clip-text text-transparent">
+ Upgrade to Business
+ </span>
+ </Link>
+ </div>
+ </div>
+ </div>
+ <div className="h-[420px]" />
+ </>
+ );
+ }
+
return children;
}
diff --git a/apps/web/lib/plan-capabilities.ts b/apps/web/lib/plan-capabilities.ts
index 2a96c86230..100b1c0237 100644
--- a/apps/web/lib/plan-capabilities.ts
+++ b/apps/web/lib/plan-capabilities.ts
@@ -8,5 +8,6 @@ export const getPlanCapabilities = (
canAddFolder: !!plan && !["free"].includes(plan),
canManageFolderPermissions: !!plan && !["free", "pro"].includes(plan), // default access level is write
canManageCustomers: !!plan && !["free", "pro"].includes(plan),
+ canManageProgram: !!plan && !["free", "pro"].includes(plan),
};
};