11"use client" ;
2+
23import { ExternalLinkIcon } from "lucide-react" ;
34import Link from "next/link" ;
45import { useState } from "react" ;
56import { Button } from "@/components/ui/button" ;
6- import { CodeServer } from "@/components/ui/code/code.server" ;
77import { TabButtons } from "@/components/ui/tabs" ;
88
9- export function PayEmbedFTUX ( props : { clientId : string } ) {
10- const [ tab , setTab ] = useState ( "embed" ) ;
9+ type Tab = "embed" | "sdk" | "api" ;
10+
11+ export function PayEmbedFTUX ( props : {
12+ clientId : string ;
13+ codeExamples : {
14+ embed : React . ReactNode ;
15+ sdk : React . ReactNode ;
16+ api : React . ReactNode ;
17+ } ;
18+ } ) {
19+ const [ tab , setTab ] = useState < Tab > ( "embed" ) ;
1120 return (
1221 < 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" >
22+ < div className = "border-b border-dashed p-4 " >
23+ < h2 className = "font-semibold text-lg tracking-tight" >
1524 Start Monetizing Your App
1625 </ h2 >
1726 </ div >
1827
19- < div className = "px -4 py-6 lg:p-6 " >
28+ < div className = "p -4 pt-2 " >
2029 < TabButtons
2130 tabClassName = "!text-sm"
2231 tabs = { [
@@ -38,32 +47,11 @@ export function PayEmbedFTUX(props: { clientId: string }) {
3847 ] }
3948 />
4049 < div className = "h-2" />
41- { tab === "embed" && (
42- < CodeServer
43- className = "bg-background"
44- code = { embedCode ( props . clientId ) }
45- lang = "tsx"
46- />
47- ) }
48- { tab === "sdk" && (
49- < CodeServer
50- className = "bg-background"
51- code = { sdkCode ( props . clientId ) }
52- ignoreFormattingErrors
53- lang = "ts"
54- />
55- ) }
56- { tab === "api" && (
57- < CodeServer
58- className = "bg-background"
59- code = { apiCode ( props . clientId ) }
60- ignoreFormattingErrors
61- lang = "bash"
62- />
63- ) }
50+
51+ { props . codeExamples [ tab ] }
6452 </ div >
6553
66- < div className = "flex flex-col gap-3 border-t p-4 lg:flex-row lg:items-center lg:justify-between lg:p-6 " >
54+ < div className = "flex flex-col gap-3 border-t p-4 lg:flex-row lg:items-center lg:justify-between" >
6755 < div className = "flex gap-3" >
6856 < Button asChild size = "sm" variant = "outline" >
6957 < Link
@@ -81,39 +69,3 @@ export function PayEmbedFTUX(props: { clientId: string }) {
8169 </ div >
8270 ) ;
8371}
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