The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Add the All programs Overview page skeleton
Rafic20f7f797b31
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/overview/overview-card.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/overview/overview-card.tsxnew file mode 100644index 0000000000..0a45e8974c--- /dev/null+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/overview/overview-card.tsx@@ -0,0 +1,118 @@+import { buttonVariants } from "@dub/ui";+import { cn } from "@dub/utils";+import Link from "next/link";+import { Fragment, ReactNode } from "react";++export function OverviewCard({+ title,+ viewAllHref,+ className,+ children,+}: {+ title: ReactNode;+ viewAllHref?: string;+ className?: string;+ children: ReactNode;+}) {+ return (+ <div+ className={cn(+ "flex flex-col rounded-xl border border-neutral-200 bg-white",+ className,+ )}+ >+ <div className="flex items-start justify-between gap-2 px-5 py-4">+ <h2 className="pt-0.5 text-base font-semibold leading-6 text-neutral-800">+ {title}+ </h2>+ {viewAllHref && <ViewAllButton href={viewAllHref} />}+ </div>+ {children}+ </div>+ );+}++export function ViewAllButton({ href }: { href: string }) {+ return (+ <Link+ href={href}+ className={cn(+ buttonVariants({ variant: "secondary" }),+ "flex h-7 shrink-0 items-center rounded-lg border px-2.5 text-sm font-medium",+ )}+ >+ View all+ </Link>+ );+}++export function OverviewCardList<T>({+ items,+ rowCount,+ renderItem,+ getKey,+ error,+ emptyState,+}: {+ items?: T[];+ rowCount: number;+ renderItem: (item: T) => ReactNode;+ getKey: (item: T) => string;+ error?: unknown;+ emptyState: { icon: ReactNode; title: string };+}) {+ if (error) {+ return <OverviewCardMessage icon={null} title="Failed to load data" />;+ }++ if (!items) {+ return (+ <div className="flex flex-col px-2 pb-2">+ {[...Array(rowCount)].map((_, idx) => (+ <div key={idx} className="flex h-10 items-center gap-2.5 px-3">+ <div className="size-5 shrink-0 animate-pulse rounded-full bg-neutral-200" />+ <div className="h-4 w-full max-w-32 animate-pulse rounded bg-neutral-200" />+ <div className="ml-auto h-4 w-12 shrink-0 animate-pulse rounded bg-neutral-200" />+ </div>+ ))}+ </div>+ );+ }++ if (items.length === 0) {+ return <OverviewCardMessage {...emptyState} />;+ }++ return (+ <div className="flex flex-col px-2 pb-2">+ {items.map((item, idx) => (+ <Fragment key={getKey(item)}>+ {idx > 0 && (+ <div className="px-2">+ <div className="h-px bg-neutral-100" />+ </div>+ )}+ {renderItem(item)}+ </Fragment>+ ))}+ </div>+ );+}++export function OverviewCardMessage({+ icon,+ title,+}: {+ icon: ReactNode;+ title: string;+}) {+ return (+ <div className="flex min-h-40 grow flex-col items-center justify-center gap-2 px-4 pb-4 text-xs text-neutral-500">+ {icon}+ {title}+ </div>+ );+}++export const OVERVIEW_CARD_ROW_CLASSNAME =+ "flex items-center gap-2.5 rounded-lg px-3 py-2.5";diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/overview/page-client.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/overview/page-client.tsxnew file mode 100644index 0000000000..f29020117c--- /dev/null+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/overview/page-client.tsx@@ -0,0 +1,23 @@+"use client";++import { DUB_PARTNERS_ANALYTICS_INTERVAL } from "@/lib/analytics/constants";+import { PageWidthWrapper } from "@/ui/layout/page-width-wrapper";+import SimpleDateRangePicker from "@/ui/shared/simple-date-range-picker";++export function PartnerOverviewPageClient() {+ return (+ <PageWidthWrapper className="flex flex-col gap-4 pb-10">+ <SimpleDateRangePicker+ className="w-full sm:w-fit"+ align="start"+ defaultInterval={DUB_PARTNERS_ANALYTICS_INTERVAL}+ />+ <div className="rounded-2xl bg-neutral-50 p-4">+ <div className="grid grid-cols-1 gap-4 lg:grid-cols-[minmax(0,1fr)_397px]">+ <div className="flex flex-col gap-3" />+ </div>+ </div>+ <div className="grid grid-cols-1 gap-4 lg:grid-cols-3" />+ </PageWidthWrapper>+ );+}diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/overview/page.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/overview/page.tsxnew file mode 100644index 0000000000..af19fe9a00--- /dev/null+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/overview/page.tsx@@ -0,0 +1,10 @@+import { PageContent } from "@/ui/layout/page-content";+import { PartnerOverviewPageClient } from "./page-client";++export default function PartnerOverviewPage() {+ return (+ <PageContent title="Overview">+ <PartnerOverviewPageClient />+ </PageContent>+ );+}diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/overview/use-overview-date-range.ts b/apps/web/app/(ee)/partners.dub.co/(dashboard)/overview/use-overview-date-range.tsnew file mode 100644index 0000000000..1c522dd7b9--- /dev/null+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/overview/use-overview-date-range.ts@@ -0,0 +1,28 @@+import { DUB_PARTNERS_ANALYTICS_INTERVAL } from "@/lib/analytics/constants";+import { IntervalOptions } from "@/lib/analytics/types";+import { useRouterStuff } from "@dub/ui";+import { endOfDay, startOfDay } from "date-fns";+import { useMemo } from "react";++export function useOverviewDateRange() {+ const { searchParamsObj } = useRouterStuff();++ const {+ start,+ end,+ interval = DUB_PARTNERS_ANALYTICS_INTERVAL,+ } = searchParamsObj as {+ start?: string;+ end?: string;+ interval?: IntervalOptions;+ };++ return useMemo(+ () => ({+ start: start ? startOfDay(new Date(start)) : undefined,+ end: end ? endOfDay(new Date(end)) : undefined,+ interval,+ }),+ [start, end, interval],+ );+}diff --git a/apps/web/lib/middleware/partners.ts b/apps/web/lib/middleware/partners.tsindex f2513ae9a1..3daecd468e 100644--- a/apps/web/lib/middleware/partners.ts+++ b/apps/web/lib/middleware/partners.ts@@ -10,6 +10,7 @@ import {} from "./utils/partners-redirect";const AUTHENTICATED_PATHS = [+ "/overview","/programs","/marketplace","/onboarding",