Skip to content

Commit

Permalink
fix(tx-list): hide buy banner when tx count is 0 (#3636)
Browse files Browse the repository at this point in the history
Signed-off-by: banklesss <[email protected]>
Co-authored-by: Michal S <[email protected]>
  • Loading branch information
banklesss and michaeljscript authored Sep 18, 2024
1 parent dfc4ce1 commit 06ebcef
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import {Chain} from '@yoroi/types'
import _ from 'lodash'
import * as React from 'react'

import {useBalances} from '../../../../yoroi-wallets/hooks'
import {useBalances, useTransactionInfos} from '../../../../yoroi-wallets/hooks'
import {Amounts, Quantities} from '../../../../yoroi-wallets/utils/utils'
import {useSelectedWallet} from '../../../WalletManager/common/hooks/useSelectedWallet'
import {useWalletManager} from '../../../WalletManager/context/WalletManagerProvider'
Expand All @@ -14,19 +15,21 @@ import {SanchonetFaucetBanner} from './SanchonetFaucetBanner'

export const ShowBuyBanner = () => {
const {wallet} = useSelectedWallet()
const transactionInfos = useTransactionInfos({wallet})
const {
selected: {network},
} = useWalletManager()
const balances = useBalances(wallet)
const primaryAmount = Amounts.getAmount(balances, wallet.portfolioPrimaryTokenInfo.id)
const hasZeroPt = Quantities.isZero(primaryAmount.quantity)
const hasZeroTx = _.isEmpty(transactionInfos)

const showSmallBanner = useShowBuyBannerSmall()
const {resetShowBuyBannerSmall} = useResetShowBuyBannerSmall()

if (hasZeroPt && network === Chain.Network.Preprod) return <PreprodFaucetBanner />
if (hasZeroPt && network === Chain.Network.Sancho) return <SanchonetFaucetBanner />
if (hasZeroPt) return <BuyBannerBig />
if (hasZeroPt && hasZeroTx && network === Chain.Network.Preprod) return <PreprodFaucetBanner />
if (hasZeroPt && hasZeroTx && network === Chain.Network.Sancho) return <SanchonetFaucetBanner />
if (hasZeroPt && hasZeroTx) return <BuyBannerBig />
if (showSmallBanner) return <BuyBannerSmall onClose={resetShowBuyBannerSmall} />

return null
Expand Down

0 comments on commit 06ebcef

Please sign in to comment.