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 ProgramAuth

Steven Tey6d2991892f17
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 a1e5523808..9251bc5b96 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
@@ -19,59 +19,68 @@ export default function ProgramAuth({ children }: { children: ReactNode }) {
}
// after Dub Partners goes GA, we can combine this with the upgrade CTA below
- if (!partnersEnabled || !defaultProgramId) {
+ if (
+ partnersEnabled === false ||
+ !defaultProgramId ||
+ 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 <UpgradeCTA />;
}
return children;
}
+
+const UpgradeCTA = () => {
+ const { slug } = useWorkspace();
+ 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]" />
+ </>
+ );
+};
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/programs/[programId]/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/programs/[programId]/page-client.tsx
index ac36b3ec25..b7e4e646a3 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/programs/[programId]/page-client.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/programs/[programId]/page-client.tsx
@@ -5,7 +5,7 @@ import { ProgramRewardList } from "@/ui/partners/program-reward-list";
import { buttonVariants, Grid, useRouterStuff } from "@dub/ui";
import { cn } from "@dub/utils";
import Link from "next/link";
-import { redirect, useParams } from "next/navigation";
+import { useParams } from "next/navigation";
import { CommissionTable } from "./commissions/commission-table";
import { OverviewChart } from "./overview-chart";
import { PendingPayouts } from "./pending-payouts";
@@ -17,10 +17,6 @@ export default function ProgramOverviewPageClient() {
const { slug, programId } = useParams();
const { getQueryString } = useRouterStuff();
- if (!program) {
- redirect(`/${slug}`);
- }
-
return (
<div className="mb-10">
<div className="rounded-lg border border-neutral-200 bg-neutral-50 p-3">
@@ -45,7 +41,7 @@ export default function ProgramOverviewPageClient() {
<div className="relative flex grow flex-col justify-end">
<div className="relative p-5 pt-10">
<div className="absolute inset-0 bg-neutral-800 [mask-image:linear-gradient(to_bottom,transparent,black_30%)]" />
- {program.rewards?.[0] && (
+ {program?.rewards?.[0] && (
<div className="relative">
<h4 className="text-sm font-semibold text-neutral-200">
Rewards