Skip to content

Commit b4a82a3

Browse files
committed
update
1 parent ff2e53e commit b4a82a3

File tree

5 files changed

+70
-63
lines changed

5 files changed

+70
-63
lines changed

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

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -326,37 +326,13 @@ export type BuyWidgetProps = {
326326
* @bridge
327327
*/
328328
export function BuyWidget(props: BuyWidgetProps) {
329-
useQuery({
330-
queryFn: () => {
331-
trackPayEvent({
332-
client: props.client,
333-
event: "ub:ui:buy_widget:render",
334-
toChainId: props.chain.id,
335-
toToken: props.tokenAddress,
336-
});
337-
return true;
338-
},
339-
queryKey: ["buy_widget:render"],
340-
});
341-
342-
const connectOptions = useMemo(() => {
343-
if (!props.connectOptions) return undefined;
344-
return {
345-
...props.connectOptions,
346-
connectModal: {
347-
...props.connectOptions.connectModal,
348-
showThirdwebBranding: props.showThirdwebBranding,
349-
},
350-
};
351-
}, [props.connectOptions, props.showThirdwebBranding]);
352-
353329
return (
354330
<BridgeWidgetContainer
355331
theme={props.theme}
356332
className={props.className}
357333
style={props.style}
358334
>
359-
<BridgeWidgetContentWrapper {...props} connectOptions={connectOptions} />
335+
<BridgeWidgetContentWrapper {...props} />
360336
</BridgeWidgetContainer>
361337
);
362338
}
@@ -369,6 +345,33 @@ function BridgeWidgetContentWrapper(props: BuyWidgetProps) {
369345
client: props.client,
370346
});
371347

348+
useQuery({
349+
queryFn: () => {
350+
trackPayEvent({
351+
client: props.client,
352+
event: "ub:ui:buy_widget:render",
353+
toChainId: props.chain.id,
354+
toToken: props.tokenAddress,
355+
});
356+
return true;
357+
},
358+
queryKey: ["buy_widget:render"],
359+
});
360+
361+
// if branding is disabled for widget, disable it for connect options too
362+
const connectOptions = useMemo(() => {
363+
if (props.showThirdwebBranding === false) {
364+
return {
365+
...props.connectOptions,
366+
connectModal: {
367+
...props.connectOptions?.connectModal,
368+
showThirdwebBranding: false,
369+
},
370+
};
371+
}
372+
return props.connectOptions;
373+
}, [props.connectOptions, props.showThirdwebBranding]);
374+
372375
if (tokenQuery.isPending || !localQuery.data) {
373376
return (
374377
<div
@@ -399,6 +402,7 @@ function BridgeWidgetContentWrapper(props: BuyWidgetProps) {
399402
currency={props.currency || "USD"}
400403
paymentMethods={props.paymentMethods || ["crypto", "card"]}
401404
presetOptions={props.presetOptions || [5, 10, 20]}
405+
connectOptions={connectOptions}
402406
showThirdwebBranding={
403407
props.showThirdwebBranding === undefined
404408
? true

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

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -313,40 +313,13 @@ export type CheckoutWidgetProps = {
313313
* @bridge
314314
*/
315315
export function CheckoutWidget(props: CheckoutWidgetProps) {
316-
useQuery({
317-
queryFn: () => {
318-
trackPayEvent({
319-
client: props.client,
320-
event: "ub:ui:checkout_widget:render",
321-
toChainId: props.chain.id,
322-
toToken: props.tokenAddress,
323-
});
324-
return true;
325-
},
326-
queryKey: ["checkout_widget:render"],
327-
});
328-
329-
const connectOptions = useMemo(() => {
330-
if (!props.connectOptions) return undefined;
331-
return {
332-
...props.connectOptions,
333-
connectModal: {
334-
...props.connectOptions.connectModal,
335-
showThirdwebBranding: props.showThirdwebBranding,
336-
},
337-
};
338-
}, [props.connectOptions, props.showThirdwebBranding]);
339-
340316
return (
341317
<CheckoutWidgetContainer
342318
theme={props.theme}
343319
className={props.className}
344320
style={props.style}
345321
>
346-
<CheckoutWidgetContentWrapper
347-
{...props}
348-
connectOptions={connectOptions}
349-
/>
322+
<CheckoutWidgetContentWrapper {...props} />
350323
</CheckoutWidgetContainer>
351324
);
352325
}
@@ -359,6 +332,33 @@ function CheckoutWidgetContentWrapper(props: CheckoutWidgetProps) {
359332
client: props.client,
360333
});
361334

335+
useQuery({
336+
queryFn: () => {
337+
trackPayEvent({
338+
client: props.client,
339+
event: "ub:ui:checkout_widget:render",
340+
toChainId: props.chain.id,
341+
toToken: props.tokenAddress,
342+
});
343+
return true;
344+
},
345+
queryKey: ["checkout_widget:render"],
346+
});
347+
348+
// if branding is disabled for widget, disable it for connect options too
349+
const connectOptions = useMemo(() => {
350+
if (!props.showThirdwebBranding === false) {
351+
return {
352+
...props.connectOptions,
353+
connectModal: {
354+
...props.connectOptions?.connectModal,
355+
showThirdwebBranding: false,
356+
},
357+
};
358+
}
359+
return props.connectOptions;
360+
}, [props.connectOptions, props.showThirdwebBranding]);
361+
362362
if (tokenQuery.isPending || !localQuery.data) {
363363
return (
364364
<div
@@ -388,6 +388,7 @@ function CheckoutWidgetContentWrapper(props: CheckoutWidgetProps) {
388388
destinationToken={tokenQuery.data.token}
389389
currency={props.currency || "USD"}
390390
paymentMethods={props.paymentMethods || ["crypto", "card"]}
391+
connectOptions={connectOptions}
391392
showThirdwebBranding={
392393
props.showThirdwebBranding === undefined
393394
? true

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ type FundWalletProps = {
4949

5050
/**
5151
* Quick buy amounts
52-
* @default [5, 10, 20]
5352
*/
5453
presetOptions: [number, number, number];
5554

@@ -110,6 +109,7 @@ export function FundWallet({
110109
const theme = useCustomTheme();
111110
const account = useActiveAccount();
112111
const receiver = receiverAddress ?? account?.address;
112+
113113
const handleAmountChange = (inputValue: string) => {
114114
let processedValue = inputValue;
115115

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

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -355,15 +355,18 @@ export function TransactionWidgetContentWrapper(props: TransactionWidgetProps) {
355355
client: props.client,
356356
});
357357

358+
// if branding is disabled for widget, disable it for connect options too
358359
const connectOptions = useMemo(() => {
359-
if (!props.connectOptions) return undefined;
360-
return {
361-
...props.connectOptions,
362-
connectModal: {
363-
...props.connectOptions.connectModal,
364-
showThirdwebBranding: props.showThirdwebBranding,
365-
},
366-
};
360+
if (props.showThirdwebBranding === false) {
361+
return {
362+
...props.connectOptions,
363+
connectModal: {
364+
...props.connectOptions?.connectModal,
365+
showThirdwebBranding: props.showThirdwebBranding,
366+
},
367+
};
368+
}
369+
return props.connectOptions;
367370
}, [props.connectOptions, props.showThirdwebBranding]);
368371

369372
if (tokenQuery.isPending || !localQuery.data) {

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ type PaymentSelectionProps = {
7676

7777
/**
7878
* Allowed payment methods
79-
* @default ["crypto", "card"]
8079
*/
8180
paymentMethods: ("crypto" | "card")[];
8281

0 commit comments

Comments
 (0)