Skip to content

Commit 3541cc2

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

File tree

5 files changed

+197
-0
lines changed

5 files changed

+197
-0
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
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+
}
71+
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
2+
import { Spinner } from "@/components/ui/Spinner/Spinner";
3+
import { ClientOnly } from "components/ClientOnly/ClientOnly";
4+
import { BillingAlerts } from "components/settings/Account/Billing/alerts/Alert";
5+
import { Suspense } from "react";
6+
import { type Blueprint, BlueprintsExplorer } from "./BlueprintsExplorer";
7+
import { BlueprintsPageHeader } from "./BlueprintsPageHeader";
8+
9+
export function BlueprintsPage(props: {
10+
className?: string;
11+
}) {
12+
return (
13+
<div className={props.className}>
14+
<BillingAlerts className="mb-10" />
15+
<BlueprintsPageHeader />
16+
<div className="h-6" />
17+
<Suspense fallback={<Loading />}>
18+
<BlueprintsPageAsync />
19+
</Suspense>
20+
</div>
21+
);
22+
}
23+
24+
function getProjectBlueprints() {
25+
return [
26+
{
27+
id: "2",
28+
name: "Transactions",
29+
slug: "transactions-blueprint",
30+
description: "Query transaction data",
31+
},
32+
{
33+
id: "1",
34+
name: "Events",
35+
slug: "events-blueprint",
36+
description: "Query event data",
37+
},
38+
{
39+
id: "2",
40+
name: "Tokens",
41+
slug: "tokens-blueprint",
42+
description: "Query ERC-20, ERC-721, and ERC-1155 tokens",
43+
},
44+
] as Blueprint[];
45+
}
46+
47+
async function BlueprintsPageAsync() {
48+
const blueprints = getProjectBlueprints();
49+
50+
return (
51+
<ClientOnly ssr={<Loading />}>
52+
<BlueprintsExplorer blueprints={blueprints} />
53+
</ClientOnly>
54+
);
55+
}
56+
57+
function Loading() {
58+
return (
59+
<div className="flex min-h-[300px] grow items-center justify-center rounded-lg border border-border">
60+
<Spinner className="size-10" />
61+
</div>
62+
);
63+
}
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: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
import { redirect } from "next/navigation";
3+
import { getAuthTokenWalletAddress } from "../../../../api/lib/getAuthToken";
4+
import { BlueprintsPage } from "./components/BlueprintsPage";
5+
6+
export default async function Page(props: {
7+
params: Promise<{ team_slug: string; project_slug: string }>;
8+
}) {
9+
const accountAddress = await getAuthTokenWalletAddress();
10+
11+
if (!accountAddress) {
12+
const { team_slug, project_slug } = await props.params;
13+
return redirect(
14+
`/login?next=${encodeURIComponent(`/team/${team_slug}/${project_slug}/insight`)}`,
15+
);
16+
}
17+
18+
return (
19+
<div className="container flex grow flex-col">
20+
<BlueprintsPage className="flex grow flex-col pt-10 pb-10" />
21+
</div>
22+
);
23+
}

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)