From 6d9d8b353f256f419f56a477a68a3a89b3c2c451 Mon Sep 17 00:00:00 2001 From: Francis Cao Date: Wed, 17 Sep 2025 11:43:58 -0700 Subject: [PATCH] update property names for list table to label, count, percent --- .../(reports)/attribution/Attribution.tsx | 60 ++++++++----------- .../[websiteId]/(reports)/revenue/Revenue.tsx | 8 +-- .../[websiteId]/(reports)/utm/UTM.tsx | 7 ++- .../realtime/RealtimeCountries.tsx | 8 ++- .../[websiteId]/realtime/RealtimeUrls.tsx | 14 ++++- 5 files changed, 51 insertions(+), 46 deletions(-) diff --git a/src/app/(main)/websites/[websiteId]/(reports)/attribution/Attribution.tsx b/src/app/(main)/websites/[websiteId]/(reports)/attribution/Attribution.tsx index 192d2c4f..af947df8 100644 --- a/src/app/(main)/websites/[websiteId]/(reports)/attribution/Attribution.tsx +++ b/src/app/(main)/websites/[websiteId]/(reports)/attribution/Attribution.tsx @@ -61,18 +61,24 @@ export function Attribution({ ] : []; - function UTMTable({ data = [], title }: { data: any; title: string }) { + function AttributionTable({ data = [], title }: { data: any; title: string }) { + const attributionData = percentFilter( + data.map(({ name, value }) => ({ + x: name, + y: Number(value), + })), + ); + return ( ({ - x: name, - y: Number(value), - })), - )} + data={attributionData.map(({ x, y, z }: { x: string; y: number; z: number }) => ({ + label: x, + count: y, + percent: z, + }))} /> ); } @@ -91,48 +97,34 @@ export function Attribution({ - ({ - x: name, - y: Number(value), - })), - )} - /> + - ({ - x: name, - y: Number(value), - })), - )} - /> + - + - + - + - + - + diff --git a/src/app/(main)/websites/[websiteId]/(reports)/revenue/Revenue.tsx b/src/app/(main)/websites/[websiteId]/(reports)/revenue/Revenue.tsx index 5963c3c0..420c94fe 100644 --- a/src/app/(main)/websites/[websiteId]/(reports)/revenue/Revenue.tsx +++ b/src/app/(main)/websites/[websiteId]/(reports)/revenue/Revenue.tsx @@ -38,7 +38,7 @@ export function Revenue({ websiteId, startDate, endDate }: RevenueProps) { }); const renderCountryName = useCallback( - ({ x: code }) => ( + ({ label: code }) => ( {countryNames[code] || formatMessage(labels.unknown)} @@ -136,9 +136,9 @@ export function Revenue({ websiteId, startDate, endDate }: RevenueProps) { title={formatMessage(labels.country)} metric={formatMessage(labels.revenue)} data={data?.country.map(({ name, value }: { name: string; value: number }) => ({ - x: name, - y: value, - z: (value / data?.total.sum) * 100, + label: name, + count: value, + percent: (value / data?.total.sum) * 100, }))} currency={currency} renderLabel={renderCountryName} diff --git a/src/app/(main)/websites/[websiteId]/(reports)/utm/UTM.tsx b/src/app/(main)/websites/[websiteId]/(reports)/utm/UTM.tsx index 47c17b6a..1df95893 100644 --- a/src/app/(main)/websites/[websiteId]/(reports)/utm/UTM.tsx +++ b/src/app/(main)/websites/[websiteId]/(reports)/utm/UTM.tsx @@ -26,6 +26,7 @@ export function UTM({ websiteId, startDate, endDate }: UTMProps) { {UTM_PARAMS.map(param => { const items = data?.[param]; + const chartData = { labels: items.map(({ utm }) => utm), datasets: [ @@ -50,9 +51,9 @@ export function UTM({ websiteId, startDate, endDate }: UTMProps) { ({ - x: utm, - y: views, - z: (views / total) * 100, + label: utm, + count: views, + percent: (views / total) * 100, }))} /> diff --git a/src/app/(main)/websites/[websiteId]/realtime/RealtimeCountries.tsx b/src/app/(main)/websites/[websiteId]/realtime/RealtimeCountries.tsx index 85640fad..2c16bced 100644 --- a/src/app/(main)/websites/[websiteId]/realtime/RealtimeCountries.tsx +++ b/src/app/(main)/websites/[websiteId]/realtime/RealtimeCountries.tsx @@ -11,7 +11,7 @@ export function RealtimeCountries({ data }) { const { countryNames } = useCountryNames(locale); const renderCountryName = useCallback( - ({ x: code }) => ( + ({ label: code }) => ( {countryNames[code]} @@ -24,7 +24,11 @@ export function RealtimeCountries({ data }) { ({ + label: x, + count: y, + percent: z, + }))} renderLabel={renderCountryName} /> ); diff --git a/src/app/(main)/websites/[websiteId]/realtime/RealtimeUrls.tsx b/src/app/(main)/websites/[websiteId]/realtime/RealtimeUrls.tsx index a6e90763..5bb51c92 100644 --- a/src/app/(main)/websites/[websiteId]/realtime/RealtimeUrls.tsx +++ b/src/app/(main)/websites/[websiteId]/realtime/RealtimeUrls.tsx @@ -27,7 +27,7 @@ export function RealtimeUrls({ data }: { data: any }) { }, ]; - const renderLink = ({ x }) => { + const renderLink = ({ label: x }) => { const domain = x.startsWith('/') ? website?.domain : ''; return ( @@ -70,7 +70,11 @@ export function RealtimeUrls({ data }: { data: any }) { title={formatMessage(labels.referrers)} metric={formatMessage(labels.views)} renderLabel={renderLink} - data={domains} + data={domains.map(({ x, y, z }: { x: string; y: number; z: number }) => ({ + label: x, + count: y, + percent: z, + }))} /> )} {filter === FILTER_PAGES && ( @@ -78,7 +82,11 @@ export function RealtimeUrls({ data }: { data: any }) { title={formatMessage(labels.pages)} metric={formatMessage(labels.views)} renderLabel={renderLink} - data={pages} + data={pages.map(({ x, y, z }: { x: string; y: number; z: number }) => ({ + label: x, + count: y, + percent: z, + }))} /> )}