|
1 | 1 | import { ShieldCheckIcon } from "lucide-react"; |
2 | 2 | import type { Metadata } from "next"; |
| 3 | +import { ThemeProvider } from "next-themes"; |
3 | 4 | import { Bridge, defineChain, toTokens } from "thirdweb"; |
4 | 5 | import { getChainMetadata } from "thirdweb/chains"; |
5 | 6 | import { shortenAddress } from "thirdweb/utils"; |
@@ -80,131 +81,137 @@ export default async function PayPage({ |
80 | 81 | } |
81 | 82 |
|
82 | 83 | return ( |
83 | | - <div className="flex z-10 flex-col lg:flex-row h-full w-full"> |
84 | | - <header className="min-w-full lg:min-w-[500px] border-b lg:border-r lg:h-full bg-card flex flex-col gap-4 items-start p-4 lg:p-8"> |
85 | | - <div> |
86 | | - <div className="flex flex-row items-center justify-start gap-4"> |
87 | | - {projectMetadata.image && ( |
88 | | - <img |
89 | | - src={ |
90 | | - resolveSchemeWithErrorHandler({ |
91 | | - uri: projectMetadata.image, |
92 | | - client: payAppThirdwebClient, |
93 | | - }) || "" |
94 | | - } |
95 | | - alt={projectMetadata.name} |
96 | | - width={25} |
97 | | - height={25} |
98 | | - className="rounded-full overflow-hidden" |
99 | | - /> |
| 84 | + <ThemeProvider |
| 85 | + forcedTheme={theme === "light" ? "light" : "dark"} |
| 86 | + attribute="class" |
| 87 | + disableTransitionOnChange |
| 88 | + enableSystem={false} |
| 89 | + > |
| 90 | + <div className="flex z-10 flex-col lg:flex-row h-full w-full"> |
| 91 | + <header className="min-w-full lg:min-w-[500px] border-b lg:border-r lg:h-full bg-card flex flex-col gap-4 items-start p-4 lg:p-8"> |
| 92 | + <div> |
| 93 | + <div className="flex flex-row items-center justify-start gap-4"> |
| 94 | + {projectMetadata.image && ( |
| 95 | + <img |
| 96 | + src={ |
| 97 | + resolveSchemeWithErrorHandler({ |
| 98 | + uri: projectMetadata.image, |
| 99 | + client: payAppThirdwebClient, |
| 100 | + }) || "" |
| 101 | + } |
| 102 | + alt={projectMetadata.name} |
| 103 | + width={25} |
| 104 | + height={25} |
| 105 | + className="rounded-full overflow-hidden" |
| 106 | + /> |
| 107 | + )} |
| 108 | + <h2 className="text-xl font-bold">{projectMetadata.name}</h2> |
| 109 | + </div> |
| 110 | + {projectMetadata.description && ( |
| 111 | + <p className="mt-2 text-sm text-muted-foreground"> |
| 112 | + {projectMetadata.description} |
| 113 | + </p> |
100 | 114 | )} |
101 | | - <h2 className="text-xl font-bold">{projectMetadata.name}</h2> |
102 | 115 | </div> |
103 | | - {projectMetadata.description && ( |
104 | | - <p className="mt-2 text-sm text-muted-foreground"> |
105 | | - {projectMetadata.description} |
106 | | - </p> |
107 | | - )} |
108 | | - </div> |
109 | 116 |
|
110 | | - <div className="hidden lg:block my-4 w-full"> |
111 | | - {paymentLink.amount && ( |
112 | | - <div className="flex flex-col gap-1 w-full my-4"> |
113 | | - <span className="text-muted-foreground text-xs">Details</span> |
114 | | - <div className="font-medium flex-row flex justify-between items-center w-full"> |
115 | | - <div className="flex flex-row items-center gap-2"> |
116 | | - {token.iconUri && ( |
117 | | - <img |
118 | | - src={resolveSchemeWithErrorHandler({ |
119 | | - uri: token.iconUri, |
120 | | - client: getConfiguredThirdwebClient({ |
121 | | - secretKey: DASHBOARD_THIRDWEB_SECRET_KEY, |
122 | | - teamId: undefined, |
123 | | - }), |
124 | | - })} |
125 | | - alt={token.name} |
126 | | - width={25} |
127 | | - height={25} |
128 | | - className="size-5 rounded-full overflow-hidden" |
129 | | - /> |
130 | | - )} |
131 | | - {toTokens(BigInt(paymentLink.amount), token.decimals)}{" "} |
132 | | - {token.symbol} |
133 | | - </div> |
134 | | - {token.prices.USD && ( |
135 | | - <span> |
136 | | - $ |
137 | | - {( |
138 | | - Number(token.prices.USD) * |
139 | | - Number( |
140 | | - toTokens(BigInt(paymentLink.amount), token.decimals), |
141 | | - ) |
142 | | - ).toFixed(2)} |
143 | | - </span> |
144 | | - )} |
145 | | - </div> |
146 | | - </div> |
147 | | - )} |
148 | | - {chain && ( |
149 | | - <div className="flex flex-col gap-1 w-full my-4"> |
150 | | - <span className="text-muted-foreground text-xs">Network</span> |
151 | | - <div className="font-medium flex-row flex justify-between items-center w-full"> |
152 | | - <div className="flex flex-row items-center gap-2"> |
153 | | - {chain.icon?.url && ( |
154 | | - <img |
155 | | - src={resolveSchemeWithErrorHandler({ |
156 | | - uri: chain.icon.url, |
157 | | - client: getConfiguredThirdwebClient({ |
158 | | - secretKey: DASHBOARD_THIRDWEB_SECRET_KEY, |
159 | | - teamId: undefined, |
160 | | - }), |
161 | | - })} |
162 | | - alt={chain.name} |
163 | | - width={chain.icon.width} |
164 | | - height={chain.icon.height} |
165 | | - className="size-5 rounded-full overflow-hidden" |
166 | | - /> |
| 117 | + <div className="hidden lg:block my-4 w-full"> |
| 118 | + {paymentLink.amount && ( |
| 119 | + <div className="flex flex-col gap-1 w-full my-4"> |
| 120 | + <span className="text-muted-foreground text-xs">Details</span> |
| 121 | + <div className="font-medium flex-row flex justify-between items-center w-full"> |
| 122 | + <div className="flex flex-row items-center gap-2"> |
| 123 | + {token.iconUri && ( |
| 124 | + <img |
| 125 | + src={resolveSchemeWithErrorHandler({ |
| 126 | + uri: token.iconUri, |
| 127 | + client: getConfiguredThirdwebClient({ |
| 128 | + secretKey: DASHBOARD_THIRDWEB_SECRET_KEY, |
| 129 | + teamId: undefined, |
| 130 | + }), |
| 131 | + })} |
| 132 | + alt={token.name} |
| 133 | + width={25} |
| 134 | + height={25} |
| 135 | + className="size-5 rounded-full overflow-hidden" |
| 136 | + /> |
| 137 | + )} |
| 138 | + {toTokens(BigInt(paymentLink.amount), token.decimals)}{" "} |
| 139 | + {token.symbol} |
| 140 | + </div> |
| 141 | + {token.prices.USD && ( |
| 142 | + <span> |
| 143 | + $ |
| 144 | + {( |
| 145 | + Number(token.prices.USD) * |
| 146 | + Number( |
| 147 | + toTokens(BigInt(paymentLink.amount), token.decimals), |
| 148 | + ) |
| 149 | + ).toFixed(2)} |
| 150 | + </span> |
167 | 151 | )} |
168 | | - {chain.name} |
169 | 152 | </div> |
170 | 153 | </div> |
171 | | - </div> |
172 | | - )} |
173 | | - {recipientEnsOrAddress.ensName || |
174 | | - (recipientEnsOrAddress.address && ( |
| 154 | + )} |
| 155 | + {chain && ( |
175 | 156 | <div className="flex flex-col gap-1 w-full my-4"> |
176 | | - <span className="text-muted-foreground text-xs">Seller</span> |
| 157 | + <span className="text-muted-foreground text-xs">Network</span> |
177 | 158 | <div className="font-medium flex-row flex justify-between items-center w-full"> |
178 | | - {recipientEnsOrAddress.ensName ?? |
179 | | - shortenAddress(recipientEnsOrAddress.address)} |
| 159 | + <div className="flex flex-row items-center gap-2"> |
| 160 | + {chain.icon?.url && ( |
| 161 | + <img |
| 162 | + src={resolveSchemeWithErrorHandler({ |
| 163 | + uri: chain.icon.url, |
| 164 | + client: getConfiguredThirdwebClient({ |
| 165 | + secretKey: DASHBOARD_THIRDWEB_SECRET_KEY, |
| 166 | + teamId: undefined, |
| 167 | + }), |
| 168 | + })} |
| 169 | + alt={chain.name} |
| 170 | + width={chain.icon.width} |
| 171 | + height={chain.icon.height} |
| 172 | + className="size-5 rounded-full overflow-hidden" |
| 173 | + /> |
| 174 | + )} |
| 175 | + {chain.name} |
| 176 | + </div> |
180 | 177 | </div> |
181 | 178 | </div> |
182 | | - ))} |
183 | | - </div> |
| 179 | + )} |
| 180 | + {recipientEnsOrAddress.ensName || |
| 181 | + (recipientEnsOrAddress.address && ( |
| 182 | + <div className="flex flex-col gap-1 w-full my-4"> |
| 183 | + <span className="text-muted-foreground text-xs">Seller</span> |
| 184 | + <div className="font-medium flex-row flex justify-between items-center w-full"> |
| 185 | + {recipientEnsOrAddress.ensName ?? |
| 186 | + shortenAddress(recipientEnsOrAddress.address)} |
| 187 | + </div> |
| 188 | + </div> |
| 189 | + ))} |
| 190 | + </div> |
184 | 191 |
|
185 | | - <div className="mt-auto hidden lg:block"> |
186 | | - <Badge className="flex items-center gap-1.5 bg-purple-100 text-purple-800 border-purple-200 dark:bg-purple-950 dark:text-purple-300 dark:border-purple-800"> |
187 | | - <ShieldCheckIcon className="size-3" /> |
188 | | - Secured by thirdweb |
189 | | - </Badge> |
190 | | - </div> |
191 | | - </header> |
192 | | - <main className="flex justify-center p-12 w-full items-center"> |
193 | | - <PayPageWidget |
194 | | - amount={paymentLink.amount ? BigInt(paymentLink.amount) : undefined} |
195 | | - chainId={Number(paymentLink.destinationToken.chainId)} |
196 | | - clientId={undefined} // Payment links don't need to use the same client ID to be executed |
197 | | - image={paymentLink.imageUrl} |
198 | | - name={paymentLink.title} |
199 | | - paymentLinkId={id} |
200 | | - purchaseData={paymentLink.purchaseData} |
201 | | - recipientAddress={paymentLink.receiver} |
202 | | - redirectUri={redirectUri} |
203 | | - theme={theme} |
204 | | - token={token} |
205 | | - /> |
206 | | - </main> |
207 | | - </div> |
| 192 | + <div className="mt-auto hidden lg:block"> |
| 193 | + <Badge className="flex items-center gap-1.5 bg-purple-100 text-purple-800 border-purple-200 dark:bg-purple-950 dark:text-purple-300 dark:border-purple-800"> |
| 194 | + <ShieldCheckIcon className="size-3" /> |
| 195 | + Secured by thirdweb |
| 196 | + </Badge> |
| 197 | + </div> |
| 198 | + </header> |
| 199 | + <main className="flex justify-center p-12 w-full items-center"> |
| 200 | + <PayPageWidget |
| 201 | + amount={paymentLink.amount ? BigInt(paymentLink.amount) : undefined} |
| 202 | + chainId={Number(paymentLink.destinationToken.chainId)} |
| 203 | + clientId={undefined} // Payment links don't need to use the same client ID to be executed |
| 204 | + image={paymentLink.imageUrl} |
| 205 | + name={paymentLink.title} |
| 206 | + paymentLinkId={id} |
| 207 | + purchaseData={paymentLink.purchaseData} |
| 208 | + recipientAddress={paymentLink.receiver} |
| 209 | + redirectUri={redirectUri} |
| 210 | + token={token} |
| 211 | + /> |
| 212 | + </main> |
| 213 | + </div> |
| 214 | + </ThemeProvider> |
208 | 215 | ); |
209 | 216 | } |
210 | 217 |
|
|
0 commit comments