Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PAY-2270] Show vendor button only if more than 1 vendor #6945

Merged
merged 1 commit into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions packages/mobile/src/components/payment-method/PaymentMethod.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import {
formatCurrencyBalance,
FeatureFlags,
useFeatureFlag,
PurchaseVendor
PurchaseVendor,
removeNullable
} from '@audius/common'
import BN from 'bn.js'
import { FlatList, View, TouchableOpacity } from 'react-native'
Expand Down Expand Up @@ -87,6 +88,10 @@ export const PaymentMethod = ({
const purchaseVendor = useSelector(getPurchaseVendor)
const { isEnabled: isCoinflowEnabled, isLoaded: isCoinflowEnabledLoaded } =
useFeatureFlag(FeatureFlags.BUY_WITH_COINFLOW)
const vendorOptions = [
isCoinflowEnabled ? PurchaseVendor.COINFLOW : null,
PurchaseVendor.STRIPE
].filter(removeNullable)

// Initial state is coinflow by default, but set to stripe if coinflow is disabled.
useEffect(() => {
Expand All @@ -105,7 +110,10 @@ export const PaymentMethod = ({
</Text>
),
icon: IconCreditCard,
content: <CardSelectionButton selectedVendor={purchaseVendor} />
content:
vendorOptions.length > 1 ? (
<CardSelectionButton selectedVendor={purchaseVendor} />
) : null
},
{
id: PurchaseMethod.CRYPTO,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ const RenderForm = ({
setSelectedMethod={setPurchaseMethod}
balance={balance}
isExistingBalanceDisabled={isExistingBalanceDisabled}
showExistingBalance={!balance?.isZero}
showExistingBalance={!balance?.isZero()}
/>
)}
</View>
Expand Down