|
| 1 | +import { WebhookIcon } from "lucide-react"; |
| 2 | +import { redirect } from "next/navigation"; |
| 3 | +import { ResponsiveSearchParamsProvider } from "responsive-rsc"; |
| 4 | +import { getAuthToken } from "@/api/auth-token"; |
| 5 | +import { getProject } from "@/api/project/projects"; |
| 6 | +import { ProjectPage } from "@/components/blocks/project-page/project-page"; |
| 7 | +import { getClientThirdwebClient } from "@/constants/thirdweb-client.client"; |
| 8 | +import { BridgeIcon } from "@/icons/BridgeIcon"; |
| 9 | +import { loginRedirect } from "@/utils/redirects"; |
| 10 | +import { AdvancedSection } from "../payments/components/AdvancedSection.client"; |
| 11 | +import { PayAnalytics } from "../payments/components/PayAnalytics"; |
| 12 | +import { getUniversalBridgeFiltersFromSearchParams } from "../payments/components/time"; |
| 13 | +import { QuickStartSection } from "./QuickstartSection.client"; |
| 14 | + |
| 15 | +export default async function Page(props: { |
| 16 | + params: Promise<{ |
| 17 | + team_slug: string; |
| 18 | + project_slug: string; |
| 19 | + }>; |
| 20 | + searchParams: Promise<{ |
| 21 | + from?: string | undefined | string[]; |
| 22 | + to?: string | undefined | string[]; |
| 23 | + interval?: string | undefined | string[]; |
| 24 | + }>; |
| 25 | +}) { |
| 26 | + const [params, authToken] = await Promise.all([props.params, getAuthToken()]); |
| 27 | + |
| 28 | + const project = await getProject(params.team_slug, params.project_slug); |
| 29 | + |
| 30 | + if (!authToken) { |
| 31 | + loginRedirect(`/team/${params.team_slug}/${params.project_slug}/payments`); |
| 32 | + } |
| 33 | + |
| 34 | + if (!project) { |
| 35 | + redirect(`/team/${params.team_slug}`); |
| 36 | + } |
| 37 | + |
| 38 | + const searchParams = await props.searchParams; |
| 39 | + |
| 40 | + const { range, interval } = getUniversalBridgeFiltersFromSearchParams({ |
| 41 | + defaultRange: "last-30", |
| 42 | + from: searchParams.from, |
| 43 | + interval: searchParams.interval, |
| 44 | + to: searchParams.to, |
| 45 | + }); |
| 46 | + |
| 47 | + const client = getClientThirdwebClient({ |
| 48 | + jwt: authToken, |
| 49 | + teamId: project.teamId, |
| 50 | + }); |
| 51 | + |
| 52 | + return ( |
| 53 | + <ProjectPage |
| 54 | + header={{ |
| 55 | + client, |
| 56 | + title: "Bridge", |
| 57 | + icon: BridgeIcon, |
| 58 | + description: ( |
| 59 | + <> |
| 60 | + Bridge allows you to enable seamless onramps, swaps, and cross-chain |
| 61 | + transfers <br className="max-sm:hidden" /> to move funds |
| 62 | + effortlessly across any EVM network |
| 63 | + </> |
| 64 | + ), |
| 65 | + actions: { |
| 66 | + secondary: { |
| 67 | + href: `/team/${params.team_slug}/${params.project_slug}/webhooks/payments`, |
| 68 | + label: "Webhooks", |
| 69 | + icon: <WebhookIcon className="size-3.5 text-muted-foreground" />, |
| 70 | + }, |
| 71 | + }, |
| 72 | + settings: { |
| 73 | + href: `/team/${params.team_slug}/${params.project_slug}/settings/payments`, |
| 74 | + }, |
| 75 | + links: [ |
| 76 | + { |
| 77 | + type: "docs", |
| 78 | + href: "https://portal.thirdweb.com/payments", |
| 79 | + }, |
| 80 | + { |
| 81 | + type: "playground", |
| 82 | + href: "https://playground.thirdweb.com/payments/ui-components", |
| 83 | + }, |
| 84 | + { |
| 85 | + type: "api", |
| 86 | + href: "https://api.thirdweb.com/reference#tag/payments", |
| 87 | + }, |
| 88 | + ], |
| 89 | + }} |
| 90 | + footer={{ |
| 91 | + center: { |
| 92 | + links: [ |
| 93 | + { |
| 94 | + href: "https://playground.thirdweb.com/payments/ui-components", |
| 95 | + label: "UI Component", |
| 96 | + }, |
| 97 | + { |
| 98 | + href: "https://playground.thirdweb.com/connect/payments/fund-wallet", |
| 99 | + label: "Buy Crypto", |
| 100 | + }, |
| 101 | + { |
| 102 | + href: "https://playground.thirdweb.com/connect/payments/commerce", |
| 103 | + label: "Checkout", |
| 104 | + }, |
| 105 | + { |
| 106 | + href: "https://playground.thirdweb.com/connect/payments/transactions", |
| 107 | + label: "Transactions", |
| 108 | + }, |
| 109 | + ], |
| 110 | + title: "Demos", |
| 111 | + }, |
| 112 | + left: { |
| 113 | + links: [ |
| 114 | + { |
| 115 | + href: "https://portal.thirdweb.com/payments", |
| 116 | + label: "Overview", |
| 117 | + }, |
| 118 | + { |
| 119 | + href: "https://portal.thirdweb.com/typescript/v5/convertCryptoToFiat", |
| 120 | + label: "TypeScript", |
| 121 | + }, |
| 122 | + { |
| 123 | + href: "https://portal.thirdweb.com/react/v5/pay/fund-wallets", |
| 124 | + label: "React", |
| 125 | + }, |
| 126 | + { |
| 127 | + href: "https://portal.thirdweb.com/dotnet/universal-bridge/quickstart", |
| 128 | + label: ".NET", |
| 129 | + }, |
| 130 | + ], |
| 131 | + title: "Documentation", |
| 132 | + }, |
| 133 | + right: { |
| 134 | + links: [ |
| 135 | + { |
| 136 | + href: "https://www.youtube.com/watch?v=aBu175-VsNY", |
| 137 | + label: "Implement cross-chain payments in any app", |
| 138 | + }, |
| 139 | + ], |
| 140 | + title: "Tutorials", |
| 141 | + }, |
| 142 | + }} |
| 143 | + > |
| 144 | + <div className="flex flex-col gap-12"> |
| 145 | + <ResponsiveSearchParamsProvider value={searchParams}> |
| 146 | + <PayAnalytics |
| 147 | + client={client} |
| 148 | + interval={interval} |
| 149 | + projectClientId={project.publishableKey} |
| 150 | + projectId={project.id} |
| 151 | + range={range} |
| 152 | + teamId={project.teamId} |
| 153 | + authToken={authToken} |
| 154 | + /> |
| 155 | + </ResponsiveSearchParamsProvider> |
| 156 | + |
| 157 | + <QuickStartSection |
| 158 | + projectSlug={params.project_slug} |
| 159 | + teamSlug={params.team_slug} |
| 160 | + clientId={project.publishableKey} |
| 161 | + teamId={project.teamId} |
| 162 | + /> |
| 163 | + |
| 164 | + <AdvancedSection |
| 165 | + projectSlug={params.project_slug} |
| 166 | + teamSlug={params.team_slug} |
| 167 | + /> |
| 168 | + </div> |
| 169 | + </ProjectPage> |
| 170 | + ); |
| 171 | +} |
0 commit comments