Skip to content

Commit

Permalink
Remove card options from top up view
Browse files Browse the repository at this point in the history
  • Loading branch information
luads committed Nov 28, 2024
1 parent bab4551 commit ec47bde
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions packages/checkout/widgets-lib/src/views/top-up/TopUpView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,15 @@ export function TopUpView({
}
}, [checkout]);

const isOnRampAvailable = useAsyncMemo<boolean | undefined>(async () => {
if (!checkout) return undefined;
try {
return checkout.isOnRampAvailable();
} catch (error) {
return false;
}
}, [checkout]);

useMount(() => {
page({ userJourney, screen: 'TopUp' });
});
Expand Down Expand Up @@ -298,8 +307,8 @@ export function TopUpView({
'views.TOP_UP_VIEW.topUpOptions.debit.subcaption',
)}${onRampFeesPercentage}%`,
),
isAvailable: true,
isEnabled: showOnrampOption,
isAvailable: !!isOnRampAvailable,
isEnabled: showOnrampOption && !!isOnRampAvailable,
},
{
testId: 'onramp',
Expand All @@ -311,8 +320,8 @@ export function TopUpView({
'views.TOP_UP_VIEW.topUpOptions.credit.subcaption',
)}${onRampFeesPercentage}%`,
),
isAvailable: true,
isEnabled: showOnrampOption,
isAvailable: !!isOnRampAvailable,
isEnabled: showOnrampOption && !!isOnRampAvailable,
},
{
testId: 'advanced',
Expand Down Expand Up @@ -348,7 +357,7 @@ export function TopUpView({
isEnabled: showBridgeOption,
},
],
[showBridgeOption, showOnrampOption, showSwapOption],
[showBridgeOption, showOnrampOption, showSwapOption, isOnRampAvailable],
);

return (
Expand Down

0 comments on commit ec47bde

Please sign in to comment.