Skip to content

Commit be13fe7

Browse files
author
Amine Afia
committed
Add initial insight UI
1 parent 3488281 commit be13fe7

File tree

5 files changed

+181
-0
lines changed

5 files changed

+181
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
"use client";
2+
3+
import {} from "@/components/ui/dropdown-menu";
4+
import {} from "lucide-react";
5+
import Link from "next/link";
6+
7+
import { ProjectAvatar } from "@/components/blocks/Avatars/ProjectAvatar";
8+
import {} from "@/components/ui/select";
9+
import { BillingAlerts } from "components/settings/Account/Billing/alerts/Alert";
10+
11+
export type Blueprint = {
12+
id: string;
13+
name: string;
14+
slug: string;
15+
description: string;
16+
};
17+
18+
export function BlueprintsExplorer(props: {
19+
blueprints: Blueprint[];
20+
}) {
21+
const { blueprints } = props;
22+
return (
23+
<div className="container px-0">
24+
<BillingAlerts className="mb-10" />
25+
26+
{/* Blueprints */}
27+
{blueprints.length === 0 ? (
28+
<div className="flex h-[450px] items-center justify-center rounded-lg border border-border ">
29+
No blueprints found
30+
</div>
31+
) : (
32+
<div className="grid grid-cols-1 gap-5 md:grid-cols-2 lg:grid-cols-3">
33+
{blueprints.map((blueprint) => {
34+
return <BlueprintCard key={blueprint.id} blueprint={blueprint} />;
35+
})}
36+
</div>
37+
)}
38+
39+
<div className="h-10" />
40+
</div>
41+
);
42+
}
43+
44+
function BlueprintCard(props: {
45+
blueprint: Blueprint;
46+
}) {
47+
const { blueprint } = props;
48+
return (
49+
<div
50+
key={blueprint.id}
51+
className="relative flex items-center gap-4 rounded-lg border border-border bg-muted/50 p-4 transition-colors hover:bg-muted/70"
52+
>
53+
<ProjectAvatar className="size-10 rounded-full" src="" />
54+
55+
<div>
56+
<Link
57+
className="group static before:absolute before:top-0 before:right-0 before:bottom-0 before:left-0 before:z-0"
58+
href={`https://portal.thirdweb.com/insight/blueprints#${blueprint.slug}`}
59+
>
60+
<h2 className="font-medium text-base">{blueprint.name}</h2>
61+
</Link>
62+
63+
<p className="my-1 text-muted-foreground/70 text-xs">
64+
{blueprint.description}
65+
</p>
66+
</div>
67+
</div>
68+
);
69+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import { Spinner } from "@/components/ui/Spinner/Spinner";
2+
import { ClientOnly } from "components/ClientOnly/ClientOnly";
3+
import { BillingAlerts } from "components/settings/Account/Billing/alerts/Alert";
4+
import { Suspense } from "react";
5+
import { type Blueprint, BlueprintsExplorer } from "./BlueprintsExplorer";
6+
import { BlueprintsPageHeader } from "./BlueprintsPageHeader";
7+
8+
export function BlueprintsPage(props: {
9+
className?: string;
10+
}) {
11+
return (
12+
<div className={props.className}>
13+
<BillingAlerts className="mb-10" />
14+
<BlueprintsPageHeader />
15+
<div className="h-6" />
16+
<Suspense fallback={<Loading />}>
17+
<BlueprintsPageAsync />
18+
</Suspense>
19+
</div>
20+
);
21+
}
22+
23+
function getProjectBlueprints() {
24+
return [
25+
{
26+
id: "1",
27+
name: "Transactions",
28+
slug: "transactions-blueprint",
29+
description: "Query transaction data",
30+
},
31+
{
32+
id: "2",
33+
name: "Events",
34+
slug: "events-blueprint",
35+
description: "Query event data",
36+
},
37+
{
38+
id: "3",
39+
name: "Tokens",
40+
slug: "tokens-blueprint",
41+
description: "Query ERC-20, ERC-721, and ERC-1155 tokens",
42+
},
43+
] as Blueprint[];
44+
}
45+
46+
async function BlueprintsPageAsync() {
47+
const blueprints = getProjectBlueprints();
48+
49+
return (
50+
<ClientOnly ssr={<Loading />}>
51+
<BlueprintsExplorer blueprints={blueprints} />
52+
</ClientOnly>
53+
);
54+
}
55+
56+
function Loading() {
57+
return (
58+
<div className="flex min-h-[300px] grow items-center justify-center rounded-lg border border-border">
59+
<Spinner className="size-10" />
60+
</div>
61+
);
62+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
"use client";
2+
3+
import { Button } from "@/components/ui/button";
4+
import { PlusIcon } from "lucide-react";
5+
6+
export function BlueprintsPageHeader() {
7+
return (
8+
<div className="border-b pb-4">
9+
<div className="flex flex-col gap-4 md:pb-4 lg:flex-row lg:justify-between">
10+
<div>
11+
<h1 className="mb-1.5 font-semibold text-3xl tracking-tight lg:text-4xl">
12+
Blueprints
13+
</h1>
14+
</div>
15+
<Button className="cursor-not-allowed gap-2 opacity-50" disabled>
16+
<div className="flex items-center">
17+
<PlusIcon className="size-4" />
18+
Create Blueprint (Coming Soon)
19+
</div>
20+
</Button>
21+
</div>
22+
</div>
23+
);
24+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { redirect } from "next/navigation";
2+
import { getAuthTokenWalletAddress } from "../../../../api/lib/getAuthToken";
3+
import { BlueprintsPage } from "./components/BlueprintsPage";
4+
5+
export default async function Page(props: {
6+
params: Promise<{ team_slug: string; project_slug: string }>;
7+
}) {
8+
const accountAddress = await getAuthTokenWalletAddress();
9+
10+
if (!accountAddress) {
11+
const { team_slug, project_slug } = await props.params;
12+
return redirect(
13+
`/login?next=${encodeURIComponent(`/team/${team_slug}/${project_slug}/insight`)}`,
14+
);
15+
}
16+
17+
return (
18+
<div className="container flex grow flex-col">
19+
<BlueprintsPage className="flex grow flex-col pt-10 pb-10" />
20+
</div>
21+
);
22+
}

apps/dashboard/src/app/team/[team_slug]/[project_slug]/layout.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ export default async function TeamLayout(props: {
6262
path: `/team/${params.team_slug}/${params.project_slug}/nebula`,
6363
name: "Nebula",
6464
},
65+
{
66+
path: `/team/${params.team_slug}/${params.project_slug}/insight`,
67+
name: "Insight",
68+
},
6569
{
6670
path: `/team/${params.team_slug}/${params.project_slug}/settings`,
6771
name: "Settings",

0 commit comments

Comments
 (0)