11"use client" ;
22import { Button } from "@/components/ui/button" ;
3- import { CodeServer } from "@/components/ui/code/code.server" ;
43import { TabButtons } from "@/components/ui/tabs" ;
54import { ExternalLinkIcon } from "lucide-react" ;
65import Link from "next/link" ;
76import { useState } from "react" ;
87
9- export function PayEmbedFTUX ( props : { clientId : string } ) {
10- const [ tab , setTab ] = useState ( "embed" ) ;
8+ type Tab = "embed" | "sdk" | "api" ;
9+
10+ export function PayEmbedFTUX ( props : {
11+ clientId : string ;
12+ codeExamples : {
13+ embed : React . ReactNode ;
14+ sdk : React . ReactNode ;
15+ api : React . ReactNode ;
16+ } ;
17+ } ) {
18+ const [ tab , setTab ] = useState < Tab > ( "embed" ) ;
1119 return (
1220 < div className = "rounded-lg border bg-card" >
13- < div className = "border-b px-4 py-4 lg:px-6 " >
14- < h2 className = "font-semibold text-xl tracking-tight" >
21+ < div className = "border-b border-dashed p-4 " >
22+ < h2 className = "font-semibold text-lg tracking-tight" >
1523 Start Monetizing Your App
1624 </ h2 >
1725 </ div >
1826
19- < div className = "px -4 py-6 lg:p-6 " >
27+ < div className = "p -4 pt-2 " >
2028 < TabButtons
2129 tabClassName = "!text-sm"
2230 tabs = { [
@@ -38,32 +46,11 @@ export function PayEmbedFTUX(props: { clientId: string }) {
3846 ] }
3947 />
4048 < div className = "h-2" />
41- { tab === "embed" && (
42- < CodeServer
43- code = { embedCode ( props . clientId ) }
44- lang = "tsx"
45- className = "bg-background"
46- />
47- ) }
48- { tab === "sdk" && (
49- < CodeServer
50- code = { sdkCode ( props . clientId ) }
51- lang = "ts"
52- className = "bg-background"
53- ignoreFormattingErrors
54- />
55- ) }
56- { tab === "api" && (
57- < CodeServer
58- code = { apiCode ( props . clientId ) }
59- lang = "bash"
60- className = "bg-background"
61- ignoreFormattingErrors
62- />
63- ) }
49+
50+ { props . codeExamples [ tab ] }
6451 </ div >
6552
66- < div className = "flex flex-col gap-3 border-t p-4 lg:flex-row lg:items-center lg:justify-between lg:p-6 " >
53+ < div className = "flex flex-col gap-3 border-t p-4 lg:flex-row lg:items-center lg:justify-between" >
6754 < div className = "flex gap-3" >
6855 < Button asChild variant = "outline" size = "sm" >
6956 < Link
@@ -81,39 +68,3 @@ export function PayEmbedFTUX(props: { clientId: string }) {
8168 </ div >
8269 ) ;
8370}
84-
85- const embedCode = ( clientId : string ) => `\
86- import { createThirdwebClient } from "thirdweb";
87- import { PayEmbed } from "thirdweb/react";
88-
89- const client = createThirdwebClient({
90- clientId: "${ clientId } ",
91- });
92-
93- export default function App() {
94- return <PayEmbed client={client} />;
95- }` ;
96-
97- const sdkCode = ( clientId : string ) => `\
98- import { Bridge, NATIVE_TOKEN_ADDRESS, createThirdwebClient, toWei } from "thirdweb";
99-
100- const client = createThirdwebClient({
101- clientId: "${ clientId } ",
102- });
103-
104- const quote = await Bridge.Buy.prepare({
105- originChainId: 1,
106- originTokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
107- destinationChainId: 10,
108- destinationTokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
109- amount: toWei("0.01"),
110- sender: "0x2a4f24F935Eb178e3e7BA9B53A5Ee6d8407C0709",
111- receiver: "0x2a4f24F935Eb178e3e7BA9B53A5Ee6d8407C0709",
112- client,
113- });` ;
114-
115- const apiCode = ( clientId : string ) => `\
116- curl -X POST https://pay.thirdweb.com/v1/buy/prepare
117- -H "Content-Type: application/json"
118- -H "x-client-id: ${ clientId } "
119- -d '{"originChainId":"1","originTokenAddress":"0x...","destinationChainId":"10","destinationTokenAddress":"0x...","amount":"0.01"}'` ;
0 commit comments