The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Add Top links by earnings to the All programs Overview page
Rafi17f3a42c2a09
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.tsxindex cba9ac3c35..7e8038b31f 100644--- 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.tsx@@ -22,7 +22,7 @@ export function OverviewCard({)}><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">+ <h2 className="min-h-7 pt-0.5 text-base font-semibold leading-6 text-neutral-800">{title}</h2>{viewAllHref && <ViewAllButton href={viewAllHref} />}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.tsxindex ab317b7a9f..fb626deb0c 100644--- 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.tsx@@ -6,6 +6,7 @@ import SimpleDateRangePicker from "@/ui/shared/simple-date-range-picker";import { PayoutsCard } from "../programs/[programSlug]/(enrolled)/payouts-card";import { EarningsChart } from "./earnings-chart";import { TasksCard } from "./tasks-card";+import { TopLinksCard } from "./top-links-card";import { TopProgramsCard } from "./top-programs-card";export function PartnerOverviewPageClient() {@@ -27,6 +28,7 @@ export function PartnerOverviewPageClient() {</div><div className="grid grid-cols-1 gap-4 lg:grid-cols-3"><TopProgramsCard />+ <TopLinksCard /></div></PageWidthWrapper>);diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/overview/top-links-card.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/overview/top-links-card.tsxnew file mode 100644index 0000000000..0d9bca24a2--- /dev/null+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/overview/top-links-card.tsx@@ -0,0 +1,53 @@+"use client";++import { usePartnerProfileTopEarnings } from "@/lib/swr/use-partner-profile-top-earnings";+import { Hyperlink } from "@dub/ui/icons";+import { currencyFormatter, getPrettyUrl } from "@dub/utils";+import {+ OVERVIEW_CARD_ROW_CLASSNAME,+ OverviewCard,+ OverviewCardList,+ ProgramLogo,+} from "./overview-card";+import { useOverviewDateRange } from "./use-overview-date-range";++export function TopLinksCard() {+ const { start, end, interval } = useOverviewDateRange();++ const { data: links, error } = usePartnerProfileTopEarnings({+ groupBy: "linkId",+ limit: 6,+ interval,+ start,+ end,+ });++ return (+ <OverviewCard title="Top links by earnings" className="rounded-2xl">+ <OverviewCardList+ items={links}+ rowCount={6}+ error={error}+ getKey={(link) => link.id}+ emptyState={{+ icon: <Hyperlink className="size-4" />,+ title: "No earnings in this date range",+ }}+ renderItem={(link) => (+ <div className={OVERVIEW_CARD_ROW_CLASSNAME}>+ <ProgramLogo program={link.program} />+ <span+ className="text-content-emphasis min-w-0 grow truncate text-xs font-semibold"+ title={link.url}+ >+ {getPrettyUrl(link.shortLink)}+ </span>+ <span className="shrink-0 text-xs font-medium text-neutral-500">+ {currencyFormatter(link.earnings)}+ </span>+ </div>+ )}+ />+ </OverviewCard>+ );+}