Skip to content

Commit

Permalink
fallback component for empty analytics data
Browse files Browse the repository at this point in the history
  • Loading branch information
shadrach-tayo committed Oct 21, 2024
1 parent 9dcaf04 commit 7cf83cd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 50 deletions.
34 changes: 2 additions & 32 deletions src/components/molecules/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,8 @@ function Analytics() {
</div>
);

if (!analytics) return <IncomingFeature />

return (
<div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
<MetricCard
Expand Down Expand Up @@ -361,38 +363,6 @@ function Analytics() {
description="Last 30 days"
icon="data"
/>
{/* <Card>
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
<CardTitle className="text-sm font-medium">Subscriptions</CardTitle>
<UsersRound className="w-4 h-4 text-muted-foreground" />
</CardHeader>
<CardContent>
<div className="text-2xl font-bold">+2350</div>
<p className="text-xs text-muted-foreground">
+180.1% from last month
</p>
</CardContent>
</Card>
<Card>
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
<CardTitle className="text-sm font-medium">Active Now</CardTitle>
<Activity className="h-4 w-4 text-muted-foreground" />
</CardHeader>
<CardContent>
<div className="text-2xl font-bold">+573</div>
<p className="text-xs text-muted-foreground">+201 since last hour</p>
</CardContent>
</Card>
<Card>
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
<CardTitle className="text-sm font-medium">Active Now</CardTitle>
<Activity className="h-4 w-4 text-muted-foreground" />
</CardHeader>
<CardContent>
<div className="text-2xl font-bold">+573</div>
<p className="text-xs text-muted-foreground">+201 since last hour</p>
</CardContent>
</Card> */}
</div>
);
}
36 changes: 18 additions & 18 deletions src/lib/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,24 +256,24 @@ export const getAnalytics = queryOptions({
credentials: "include",
});
const json = (await response.json()) as ApiResponse<Analytics>;
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
});

0 comments on commit 7cf83cd

Please sign in to comment.