From 78a85a1886782dfe7618c58e348b7f6ee3b48513 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Greg=20Berg=C3=A9?= Date: Sat, 28 Dec 2024 11:22:28 +0100 Subject: [PATCH] fix(analytics): fix analytics if empty --- apps/frontend/src/pages/Account/Analytics.tsx | 58 ++++++++++++++----- 1 file changed, 44 insertions(+), 14 deletions(-) diff --git a/apps/frontend/src/pages/Account/Analytics.tsx b/apps/frontend/src/pages/Account/Analytics.tsx index ca949ee06..ec08dde7a 100644 --- a/apps/frontend/src/pages/Account/Analytics.tsx +++ b/apps/frontend/src/pages/Account/Analytics.tsx @@ -167,7 +167,9 @@ function Charts(props: { accountSlug: string; period: Period }) { }, {}, ), - total: Math.round(screenshots.total / builds.total), + total: builds.total + ? Math.round(screenshots.total / builds.total) + : 0, ts: serie.ts, }); return acc; @@ -209,10 +211,7 @@ function Charts(props: { accountSlug: string; period: Period }) { {metrics?.builds ? ( metrics.builds.all.total === 0 ? ( - + ) : ( {metrics ? ( metrics.screenshots.all.total === 0 ? ( - + ) : ( Screenshots by Project - {metrics ? : null} + {metrics ? ( + metrics.screenshots.all.total > 0 ? ( + + ) : ( + + ) + ) : null}
@@ -294,14 +296,23 @@ function Charts(props: { accountSlug: string; period: Period }) { Screenshots by Build + Screenshots + {screenshotByBuildSeries ? ( screenshotByBuildSeries.all.total === 0 ? ( - + ) : ( + ); +} + +function EmptyStateBuilds() { + return ( + + ); +} + type Metric = { all: { total: number; @@ -342,6 +371,7 @@ function Count(props: { count: number | null }) { value={props.count ?? 0} className={isLoading ? "invisible" : undefined} /> + {isLoading && (
)}