From 96fcdefeedc30bd370936eb100397399c8c1609f Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Wed, 18 Jun 2025 20:12:42 -0700 Subject: [PATCH] Updated Goal loading. --- .../[websiteId]/reports/goals/Goal.tsx | 116 +++++++++--------- 1 file changed, 59 insertions(+), 57 deletions(-) diff --git a/src/app/(main)/websites/[websiteId]/reports/goals/Goal.tsx b/src/app/(main)/websites/[websiteId]/reports/goals/Goal.tsx index a3ef7515..e1480491 100644 --- a/src/app/(main)/websites/[websiteId]/reports/goals/Goal.tsx +++ b/src/app/(main)/websites/[websiteId]/reports/goals/Goal.tsx @@ -24,7 +24,7 @@ export type GoalData = { num: number; total: number }; export function Goal({ id, name, type, parameters, websiteId, startDate, endDate }: GoalProps) { const { formatMessage, labels } = useMessages(); - const { data, error, isLoading } = useResultQuery(type, { + const { data, error, isLoading, isFetching } = useResultQuery(type, { websiteId, dateRange: { startDate, @@ -35,64 +35,66 @@ export function Goal({ id, name, type, parameters, websiteId, startDate, endDate const isPage = parameters?.type === 'page'; return ( - - - - - - - {name} - + + {data && ( + + + + + + {name} + + + + + + {({ close }) => { + return ( + + + + ); + }} + + + + + + {formatMessage(isPage ? labels.viewedPage : labels.triggeredEvent)} + + {formatMessage(labels.conversionRate)} + + + + {parameters.type === 'page' ? : } + {parameters.value} - - - - {({ close }) => { - return ( - - - - ); - }} - - + + + + + {`${formatLongNumber( + data?.num, + )} / ${formatLongNumber(data?.total)}`} + + + + + + {data?.total ? Math.round((+data?.num / +data?.total) * 100) : '0'}% + + - - - {formatMessage(isPage ? labels.viewedPage : labels.triggeredEvent)} - - {formatMessage(labels.conversionRate)} - - - - {parameters.type === 'page' ? : } - {parameters.value} - - - - - - {`${formatLongNumber( - data?.num, - )} / ${formatLongNumber(data?.total)}`} - - - - - - {data?.total ? Math.round((+data?.num / +data?.total) * 100) : '0'}% - - - + )} ); }