Skip to content

Commit 485b107

Browse files
committed
feat: allow using the checkout widget without a wallet connected
1 parent f33d8f1 commit 485b107

File tree

4 files changed

+20
-31
lines changed

4 files changed

+20
-31
lines changed

packages/thirdweb/src/react/web/ui/Bridge/BridgeOrchestrator.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,6 @@ export function BridgeOrchestrator({
277277
{state.value === "init" && uiOptions.mode === "direct_payment" && (
278278
<DirectPayment
279279
client={client}
280-
connectOptions={modifiedConnectOptions}
281280
onContinue={handleRequirementsResolved}
282281
showThirdwebBranding={showThirdwebBranding}
283282
uiOptions={uiOptions}

packages/thirdweb/src/react/web/ui/Bridge/CheckoutWidget.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ import { Spinner } from "../components/Spinner.js";
2727
import type { LocaleId } from "../types.js";
2828
import { BridgeOrchestrator, type UIOptions } from "./BridgeOrchestrator.js";
2929
import { UnsupportedTokenScreen } from "./UnsupportedTokenScreen.js";
30+
import { Container } from "../components/basic.js";
31+
import { Text } from "../components/text.js";
32+
import { Button } from "../components/buttons.js";
3033

3134
export type CheckoutWidgetProps = {
3235
/**
@@ -421,6 +424,19 @@ export function CheckoutWidget(props: CheckoutWidgetProps) {
421424
);
422425
}
423426

427+
if (bridgeDataQuery.isError) {
428+
content = (
429+
<Container flex="column" center="both" gap="md" p="md" py="xl">
430+
<Text center size="md" weight={600}>
431+
Something went wrong.
432+
</Text>
433+
<Button variant="ghost" onClick={() => bridgeDataQuery.refetch()}>
434+
Retry
435+
</Button>
436+
</Container>
437+
);
438+
}
439+
424440
return (
425441
<CustomThemeProvider theme={theme}>
426442
<EmbedContainer

packages/thirdweb/src/react/web/ui/Bridge/DirectPayment.tsx

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,13 @@ import type { Token } from "../../../../bridge/types/Token.js";
33
import { defineChain } from "../../../../chains/utils.js";
44
import type { ThirdwebClient } from "../../../../client/client.js";
55
import type { Address } from "../../../../utils/address.js";
6-
import { useCustomTheme } from "../../../core/design-system/CustomThemeProvider.js";
7-
import { useActiveAccount } from "../../../core/hooks/wallets/useActiveAccount.js";
8-
import { ConnectButton } from "../ConnectWallet/ConnectButton.js";
96
import { PoweredByThirdweb } from "../ConnectWallet/PoweredByTW.js";
107
import { FiatValue } from "../ConnectWallet/screens/Buy/swap/FiatValue.js";
118
import { Container, Line } from "../components/basic.js";
129
import { Button } from "../components/buttons.js";
1310
import { ChainName } from "../components/ChainName.js";
1411
import { Spacer } from "../components/Spacer.js";
1512
import { Text } from "../components/text.js";
16-
import type { PayEmbedConnectOptions } from "../PayEmbed.js";
1713
import type { UIOptions } from "./BridgeOrchestrator.js";
1814
import { ChainIcon } from "./common/TokenAndChain.js";
1915
import { WithHeader } from "./common/WithHeader.js";
@@ -34,11 +30,6 @@ export interface DirectPaymentProps {
3430
*/
3531
onContinue: (amount: string, token: Token, receiverAddress: Address) => void;
3632

37-
/**
38-
* Connect options for wallet connection
39-
*/
40-
connectOptions?: PayEmbedConnectOptions;
41-
4233
/**
4334
* Whether to show thirdweb branding in the widget.
4435
* @default true
@@ -50,12 +41,9 @@ export function DirectPayment({
5041
uiOptions,
5142
client,
5243
onContinue,
53-
connectOptions,
5444
showThirdwebBranding = true,
5545
}: DirectPaymentProps) {
56-
const activeAccount = useActiveAccount();
5746
const chain = defineChain(uiOptions.paymentInfo.token.chainId);
58-
const theme = useCustomTheme();
5947
const handleContinue = () => {
6048
onContinue(
6149
uiOptions.paymentInfo.amount,
@@ -188,23 +176,9 @@ export function DirectPayment({
188176

189177
{/* Action button */}
190178
<Container flex="column">
191-
{activeAccount ? (
192-
<Button fullWidth onClick={handleContinue} variant="primary">
193-
{buyNow}
194-
</Button>
195-
) : (
196-
<ConnectButton
197-
client={client}
198-
connectButton={{
199-
label: buyNow,
200-
style: {
201-
width: "100%",
202-
},
203-
}}
204-
theme={theme}
205-
{...connectOptions}
206-
/>
207-
)}
179+
<Button fullWidth onClick={handleContinue} variant="primary">
180+
{buyNow}
181+
</Button>
208182

209183
{showThirdwebBranding ? (
210184
<div>

packages/thirdweb/src/react/web/ui/Bridge/payment-selection/WalletFiatSelection.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export function WalletFiatSelection({
121121
</Container>
122122
<Container flex="column" gap="3xs" style={{ flex: 1 }}>
123123
<Text color="primaryText" size="sm" style={{ fontWeight: 600 }}>
124-
Connect Another Wallet
124+
Connect a Wallet
125125
</Text>
126126
<Text color="secondaryText" size="xs">
127127
Use a different wallet to pay

0 commit comments

Comments
 (0)