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.

Point the Overview View all buttons to the Earnings page

Rafi4a96b7f33d7a
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/overview/earnings-chart.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/overview/earnings-chart.tsx
index f38b48bf6f..9c4927cf74 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/overview/earnings-chart.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/overview/earnings-chart.tsx
@@ -20,6 +20,8 @@ import NumberFlow from "@number-flow/react";
import { LinearGradient } from "@visx/gradient";
import { useRouter } from "next/navigation";
import { useId, useMemo } from "react";
+import { ViewAllButton } from "./overview-card";
+import { useEarningsPageHref } from "./use-earnings-page-href";
import { useTopProgramEarnings } from "./use-top-program-earnings";
const MAX_TOOLTIP_PROGRAMS = 5;
@@ -28,6 +30,7 @@ export function EarningsChart() {
const id = useId();
const router = useRouter();
const { start, end, interval } = usePartnerDateRange();
+ const earningsPageHref = useEarningsPageHref();
// on touch devices, the chart opens /programs at the end of each drag, which
// stops partners from reading the tooltip
@@ -76,9 +79,12 @@ export function EarningsChart() {
className="flex flex-col rounded-xl border border-neutral-200 bg-white lg:h-[460px]"
>
<div className="px-5 py-4">
- <h2 className="pt-0.5 text-base font-semibold leading-6 text-neutral-800">
- Earnings
- </h2>
+ <div className="flex items-start justify-between gap-2">
+ <h2 className="pt-0.5 text-base font-semibold leading-6 text-neutral-800">
+ Earnings
+ </h2>
+ <ViewAllButton href={earningsPageHref} />
+ </div>
{total !== undefined ? (
<NumberFlow
className="text-lg font-medium leading-7 text-neutral-600"
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/overview/recent-earnings-card.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/overview/recent-earnings-card.tsx
index de87386a98..c943ce5f9e 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/overview/recent-earnings-card.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/overview/recent-earnings-card.tsx
@@ -15,9 +15,11 @@ import {
OverviewCard,
OverviewCardList,
} from "./overview-card";
+import { useEarningsPageHref } from "./use-earnings-page-href";
export function RecentEarningsCard() {
const { start, end, interval } = usePartnerDateRange();
+ const earningsPageHref = useEarningsPageHref();
const { data: earnings, error } = usePartnerProfileEarnings({
pageSize: 6,
@@ -29,6 +31,7 @@ export function RecentEarningsCard() {
return (
<OverviewCard
title="Recent earnings"
+ viewAllHref={earningsPageHref}
className="rounded-2xl"
testId={testIds.partnerOverview.recentEarnings}
>
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.tsx
index 9cbbbfc445..49e265c96d 100644
--- 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.tsx
@@ -12,9 +12,11 @@ import {
OverviewCard,
OverviewCardList,
} from "./overview-card";
+import { useEarningsPageHref } from "./use-earnings-page-href";
export function TopLinksCard({ className }: { className?: string }) {
const { start, end, interval } = usePartnerDateRange();
+ const earningsPageHref = useEarningsPageHref({ groupBy: "linkId" });
const { data: links, error } = usePartnerProfileEarningsAnalytics({
groupBy: "linkId",
@@ -27,6 +29,7 @@ export function TopLinksCard({ className }: { className?: string }) {
return (
<OverviewCard
title="Top links by earnings"
+ viewAllHref={earningsPageHref}
className={cn("rounded-2xl", className)}
testId={testIds.partnerOverview.topLinks}
>
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/overview/use-earnings-page-href.ts b/apps/web/app/(ee)/partners.dub.co/(dashboard)/overview/use-earnings-page-href.ts
new file mode 100644
index 0000000000..c95081cf57
--- /dev/null
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/overview/use-earnings-page-href.ts
@@ -0,0 +1,17 @@
+import { useRouterStuff } from "@dub/ui";
+
+// the All programs Earnings page, with the date range of the Overview page
+export function useEarningsPageHref(
+ params: { groupBy?: "linkId" | "programId" } = {},
+) {
+ const { searchParamsObj } = useRouterStuff();
+ const { interval, start, end } = searchParamsObj;
+
+ const query = new URLSearchParams(
+ Object.entries({ ...params, interval, start, end }).filter(
+ (entry): entry is [string, string] => Boolean(entry[1]),
+ ),
+ ).toString();
+
+ return `/earnings${query ? `?${query}` : ""}`;
+}