From 7cf83cdf5762d7eaedf408919bdce41be2041764 Mon Sep 17 00:00:00 2001 From: shadrach Date: Mon, 21 Oct 2024 04:32:37 -0500 Subject: [PATCH] fallback component for empty analytics data --- src/components/molecules/Dashboard.tsx | 34 ++---------------------- src/lib/api/index.ts | 36 +++++++++++++------------- 2 files changed, 20 insertions(+), 50 deletions(-) diff --git a/src/components/molecules/Dashboard.tsx b/src/components/molecules/Dashboard.tsx index 0822fb6..3f90f4c 100644 --- a/src/components/molecules/Dashboard.tsx +++ b/src/components/molecules/Dashboard.tsx @@ -268,6 +268,8 @@ function Analytics() { ); + if (!analytics) return + return (
- {/* - - Subscriptions - - - -
+2350
-

- +180.1% from last month -

-
-
- - - Active Now - - - -
+573
-

+201 since last hour

-
-
- - - Active Now - - - -
+573
-

+201 since last hour

-
-
*/}
); } diff --git a/src/lib/api/index.ts b/src/lib/api/index.ts index 299f8b9..15d7a88 100644 --- a/src/lib/api/index.ts +++ b/src/lib/api/index.ts @@ -256,24 +256,24 @@ export const getAnalytics = queryOptions({ credentials: "include", }); const json = (await response.json()) as ApiResponse; - return { - "newUsersInLast30Days": 5, - "newUsersInLast7Days": 2, - "newUsersToday": 0, - "newNodesInLast30Days": 2292, - "newNodesInLast7Days": 454, - "newNodesToday": 0, - "activeUsersToday": 1, - "activeUsersInLast7Days": 11, - "activeUsersInLast30Days": 17, - "nodeViewsToday": 2, - "nodeViewsInLast7Days": 3485, - "nodeViewsInLast30Days": 14245, - "bytesToday": null, - "bytesInLast7Days": 22890864, - "bytesInLast30Days": 77358695 - } - // return json.data ?? null; + // return { + // "newUsersInLast30Days": 5, + // "newUsersInLast7Days": 2, + // "newUsersToday": 0, + // "newNodesInLast30Days": 2292, + // "newNodesInLast7Days": 454, + // "newNodesToday": 0, + // "activeUsersToday": 1, + // "activeUsersInLast7Days": 11, + // "activeUsersInLast30Days": 17, + // "nodeViewsToday": 2, + // "nodeViewsInLast7Days": 3485, + // "nodeViewsInLast30Days": 14245, + // "bytesToday": null, + // "bytesInLast7Days": 22890864, + // "bytesInLast30Days": 77358695 + // } + return json.data ?? null; }, staleTime: 60 * 1000 });