The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Overview page layout
Tim Wilson8c88083b35a9
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/page-client.tsxindex 015351e0d1..7a7712e9ec 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/page-client.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/page-client.tsx@@ -1,89 +1,62 @@"use client";+import { DUB_PARTNERS_ANALYTICS_INTERVAL } from "@/lib/analytics/constants";import useProgram from "@/lib/swr/use-program";-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 SimpleDateRangePicker from "@/ui/shared/simple-date-range-picker";+import { useRouterStuff } from "@dub/ui";+import { IntervalOptions } from "date-fns";import { useParams } from "next/navigation";-import { CommissionTable } from "./commissions/commission-table";-import { OverviewChart } from "./overview-chart";-import { PendingPayouts } from "./pending-payouts";-import { ProgramMetrics } from "./program-metrics";-import { TopPartners } from "./top-partners";+import { ContextType, createContext, useMemo } from "react";++export const ProgramOverviewContext = createContext<{+ start?: string;+ end?: string;+ interval?: IntervalOptions;+}>({});export default function ProgramOverviewPageClient() {const { program } = useProgram();const { slug } = useParams();const { getQueryString } = useRouterStuff();+ const { searchParamsObj } = useRouterStuff();++ const { start, end, interval } = useMemo(+ () =>+ ({+ interval: DUB_PARTNERS_ANALYTICS_INTERVAL,+ ...searchParamsObj,+ }) as ContextType<typeof ProgramOverviewContext>,+ [searchParamsObj],+ );+return (- <div className="mb-10">- <div className="rounded-lg border border-neutral-200 bg-neutral-50 p-3">- <div className="grid grid-cols-1 gap-6 lg:grid-cols-[minmax(0,5fr)_minmax(0,3fr)] lg:gap-10">- <OverviewChart />- <div className="relative flex flex-col overflow-hidden rounded-lg bg-neutral-800">- <Grid className="text-white/5" cellSize={20} />- <div className="relative flex items-center justify-between p-5">- <h3 className="text-base font-semibold text-neutral-50">- Program- </h3>- <Link- href={`/${slug}/program/settings`}- className={cn(- buttonVariants({ variant: "secondary" }),- "flex h-7 items-center rounded-md border px-2 text-sm",- )}- >- Edit Program- </Link>- </div>- <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] && (- <div className="relative">- <h4 className="text-sm font-semibold text-neutral-200">- Rewards- </h4>- <ProgramRewardList- rewards={program.rewards}- discount={program.discounts?.[0]}- className="mt-2 border-neutral-600 bg-neutral-700 text-neutral-300 [&_li>svg]:text-neutral-50"- />- </div>- )}- </div>- </div>- </div>+ <div className="@container flex flex-col gap-6">+ <SimpleDateRangePicker align="start" className="w-fit" />+ <div className="@4xl:grid-cols-[minmax(0,1fr)_400px] grid grid-cols-1 gap-6 rounded-2xl bg-neutral-100 p-4">+ {/* Chart */}+ <div className="border-border-subtle @4xl:h-full h-96 rounded-[0.625rem] border bg-white"></div>++ <div className="@4xl:grid-cols-1 grid grid-cols-2 gap-6">+ {/* Tasks */}+ <div className="border-border-subtle h-48 rounded-[0.625rem] border bg-white"></div>++ {/* Program links */}+ <div className="border-border-subtle h-48 rounded-[0.625rem] border bg-white"></div></div></div>- <div className="mt-6">- <ProgramMetrics />+ <div className="@2xl:grid-cols-2 @4xl:grid-cols-3 grid grid-cols-1 gap-6">+ {[...Array(6)].map((_, idx) => (+ <div+ key={idx}+ className="border-border-subtle h-64 rounded-[0.625rem] border bg-white"+ ></div>+ ))}</div>- <div className="mt-6 grid grid-cols-1 gap-6 md:grid-cols-2">+ {/* <div className="mt-6 grid grid-cols-1 gap-6 md:grid-cols-2"><TopPartners /><PendingPayouts />- </div>-- <div className="mt-6">- <div className="flex items-center justify-between pb-3">- <h2 className="text-base font-semibold text-neutral-900">- Recent commissions- </h2>-- <Link- href={`/${slug}/program/commissions${getQueryString()}`}- className={cn(- buttonVariants({ variant: "secondary" }),- "flex h-8 items-center rounded-lg border px-2 text-sm",- )}- >- View all- </Link>- </div>- <CommissionTable limit={10} />- </div>+ </div> */}</div>);}diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/page.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/page.tsxindex eaa8995232..4051e9920e 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/page.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/page.tsx@@ -5,7 +5,7 @@ import ProgramOverviewPageClient from "./page-client";export default async function ProgramOverviewPage() {return (<PageContent title="Overview">- <PageWidthWrapper>+ <PageWidthWrapper className="mb-10"><ProgramOverviewPageClient /></PageWidthWrapper></PageContent>diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/program-metrics.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/program-metrics.tsxdeleted file mode 100644index 6d84f57732..0000000000--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/program-metrics.tsx+++ /dev/null@@ -1,101 +0,0 @@-import useProgramMetrics from "@/lib/swr/use-program-metrics";-import { Icon } from "@dub/ui";-import { Check2, CircleDollar, MoneyBills2, Users } from "@dub/ui/icons";-import NumberFlow from "@number-flow/react";-import Link from "next/link";-import { useParams } from "next/navigation";--export function ProgramMetrics() {- const { metrics, error } = useProgramMetrics();-- return (- <div className="grid grid-cols-1 divide-neutral-200 overflow-hidden rounded-lg border border-neutral-200 max-md:divide-y md:grid-cols-4 md:divide-x">- <Stat- icon={Users}- label="Partners"- tab="partners"- value={metrics?.partnersCount}- error={error}- />- <Stat- icon={Check2}- label="Sales"- tab="commissions" // TODO update to program analytics sales tab- value={metrics?.commissionsCount}- error={error}- />- <Stat- icon={CircleDollar}- label="Commissions"- value={metrics?.commissions}- tab="commissions"- error={error}- isCurrency- />- <Stat- icon={MoneyBills2}- label="Payouts"- tab="payouts"- value={metrics?.payouts}- error={error}- isCurrency- />- </div>- );-}--function Stat({- icon: Icon,- label,- value,- tab,- error,- isCurrency = false,-}: {- icon: Icon;- label: string;- value: number | undefined;- tab: string;- error: boolean;- isCurrency?: boolean;-}) {- const { slug } = useParams();- const isLoading = value === undefined && !error;-- return (- <Link- href={`/${slug}/program/${tab}`}- className="flex flex-row items-center gap-x-4 gap-y-5 p-3 transition-colors hover:bg-neutral-50 md:flex-col md:items-start lg:p-5"- >- <div className="flex size-10 items-center justify-center rounded-md bg-neutral-100">- <Icon className="size-4 text-neutral-900" />- </div>- <div className="w-full">- <div className="text-sm text-neutral-500">{label}</div>- {isLoading ? (- <div className="h-7 w-24 animate-pulse rounded-md bg-neutral-200 md:mt-2.5 md:h-8 lg:h-11" />- ) : (- <div className="truncate text-xl text-neutral-800 md:mt-2 md:text-2xl lg:text-3xl">- {error ? (- "-"- ) : (- <NumberFlow- value={isCurrency ? value! / 100 : value || 0}- format={- isCurrency- ? {- style: "currency",- currency: "USD",- // @ts-ignore – trailingZeroDisplay is a valid option but TS is outdated- trailingZeroDisplay: "stripIfInteger",- }- : undefined- }- />- )}- </div>- )}- </div>- </Link>- );-}