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.

Start the Programs page on the table for partners with many programs

Rafi25bba033073b
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/page-client.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/page-client.tsx
index 556025877e..afb02a3684 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/page-client.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/page-client.tsx
@@ -13,7 +13,11 @@ import { SimpleEmptyState } from "@/ui/shared/simple-empty-state";
import { ToggleGroup, useLocalStorage, useRouterStuff } from "@dub/ui";
import { GridIcon, HexadecagonStar, TableRows2 } from "@dub/ui/icons";
import { useId } from "react";
-import { PROGRAM_TABS, ProgramTab } from "./program-tabs";
+import {
+ PROGRAM_TABS,
+ PROGRAMS_TABLE_VIEW_THRESHOLD,
+ ProgramTab,
+} from "./program-tabs";
import { ProgramsTable } from "./programs-table";
type ProgramsView = "grid" | "table";
@@ -21,9 +25,10 @@ type ProgramsView = "grid" | "table";
export function PartnersDashboardPageClient() {
const { searchParams, queryParams } = useRouterStuff();
- const [view, setView] = useLocalStorage<ProgramsView>(
+ // null until the partner chooses a view with the toggle
+ const [savedView, setView] = useLocalStorage<ProgramsView | null>(
"partner-programs-view",
- "grid",
+ null,
);
const search = searchParams.get("search") || undefined;
@@ -51,6 +56,16 @@ export function PartnersDashboardPageClient() {
? PROGRAM_TABS[0]
: undefined);
+ const view: ProgramsView | undefined =
+ savedView ??
+ (statusCounts
+ ? statusCounts.approved > PROGRAMS_TABLE_VIEW_THRESHOLD
+ ? "table"
+ : "grid"
+ : statusCountsError
+ ? "grid"
+ : undefined);
+
// the Inactive tab shows only when the partner has an inactive program
const tabs = PROGRAM_TABS.filter(
(programTab) =>
@@ -82,7 +97,7 @@ export function PartnersDashboardPageClient() {
label: <TableRows2 className="size-4" />,
},
]}
- selected={view}
+ selected={view ?? ""}
selectAction={(option) => setView(option as ProgramsView)}
/>
</div>
@@ -107,7 +122,7 @@ export function PartnersDashboardPageClient() {
}
/>
<div className="border-border-subtle -mx-px -mb-px overflow-clip rounded-xl border bg-white">
- {tab ? (
+ {tab && view ? (
<ProgramsTabContent
tab={tab}
search={search}
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/program-tabs.ts b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/program-tabs.ts
index 5cc32ddd60..70240a263b 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/program-tabs.ts
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/program-tabs.ts
@@ -69,3 +69,7 @@ export type ProgramTab = (typeof PROGRAM_TABS)[number];
export type ProgramTabId = ProgramTab["id"];
export const PROGRAMS_TABLE_PAGE_SIZE = 10;
+
+// without a saved view, the page starts on the table for partners with more
+// active programs than this
+export const PROGRAMS_TABLE_VIEW_THRESHOLD = 6;