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.

redirect to first program

Kiran Kb19f469806c2
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/programs/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/programs/page-client.tsx
new file mode 100644
index 0000000000..32b2abe5be
--- /dev/null
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/programs/page-client.tsx
@@ -0,0 +1,27 @@
+"use client";
+
+import useWorkspace from "@/lib/swr/use-workspace";
+import { ProgramProps } from "@/lib/types";
+import { fetcher } from "@dub/utils/src/functions/fetcher";
+import { notFound, redirect } from "next/navigation";
+import useSWR from "swr";
+
+export function ProgramsPageClient() {
+ const { id, slug } = useWorkspace();
+ const { data: programs, isLoading } = useSWR<ProgramProps[]>(
+ `/api/programs?workspaceId=${id}`,
+ fetcher,
+ );
+
+ if (isLoading) {
+ return null;
+ }
+
+ const firstProgramId = programs?.[0]?.id;
+
+ if (!firstProgramId) {
+ notFound();
+ }
+
+ redirect(`/${slug}/programs/${firstProgramId}`);
+}
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/programs/page.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/programs/page.tsx
index 33c7f7044b..4115255c07 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/programs/page.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/programs/page.tsx
@@ -1,5 +1,10 @@
import { PageContent } from "@/ui/layout/page-content";
+import { ProgramsPageClient } from "./page-client";
export default function Programs() {
- return <PageContent title="Programs" />;
+ return (
+ <PageContent>
+ <ProgramsPageClient />
+ </PageContent>
+ );
}
diff --git a/apps/web/ui/layout/sidebar/app-sidebar-nav.tsx b/apps/web/ui/layout/sidebar/app-sidebar-nav.tsx
index 174d760808..f6de1b721b 100644
--- a/apps/web/ui/layout/sidebar/app-sidebar-nav.tsx
+++ b/apps/web/ui/layout/sidebar/app-sidebar-nav.tsx
@@ -67,7 +67,7 @@ const NAV_AREAS: SidebarNavAreas<{
name: "Partnerships",
items: [
{
- name: "Programs",
+ name: "Affiliate Program",
icon: TableIcon,
href: `/${slug}/programs`,
},