The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Stop the Overview chart from opening /programs on touch devices
Rafiaa2dd1f5d49a
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.tsxindex e062fd46fe..21ba9a4ee1 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@@ -16,7 +16,7 @@ import { currencyFormatter, nFormatter } from "@dub/utils";import NumberFlow from "@number-flow/react";import { LinearGradient } from "@visx/gradient";import { useRouter } from "next/navigation";-import { useId, useMemo } from "react";+import { useEffect, useId, useMemo, useState } from "react";import { ProgramLogo } from "./overview-card";import { useOverviewDateRange } from "./use-overview-date-range";import { useTopProgramEarnings } from "./use-top-program-earnings";@@ -28,6 +28,14 @@ export function EarningsChart() {const router = useRouter();const { start, end, interval } = useOverviewDateRange();+ // on touch devices, the chart opens /programs at the end of each drag, which+ // stops partners from reading the tooltip+ const [isTouchDevice, setIsTouchDevice] = useState(false);++ useEffect(() => {+ setIsTouchDevice(window.matchMedia("(pointer: coarse)").matches);+ }, []);+const { data: timeseries, error } = usePartnerProfileEarningsTimeseries({groupBy: "programId",interval,@@ -117,7 +125,9 @@ export function EarningsChart() {isActive: true,},]}- onXValueClick={() => router.push("/programs")}+ onXValueClick={+ isTouchDevice ? undefined : () => router.push("/programs")+ }tooltipClassName="w-[240px] overflow-hidden p-0 shadow-md"tooltipContent={(d) => {const programEarnings = Object.entries(