Skip to content

Commit 514c1a8

Browse files
committed
[TOOL-3496] Dashboard: Ecosystem pages UI improvements (#6311)
![image.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/yNOf1svJ8o3zjO7zQouZ/f1d0c79f-f711-42e3-9c5e-2b57bfacc05b.png) ![image.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/yNOf1svJ8o3zjO7zQouZ/39702f47-477c-4177-bf3b-ac41c05b5093.png) ![image.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/yNOf1svJ8o3zjO7zQouZ/ce5cc358-a16a-4a06-90a1-a11ff47f67e4.png) <!-- start pr-codex --> --- ## PR-Codex overview This PR focuses on refactoring and enhancing the loading components and ecosystem management pages in the `dashboard` application. It introduces improvements in code structure, UI components, and error handling. ### Detailed summary - Removed unused files from `utils`, `data`, and `ecosystem` directories. - Updated `GenericLoadingPage` to accept a `className` prop for styling. - Refactored loading components to use the new `GenericLoadingPage` structure. - Enhanced `EcosystemCreatePage` layout and styling. - Improved `EcosystemAnalyticsPage` to fetch and display wallet usage statistics. - Replaced direct API calls with token-based authentication in ecosystem pages. - Updated `EcosystemHeader` to utilize new UI components and improve layout. - Refactored ecosystem creation form for better user experience and error handling. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent a2d75df commit 514c1a8

File tree

15 files changed

+383
-457
lines changed

15 files changed

+383
-457
lines changed

apps/dashboard/src/@/components/blocks/skeletons/GenericLoadingPage.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
"use client";
22

33
import { Spinner } from "@/components/ui/Spinner/Spinner";
4+
import { cn } from "../../../lib/utils";
45

5-
export function GenericLoadingPage() {
6+
export function GenericLoadingPage({
7+
className,
8+
}: {
9+
className?: string;
10+
}) {
611
return (
7-
<div className="flex min-h-[500px] grow items-center justify-center rounded-lg border border-border">
12+
<div
13+
className={cn(
14+
"flex min-h-[500px] grow items-center justify-center rounded-lg border border-border",
15+
className,
16+
)}
17+
>
818
<Spinner className="size-10" />
919
</div>
1020
);

apps/dashboard/src/app/team/[team_slug]/(team)/~/ecosystem/[slug]/(active)/analytics/components/EcosystemAnalyticsPage.tsx

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,57 @@ import {
55
import { RangeSelector } from "components/analytics/range-selector";
66
import { getEcosystemWalletUsage } from "data/analytics/wallets/ecosystem";
77
import { EcosystemWalletUsersChartCard } from "./EcosystemWalletUsersChartCard";
8+
import { EcosystemWalletsSummary } from "./Summary";
89

910
export async function EcosystemAnalyticsPage({
1011
ecosystemSlug,
1112
interval,
1213
range,
13-
}: { ecosystemSlug: string; interval: "day" | "week"; range?: Range }) {
14+
}: {
15+
ecosystemSlug: string;
16+
interval: "day" | "week";
17+
range?: Range;
18+
}) {
1419
if (!range) {
1520
range = getLastNDaysRange("last-120");
1621
}
1722

18-
const stats = await getEcosystemWalletUsage({
23+
const allTimeStatsPromise = getEcosystemWalletUsage({
24+
ecosystemSlug,
25+
from: new Date(2022, 0, 1),
26+
to: new Date(),
27+
period: "all",
28+
});
29+
30+
const monthlyStatsPromise = getEcosystemWalletUsage({
31+
ecosystemSlug,
32+
from: new Date(new Date().getFullYear(), new Date().getMonth(), 1),
33+
to: new Date(),
34+
period: "month",
35+
});
36+
37+
const statsPromise = getEcosystemWalletUsage({
1938
ecosystemSlug,
2039
from: range.from,
2140
to: range.to,
2241
period: interval,
2342
}).catch(() => null);
2443

44+
const [allTimeStats, monthlyStats, stats] = await Promise.all([
45+
allTimeStatsPromise,
46+
monthlyStatsPromise,
47+
statsPromise,
48+
]);
49+
2550
return (
2651
<div>
52+
<EcosystemWalletsSummary
53+
allTimeStats={allTimeStats ?? []}
54+
monthlyStats={monthlyStats ?? []}
55+
/>
56+
57+
<div className="h-6" />
58+
2759
<RangeSelector range={range} interval={interval} />
2860

2961
<div className="h-6" />
Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Range } from "components/analytics/date-range-selector";
2-
import { fetchApiServer } from "data/analytics/fetch-api-server";
3-
import { FetchError } from "utils/error";
4-
import type { Ecosystem } from "../../../types";
2+
import { redirect } from "next/navigation";
3+
import { getAuthToken } from "../../../../../../../../api/lib/getAuthToken";
4+
import { fetchEcosystem } from "../../../utils/fetchEcosystem";
55
import { EcosystemAnalyticsPage } from "./components/EcosystemAnalyticsPage";
66

77
export default async function Page(props: {
@@ -19,7 +19,19 @@ export default async function Page(props: {
1919
props.searchParams,
2020
]);
2121

22-
const ecosystem = await getEcosystem(params.slug);
22+
const ecosystemLayoutPath = `/team/${params.team_slug}/~/ecosystem`;
23+
const authToken = await getAuthToken();
24+
25+
if (!authToken) {
26+
redirect(ecosystemLayoutPath);
27+
}
28+
29+
const ecosystem = await fetchEcosystem(params.slug, authToken);
30+
31+
if (!ecosystem) {
32+
redirect(ecosystemLayoutPath);
33+
}
34+
2335
return (
2436
<EcosystemAnalyticsPage
2537
ecosystemSlug={ecosystem.slug}
@@ -28,19 +40,3 @@ export default async function Page(props: {
2840
/>
2941
);
3042
}
31-
32-
async function getEcosystem(ecosystemSlug: string) {
33-
const res = await fetchApiServer(`/v1/ecosystem-wallet/${ecosystemSlug}`);
34-
35-
if (!res.ok) {
36-
const data = await res.json();
37-
console.error(data);
38-
throw new FetchError(
39-
res,
40-
data?.message ?? data?.error?.message ?? "Failed to fetch ecosystems",
41-
);
42-
}
43-
44-
const data = (await res.json()) as { result: Ecosystem };
45-
return data.result;
46-
}
Lines changed: 25 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import { COOKIE_ACTIVE_ACCOUNT, COOKIE_PREFIX_TOKEN } from "@/constants/cookie";
2-
import { getEcosystemWalletUsage } from "data/analytics/wallets/ecosystem";
3-
import { cookies } from "next/headers";
1+
import { SidebarLayout } from "@/components/blocks/SidebarLayout";
2+
import {} from "@/constants/cookie";
43
import { redirect } from "next/navigation";
5-
import { getAddress } from "thirdweb";
4+
import { getAuthToken } from "../../../../../../../../api/lib/getAuthToken";
65
import { fetchEcosystem } from "../../../utils/fetchEcosystem";
76
import { EcosystemHeader } from "./ecosystem-header.client";
87

@@ -15,12 +14,7 @@ export async function EcosystemLayoutSlug({
1514
params: { slug: string };
1615
ecosystemLayoutPath: string;
1716
}) {
18-
const cookiesManager = await cookies();
19-
const activeAccount = cookiesManager.get(COOKIE_ACTIVE_ACCOUNT)?.value;
20-
const authToken = activeAccount
21-
? (await cookies()).get(COOKIE_PREFIX_TOKEN + getAddress(activeAccount))
22-
?.value
23-
: null;
17+
const authToken = await getAuthToken();
2418

2519
if (!authToken) {
2620
redirect(ecosystemLayoutPath);
@@ -32,34 +26,32 @@ export async function EcosystemLayoutSlug({
3226
redirect(ecosystemLayoutPath);
3327
}
3428

35-
const allTimeStatsPromise = getEcosystemWalletUsage({
36-
ecosystemSlug: ecosystem.slug,
37-
from: new Date(2022, 0, 1),
38-
to: new Date(),
39-
period: "all",
40-
});
41-
42-
const monthlyStatsPromise = getEcosystemWalletUsage({
43-
ecosystemSlug: ecosystem.slug,
44-
from: new Date(new Date().getFullYear(), new Date().getMonth(), 1),
45-
to: new Date(),
46-
period: "month",
47-
});
48-
49-
const [allTimeStats, monthlyStats] = await Promise.all([
50-
allTimeStatsPromise,
51-
monthlyStatsPromise,
52-
]);
53-
5429
return (
55-
<div className="flex w-full flex-col gap-10">
30+
<div className="flex grow flex-col">
5631
<EcosystemHeader
5732
ecosystem={ecosystem}
5833
ecosystemLayoutPath={ecosystemLayoutPath}
59-
allTimeStats={allTimeStats || []}
60-
monthlyStats={monthlyStats || []}
6134
/>
62-
{children}
35+
36+
<SidebarLayout
37+
sidebarLinks={[
38+
{
39+
label: "Overview",
40+
href: `${ecosystemLayoutPath}/${ecosystem.slug}`,
41+
exactMatch: true,
42+
},
43+
{
44+
label: "Analytics",
45+
href: `${ecosystemLayoutPath}/${ecosystem.slug}/analytics`,
46+
},
47+
{
48+
label: "Design (coming soon)",
49+
href: `${ecosystemLayoutPath}/${ecosystem.slug}#`,
50+
},
51+
]}
52+
>
53+
{children}
54+
</SidebarLayout>
6355
</div>
6456
);
6557
}

0 commit comments

Comments
 (0)