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.

Update earnings-chart.tsx

Tim Wilson0d1f34f2c3af
diff --git a/apps/web/app/partners.dub.co/(dashboard)/programs/[programSlug]/earnings/earnings-chart.tsx b/apps/web/app/partners.dub.co/(dashboard)/programs/[programSlug]/earnings/earnings-chart.tsx
index c1390b6d47..dca58db48f 100644
--- a/apps/web/app/partners.dub.co/(dashboard)/programs/[programSlug]/earnings/earnings-chart.tsx
+++ b/apps/web/app/partners.dub.co/(dashboard)/programs/[programSlug]/earnings/earnings-chart.tsx
@@ -2,7 +2,7 @@ import { formatDateTooltip } from "@/lib/analytics/format-date-tooltip";
import { IntervalOptions } from "@/lib/analytics/types";
import { usePartnerEarnings } from "@/lib/swr/use-partner-earnings";
import useProgramEnrollment from "@/lib/swr/use-program-enrollment";
-import { useRouterStuff } from "@dub/ui";
+import { LoadingSpinner, useRouterStuff } from "@dub/ui";
import { Areas, TimeSeriesChart, XAxis, YAxis } from "@dub/ui/charts";
import { currencyFormatter } from "@dub/utils";
import { useMemo } from "react";
@@ -64,57 +64,66 @@ export function EarningsChart() {
return (
<div className="rounded-lg border border-neutral-200 p-6">
<div className="h-80">
- <TimeSeriesChart
- data={chartData}
- series={series}
- tooltipClassName="p-0"
- // tooltipContent={(d) => {
- // return (
- // <>
- // <p className="border-b border-neutral-200 px-4 py-3 text-sm text-neutral-900">
- // {formatDateTooltip(d.date, {
- // interval: demo ? "day" : interval,
- // start,
- // end,
- // dataAvailableFrom: createdAt,
- // })}
- // </p>
- // <div className="grid grid-cols-2 gap-x-6 gap-y-2 px-4 py-3 text-sm">
- // <Fragment key={resource}>
- // <div className="flex items-center gap-2">
- // {activeSeries && (
- // <div
- // className={cn(
- // activeSeries.colorClassName,
- // "h-2 w-2 rounded-sm bg-current opacity-50 shadow-[inset_0_0_0_1px_#0003]",
- // )}
- // />
- // )}
- // <p className="capitalize text-neutral-600">{resource}</p>
- // </div>
- // <p className="text-right font-medium text-neutral-900">
- // {resource === "sales" && saleUnit === "saleAmount"
- // ? currencyFormatter(d.values.saleAmount)
- // : nFormatter(d.values[resource], { full: true })}
- // </p>
- // </Fragment>
- // </div>
- // </>
- // );
- // }}
- >
- <Areas />
- <XAxis
- tickFormat={(d) =>
- formatDateTooltip(d, {
- interval,
- start,
- end,
- })
- }
- />
- <YAxis showGridLines tickFormat={(v) => `${currencyFormatter(v)}`} />
- </TimeSeriesChart>
+ {chartData ? (
+ <TimeSeriesChart
+ data={chartData}
+ series={series}
+ tooltipClassName="p-0"
+ // tooltipContent={(d) => {
+ // return (
+ // <>
+ // <p className="border-b border-neutral-200 px-4 py-3 text-sm text-neutral-900">
+ // {formatDateTooltip(d.date, {
+ // interval: demo ? "day" : interval,
+ // start,
+ // end,
+ // dataAvailableFrom: createdAt,
+ // })}
+ // </p>
+ // <div className="grid grid-cols-2 gap-x-6 gap-y-2 px-4 py-3 text-sm">
+ // <Fragment key={resource}>
+ // <div className="flex items-center gap-2">
+ // {activeSeries && (
+ // <div
+ // className={cn(
+ // activeSeries.colorClassName,
+ // "h-2 w-2 rounded-sm bg-current opacity-50 shadow-[inset_0_0_0_1px_#0003]",
+ // )}
+ // />
+ // )}
+ // <p className="capitalize text-neutral-600">{resource}</p>
+ // </div>
+ // <p className="text-right font-medium text-neutral-900">
+ // {resource === "sales" && saleUnit === "saleAmount"
+ // ? currencyFormatter(d.values.saleAmount)
+ // : nFormatter(d.values[resource], { full: true })}
+ // </p>
+ // </Fragment>
+ // </div>
+ // </>
+ // );
+ // }}
+ >
+ <Areas />
+ <XAxis
+ tickFormat={(d) =>
+ formatDateTooltip(d, {
+ interval,
+ start,
+ end,
+ })
+ }
+ />
+ <YAxis
+ showGridLines
+ tickFormat={(v) => `${currencyFormatter(v)}`}
+ />
+ </TimeSeriesChart>
+ ) : (
+ <div className="flex size-full items-center justify-center">
+ <LoadingSpinner />
+ </div>
+ )}
</div>
</div>
);