Skip to content

Commit 8c5b968

Browse files
committed
Insight Dashboard
1 parent a7d0ecb commit 8c5b968

File tree

9 files changed

+772
-133
lines changed

9 files changed

+772
-133
lines changed

apps/dashboard/src/@/components/ui/code/getCodeHtml.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ function isPrettierSupportedLang(lang: BundledLanguage) {
1010
lang === "ts" ||
1111
lang === "tsx" ||
1212
lang === "javascript" ||
13-
lang === "typescript" ||
14-
lang === "css" ||
15-
lang === "json"
13+
lang === "typescript"
1614
);
1715
}
1816

Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
import type { Meta, StoryObj } from "@storybook/react";
2+
import { useMutation } from "@tanstack/react-query";
3+
import { useState } from "react";
4+
import { mobileViewport } from "../../../../../../stories/utils";
5+
import { BluePrintPlaygroundUI } from "./BluePrintPlayground";
6+
import type { BluePrintMetadata } from "./utils";
7+
8+
const meta = {
9+
title: "Insight/BluePrintPlayground",
10+
component: Story,
11+
parameters: {
12+
nextjs: {
13+
appDirectory: true,
14+
},
15+
},
16+
} satisfies Meta<typeof Story>;
17+
18+
export default meta;
19+
type Story = StoryObj<typeof meta>;
20+
21+
export const Desktop: Story = {
22+
args: {
23+
metadata: getBlueprintMetadata().transactionsMetadata,
24+
},
25+
};
26+
27+
export const Mobile: Story = {
28+
args: {
29+
metadata: getBlueprintMetadata().transactionsMetadata,
30+
},
31+
parameters: {
32+
viewport: mobileViewport("iphone14"),
33+
},
34+
};
35+
36+
function Story() {
37+
return (
38+
<div className="flex flex-col gap-10">
39+
<Variant metadata={getBlueprintMetadata().transactionsMetadata} />
40+
<Variant metadata={getBlueprintMetadata().eventsMetadata} />
41+
<Variant metadata={getBlueprintMetadata().tokensMetadata} />
42+
</div>
43+
);
44+
}
45+
46+
function Variant(props: {
47+
metadata: BluePrintMetadata;
48+
}) {
49+
const [response, setResponse] = useState<string | undefined>(undefined);
50+
const mutation = useMutation({
51+
mutationFn: async () => {
52+
await new Promise((resolve) => setTimeout(resolve, 1000));
53+
54+
const dummyResponse = {
55+
data: {
56+
title: "This is a dummy response",
57+
content: crypto.getRandomValues(new Uint8Array(10)),
58+
},
59+
};
60+
61+
return JSON.stringify(dummyResponse, null, 2);
62+
},
63+
});
64+
return (
65+
<div className="flex min-h-[800px] flex-col">
66+
<BluePrintPlaygroundUI
67+
metadata={props.metadata}
68+
backLink="/"
69+
isPending={mutation.isPending}
70+
onRunClick={async () => {
71+
const res = await mutation.mutateAsync();
72+
setResponse(res);
73+
}}
74+
response={response}
75+
/>
76+
</div>
77+
);
78+
}
79+
80+
function getBlueprintMetadata() {
81+
const transactionsMetadata: BluePrintMetadata = {
82+
domain: "https://{chainId}.insight.thirdweb.com",
83+
path: "/{clientId}/transactions",
84+
parameters: [
85+
{
86+
description: "Chain ID",
87+
name: "chainId",
88+
in: "path",
89+
required: true,
90+
},
91+
{
92+
description: "Filter parameters",
93+
name: "filter",
94+
in: "query",
95+
},
96+
{
97+
description: "Field to group results by",
98+
name: "group_by",
99+
in: "query",
100+
},
101+
{
102+
description: "Field to sort results by",
103+
name: "sort_by",
104+
in: "query",
105+
},
106+
{
107+
description: "Sort order (asc or desc)",
108+
name: "sort_order",
109+
in: "query",
110+
},
111+
{
112+
description: "Page number for pagination",
113+
name: "page",
114+
in: "query",
115+
},
116+
{
117+
description: "Number of items per page",
118+
name: "limit",
119+
in: "query",
120+
},
121+
{
122+
description: "List of aggregate functions to apply",
123+
name: "aggregate",
124+
in: "query",
125+
},
126+
],
127+
title: "Transactions",
128+
description: "Retrieve all transactions across all contracts",
129+
};
130+
131+
const eventsMetadata: BluePrintMetadata = {
132+
domain: "https://{chainId}.insight.thirdweb.com",
133+
path: "/{clientId}/events",
134+
parameters: [
135+
{
136+
description: "Chain ID",
137+
name: "chainId",
138+
in: "path",
139+
required: true,
140+
},
141+
{
142+
description: "Filter parameters",
143+
name: "filter",
144+
in: "query",
145+
},
146+
{
147+
description: "Field to group results by",
148+
name: "group_by",
149+
in: "query",
150+
},
151+
{
152+
description: "Field to sort results by",
153+
name: "sort_by",
154+
in: "query",
155+
},
156+
{
157+
description: "Sort order (asc or desc)",
158+
name: "sort_order",
159+
in: "query",
160+
},
161+
{
162+
description: "Page number for pagination",
163+
name: "page",
164+
in: "query",
165+
},
166+
{
167+
description: "Number of items per page",
168+
name: "limit",
169+
in: "query",
170+
},
171+
{
172+
description: "List of aggregate functions to apply",
173+
name: "aggregate",
174+
in: "query",
175+
},
176+
],
177+
title: "Events",
178+
description: "Retrieve all logs across all contracts",
179+
};
180+
181+
const tokensMetadata: BluePrintMetadata = {
182+
domain: "https://{chainId}.insight.thirdweb.com",
183+
path: "/v1/{clientId}/tokens/erc20/:ownerAddress",
184+
parameters: [
185+
{
186+
name: "chainId",
187+
in: "path",
188+
required: true,
189+
description: "Chain ID",
190+
},
191+
{
192+
required: true,
193+
name: "ownerAddress",
194+
in: "path",
195+
},
196+
{
197+
required: false,
198+
name: "clientId",
199+
in: "path",
200+
},
201+
],
202+
title: "Tokens",
203+
description: "Retrieve tokens balances for a given owner address",
204+
};
205+
206+
return {
207+
transactionsMetadata,
208+
eventsMetadata,
209+
tokensMetadata,
210+
};
211+
}

0 commit comments

Comments
 (0)