Skip to content

Commit a328250

Browse files
committed
feat: Add api to project view section (#7992)
<!-- ## title your PR with this format: "[SDK/Dashboard/Portal] Feature/Fix: Concise title for the changes" If you did not copy the branch name from Linear, paste the issue tag here (format is TEAM-0000): ## Notes for the reviewer Anything important to call out? Be sure to also clarify these in your comments. ## How to test Unit tests, playground, etc. --> <!-- start pr-codex --> --- ## PR-Codex overview This PR enhances the `IntegrateAPIKeyCodeTabs` component by adding new tab keys for `api` and `curl`, along with their respective code examples for API integration. It also updates the default selected tab to `api`. ### Detailed summary - Added new `TabKey` values: `api` and `curl`. - Updated `tabNames` to include labels for `api` and `curl`. - Changed default tab state from `ts` to `api`. - Introduced `apiCodeExample` function for API integration code. - Introduced `curlCodeExample` function for cURL integration code. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added API and cURL tabs to the API integration UI with ready-to-copy code examples (JavaScript fetch and Bash curl) for server-side wallet API calls. * Set the API tab as the default selection and updated tab order to include API and cURL. * Examples auto-fill the masked secret key when available and include a sample identifier, improving first-time setup guidance. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 928704a commit a328250

File tree

2 files changed

+48
-2
lines changed

2 files changed

+48
-2
lines changed

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/components/ProjectFTUX/IntegrateAPIKeyCodeTabs.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,31 @@
33
import { useState } from "react";
44
import { TabButtons } from "@/components/ui/tabs";
55

6-
type TabKey = "ts" | "react" | "react-native" | "dotnet" | "unity" | "unreal";
6+
type TabKey =
7+
| "ts"
8+
| "react"
9+
| "react-native"
10+
| "dotnet"
11+
| "unity"
12+
| "unreal"
13+
| "api"
14+
| "curl";
715

816
const tabNames: Record<TabKey, string> = {
17+
api: "API",
918
ts: "TypeScript",
1019
react: "React",
1120
"react-native": "React Native",
1221
dotnet: ".NET",
1322
unity: "Unity",
1423
unreal: "Unreal Engine",
24+
curl: "cURL",
1525
};
1626

1727
export function IntegrateAPIKeyCodeTabs(props: {
1828
tabs: Record<TabKey, React.ReactNode>;
1929
}) {
20-
const [tab, setTab] = useState<TabKey>("ts");
30+
const [tab, setTab] = useState<TabKey>("api");
2131

2232
return (
2333
<div>

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/components/ProjectFTUX/ProjectFTUX.tsx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,20 @@ function IntegrationCodeExamples(props: {
187187
</AlertDescription>
188188
</Alert>
189189
),
190+
api: (
191+
<CodeServer
192+
className="bg-background"
193+
code={apiCodeExample(props.project)}
194+
lang="javascript"
195+
/>
196+
),
197+
curl: (
198+
<CodeServer
199+
className="bg-background"
200+
code={curlCodeExample(props.project)}
201+
lang="bash"
202+
/>
203+
),
190204
}}
191205
/>
192206
);
@@ -221,6 +235,28 @@ var client = ThirdwebClient.Create(clientId: "${project.publishableKey}", bundle
221235
// For backend applications (Note: below shown secret key is not the full secret key)
222236
var client = ThirdwebClient.Create(secretKey: "${project.secretKeys[0]?.masked}");`;
223237

238+
const apiCodeExample = (project: Project): string => `\
239+
// Server-side only: replace with your full secret key. Never expose in browser code.
240+
fetch('https://api.thirdweb.com/v1/wallets/server', {
241+
method: 'POST',
242+
headers: {
243+
'Content-Type': 'application/json',
244+
'x-secret-key': '${project.secretKeys[0]?.masked ?? "<YOUR_SECRET_KEY>"}'
245+
},
246+
body: JSON.stringify({
247+
identifier: 'treasury-wallet-123'
248+
})
249+
});`;
250+
251+
const curlCodeExample = (project: Project): string => `\
252+
// Server-side only: replace with your full secret key. Never expose in browser code.
253+
curl https://api.thirdweb.com/v1/wallets/server \\
254+
--request POST \\
255+
--header 'Content-Type: application/json' \\
256+
--header 'x-secret-key: ${project.secretKeys[0]?.masked ?? "<YOUR_SECRET_KEY>"}' \\
257+
--data '{
258+
"identifier": "treasury-wallet-123"
259+
}'`;
224260
// products section ------------------------------------------------------------
225261

226262
function ProductsSection(props: { teamSlug: string; projectSlug: string }) {

0 commit comments

Comments
 (0)