The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
show sales count and sale amount
Steven Tey32f69540da3f
diff --git a/apps/web/app/partners.dub.co/(dashboard)/programs/[programSlug]/page-client.tsx b/apps/web/app/partners.dub.co/(dashboard)/programs/[programSlug]/page-client.tsxindex d1ccec60b0..d1e1ded16b 100644--- a/apps/web/app/partners.dub.co/(dashboard)/programs/[programSlug]/page-client.tsx+++ b/apps/web/app/partners.dub.co/(dashboard)/programs/[programSlug]/page-client.tsx@@ -166,12 +166,14 @@ function EarningsChart() {const { start, end, interval, color } = useContext(ProgramOverviewContext);const { data: { earnings: total } = {} } = usePartnerAnalytics({+ event: "composite",interval,start,end,});const { data: timeseries, error } = usePartnerAnalytics({+ event: "sales",groupBy: "timeseries",interval,start,@@ -307,6 +309,7 @@ function StatCard({const { start, end, interval, color } = useContext(ProgramOverviewContext);const { data: total } = usePartnerAnalytics({+ event: "composite",interval,start,end,diff --git a/apps/web/ui/analytics/analytics-area-chart.tsx b/apps/web/ui/analytics/analytics-area-chart.tsxindex e37293d1d6..0cb240f7bd 100644--- a/apps/web/ui/analytics/analytics-area-chart.tsx+++ b/apps/web/ui/analytics/analytics-area-chart.tsx@@ -126,8 +126,6 @@ export default function AnalyticsAreaChart({series={series}tooltipClassName="p-0"tooltipContent={(d) => {- const value =- d.values[resource === "sales" ? "saleAmount" : resource];return (<><p className="border-b border-gray-200 px-4 py-3 text-sm text-gray-900">@@ -147,8 +145,19 @@ export default function AnalyticsAreaChart({<p className="capitalize text-gray-600">{resource}</p></div><p className="text-right font-medium text-gray-900">- {resource === "sales" && "$"}- {nFormatter(value, { full: true })}+ {nFormatter(d.values[resource], { full: true })}+ {resource === "sales" && (+ <span className="ml-1 text-gray-500">+ (+ {Intl.NumberFormat("en-US", {+ style: "currency",+ currency: "USD",+ // @ts-ignore – this is a valid option but TS is outdated+ trailingZeroDisplay: "stripIfInteger",+ }).format(d.values.saleAmount)}+ )+ </span>+ )}</p></Fragment></div>diff --git a/apps/web/ui/analytics/main.tsx b/apps/web/ui/analytics/main.tsxindex c3fd8f12c3..e011bc2781 100644--- a/apps/web/ui/analytics/main.tsx+++ b/apps/web/ui/analytics/main.tsx@@ -55,12 +55,6 @@ export default function Main() {<div className="scrollbar-hide flex shrink-0 grow divide-x overflow-y-hidden"><NumberFlowGroup>{tabs.map(({ id, label, colorClassName }, idx) => {- const total = {- clicks: totalEvents?.clicks,- leads: totalEvents?.leads,- sales: totalEvents ? totalEvents.saleAmount / 100 : undefined,- }[id];-return (<div key={id} className="relative z-0">{idx > 0 && (@@ -109,25 +103,32 @@ export default function Main() {/><span>{label}</span></div>- <div className="mt-1 flex">- {total || total === 0 ? (- <NumberFlow- value={total}- className="text-2xl font-medium sm:text-3xl"- format={- id === "sales"- ? {- style: "currency",- currency: "USD",- // @ts-ignore – this is a valid option but TS is outdated- trailingZeroDisplay: "stripIfInteger",- }- : {- notation:- total > 999999 ? "compact" : "standard",- }- }- />+ <div className="mt-1 flex items-center gap-2">+ {totalEvents?.[id] || totalEvents?.[id] === 0 ? (+ <>+ <NumberFlow+ value={totalEvents[id]}+ className="text-2xl font-medium sm:text-3xl"+ format={{+ notation:+ totalEvents[id] > 999999+ ? "compact"+ : "standard",+ }}+ />+ {id === "sales" && (+ <NumberFlow+ className="text-lg font-medium text-gray-500 sm:text-xl"+ value={totalEvents.saleAmount / 100}+ format={{+ style: "currency",+ currency: "USD",+ // @ts-ignore – this is a valid option but TS is outdated+ trailingZeroDisplay: "stripIfInteger",+ }}+ />+ )}+ </>) : requiresUpgrade ? (<div className="block rounded-full bg-gray-100 p-2.5"><Lock className="h-4 w-4 text-gray-500" />