Skip to content

Commit

Permalink
[PAY-2270] Show vendor button only if more than 1 vendor (#6945)
Browse files Browse the repository at this point in the history
  • Loading branch information
dharit-tan authored Dec 14, 2023
1 parent 9c2e79c commit 215a36a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
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

0 comments on commit 215a36a

Please sign in to comment.