From 123435b0e41296f38f6f0498b93ae9730b1856fd Mon Sep 17 00:00:00 2001 From: MananTank Date: Tue, 17 Dec 2024 16:22:14 +0000 Subject: [PATCH] [DASH-643] Improve Project overview page load perf (#5774) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Problem solved Short description of the bug fixed or feature added --- ## PR-Codex overview This PR focuses on enhancing the `ProjectOverviewPage` component by integrating a loading state with `Suspense`, restructuring the layout, and improving the conditional rendering of analytics components based on project activity. ### Detailed summary - Added `Suspense` for loading state using `GenericLoadingPage`. - Refactored layout to use a flexbox structure. - Enhanced conditional rendering for `ProjectAnalytics` and `EmptyState`. - Improved user statistics and charts display logic. - Streamlined the rendering of various analytics cards. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` --- .../team/[team_slug]/[project_slug]/page.tsx | 165 ++++++++++-------- 1 file changed, 94 insertions(+), 71 deletions(-) diff --git a/apps/dashboard/src/app/team/[team_slug]/[project_slug]/page.tsx b/apps/dashboard/src/app/team/[team_slug]/[project_slug]/page.tsx index 857f7b5ca2f..fee25daf6cf 100644 --- a/apps/dashboard/src/app/team/[team_slug]/[project_slug]/page.tsx +++ b/apps/dashboard/src/app/team/[team_slug]/[project_slug]/page.tsx @@ -1,7 +1,7 @@ +import { type Project, getProject } from "@/api/projects"; +import { GenericLoadingPage } from "@/components/blocks/skeletons/GenericLoadingPage"; import { notFound } from "next/navigation"; -import { getProject } from "@/api/projects"; - import { type DurationId, type Range, @@ -22,6 +22,7 @@ import { isProjectActive, } from "@/api/analytics"; import { EmptyStateCard } from "app/team/components/Analytics/EmptyStateCard"; +import { Suspense } from "react"; import { type ChainMetadata, defineChain, @@ -69,6 +70,43 @@ export default async function ProjectOverviewPage(props: PageProps) { const isActive = await isProjectActive({ clientId: project.publishableKey }); + return ( +
+
+ +
+ {!isActive ? ( +
+ +
+ ) : ( +
+ }> + + +
+ )} +
+ ); +} + +async function ProjectAnalytics(props: { + project: Project; + range: Range; + interval: "day" | "week"; + searchParams: PageSearchParams; +}) { + const { project, range, interval, searchParams } = props; + // Fetch all analytics data in parallel const [ walletConnections, @@ -114,79 +152,64 @@ export default async function ProjectOverviewPage(props: PageProps) { ]); return ( -
-
- -
- {!isActive ? ( -
- +
+ {walletUserStatsTimeSeries.some((w) => w.totalUsers !== 0) ? ( +
+
) : ( -
- {walletUserStatsTimeSeries.some((w) => w.totalUsers !== 0) ? ( -
- -
- ) : ( - - )} - + )} + +
+ {walletConnections.length > 0 ? ( + + ) : ( + + )} + {inAppWalletUsage.length > 0 ? ( + + ) : ( + + )} +
+ {userOpUsage.length > 0 ? ( +
+ -
- {walletConnections.length > 0 ? ( - - ) : ( - - )} - {inAppWalletUsage.length > 0 ? ( - - ) : ( - - )} -
- {userOpUsage.length > 0 ? ( -
- -
- ) : ( - - )}
+ ) : ( + )}
);