Skip to content

Commit

Permalink
fix: Only show add funds cta if user has no funds
Browse files Browse the repository at this point in the history
  • Loading branch information
usame-algan committed Feb 9, 2024
1 parent 8f1f5e2 commit 68dfeed
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
14 changes: 5 additions & 9 deletions src/components/balances/AssetsTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,6 @@ const AssetsTable = ({
[hiddenAssets, balances.items, showHiddenAssets],
)

const hasNoAssets = balances.items.length === 1 && balances.items[0].balance === '0'

const selectedAssetCount = visibleAssets?.filter((item) => isAssetSelected(item.tokenInfo.address)).length || 0

const onSendClick = (tokenAddress: string) => {
Expand Down Expand Up @@ -250,13 +248,11 @@ const AssetsTable = ({
showHiddenAssets={showHiddenAssets}
/>

{hasNoAssets ? (
<AddFundsCTA />
) : (
<div className={css.container}>
<EnhancedTable rows={rows} headCells={headCells} />
</div>
)}
<div className={css.container}>
<EnhancedTable rows={rows} headCells={headCells} />
</div>

<AddFundsCTA />
</>
)
}
Expand Down
6 changes: 6 additions & 0 deletions src/components/common/AddFunds/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import useBalances from '@/hooks/useBalances'
import { Box, FormControlLabel, Grid, Paper, Switch, Typography } from '@mui/material'
import EthHashInfo from '@/components/common/EthHashInfo'
import QRCode from '@/components/common/QRCode'
Expand All @@ -8,13 +9,18 @@ import { selectSettings, setQrShortName } from '@/store/settingsSlice'
import BuyCryptoButton from '@/components/common/BuyCryptoButton'

const AddFundsCTA = () => {
const { balances } = useBalances()
const safeAddress = useSafeAddress()
const chain = useCurrentChain()
const dispatch = useAppDispatch()
const settings = useAppSelector(selectSettings)
const qrPrefix = settings.shortName.qr ? `${chain?.shortName}:` : ''
const qrCode = `${qrPrefix}${safeAddress}`

const hasNoAssets = balances.items.length === 1 && balances.items[0].balance === '0'

if (!hasNoAssets) return null

return (
<Paper>
<Grid container gap={3} alignItems="center" justifyContent="center" p={4}>
Expand Down
4 changes: 2 additions & 2 deletions src/components/dashboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import GovernanceSection from '@/components/dashboard/GovernanceSection/Governan
import CreationDialog from '@/components/dashboard/CreationDialog'
import { useRouter } from 'next/router'
import { CREATION_MODAL_QUERY_PARM } from '../new-safe/create/logic'

import css from './styles.module.css'
import useRecovery from '@/features/recovery/hooks/useRecovery'
import { useIsRecoverySupported } from '@/features/recovery/hooks/useIsRecoverySupported'
const RecoveryHeader = dynamic(() => import('@/features/recovery/components/RecoveryHeader'))
Expand All @@ -27,7 +27,7 @@ const Dashboard = (): ReactElement => {

return (
<>
<Grid container spacing={3}>
<Grid container spacing={3} className={css.container}>
{supportsRecovery && <RecoveryHeader />}

<Grid item xs={12}>
Expand Down
3 changes: 3 additions & 0 deletions src/components/dashboard/styles.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.container > div:empty {
display: none;
}

0 comments on commit 68dfeed

Please sign in to comment.