Skip to content

Commit bb3fe0b

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

File tree

5 files changed

+194
-0
lines changed

5 files changed

+194
-0
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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 ">
24+
{/* <div className="h-10" /> */}
25+
<BillingAlerts className="mb-10" />
26+
27+
{/* Blueprints */}
28+
{blueprints.length === 0 ? (
29+
<div className="flex h-[450px] items-center justify-center rounded-lg border border-border ">
30+
No blueprints found
31+
</div>
32+
) : (
33+
<div className="grid grid-cols-1 gap-5 md:grid-cols-2 lg:grid-cols-3">
34+
{blueprints.map((blueprint) => {
35+
return <BlueprintCard key={blueprint.id} blueprint={blueprint} />;
36+
})}
37+
</div>
38+
)}
39+
40+
<div className="h-10" />
41+
</div>
42+
);
43+
}
44+
45+
function BlueprintCard(props: {
46+
blueprint: Blueprint;
47+
}) {
48+
const { blueprint } = props;
49+
return (
50+
<div
51+
key={blueprint.id}
52+
className="relative flex items-center gap-4 rounded-lg border border-border bg-muted/50 p-4 transition-colors hover:bg-muted/70"
53+
>
54+
<ProjectAvatar className="size-10 rounded-full" src="" />
55+
56+
<div>
57+
<Link
58+
className="group static before:absolute before:top-0 before:right-0 before:bottom-0 before:left-0 before:z-0"
59+
href={`https://portal.thirdweb.com/insight/blueprints#${blueprint.slug}`}
60+
>
61+
<h2 className="font-medium text-base">{blueprint.name}</h2>
62+
</Link>
63+
64+
<p className="my-1 text-muted-foreground/70 text-xs">
65+
{blueprint.description}
66+
</p>
67+
</div>
68+
</div>
69+
);
70+
}
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: "2",
27+
name: "Transactions",
28+
slug: "transactions-blueprint",
29+
description: "Query transaction data",
30+
},
31+
{
32+
id: "1",
33+
name: "Events",
34+
slug: "events-blueprint",
35+
description: "Query event data",
36+
},
37+
{
38+
id: "2",
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: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
"use client";
2+
3+
import { Button } from "@/components/ui/button";
4+
import { ImportModal } from "components/contract-components/import-contract/modal";
5+
import { PlusIcon } from "lucide-react";
6+
import { useState } from "react";
7+
8+
export function BlueprintsPageHeader() {
9+
const [importModalOpen, setImportModalOpen] = useState(false);
10+
11+
return (
12+
<div className="border-b pb-4">
13+
<ImportModal
14+
isOpen={importModalOpen}
15+
onClose={() => {
16+
setImportModalOpen(false);
17+
}}
18+
/>
19+
<div className="flex flex-col gap-4 md:pb-4 lg:flex-row lg:justify-between">
20+
<div>
21+
<h1 className="mb-1.5 font-semibold text-3xl tracking-tight lg:text-4xl">
22+
Blueprints
23+
</h1>
24+
</div>
25+
<div className="flex gap-2 [&>*]:grow">
26+
<Button className="cursor-not-allowed gap-2 opacity-50" disabled>
27+
<div className="flex items-center">
28+
<PlusIcon className="size-4" />
29+
Create Blueprint (Coming Soon)
30+
</div>
31+
</Button>
32+
</div>
33+
</div>
34+
</div>
35+
);
36+
}
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)