From 7b59d097cfaf966e6dfe4c55b8e8978a11546511 Mon Sep 17 00:00:00 2001 From: Usame Algan Date: Thu, 9 Nov 2023 09:39:03 +0100 Subject: [PATCH] fix: Add ramp view to assets page if there are no assets --- src/components/balances/AssetsTable/index.tsx | 64 +++++++++++++++++-- 1 file changed, 60 insertions(+), 4 deletions(-) diff --git a/src/components/balances/AssetsTable/index.tsx b/src/components/balances/AssetsTable/index.tsx index b673142d13..b333ab43d4 100644 --- a/src/components/balances/AssetsTable/index.tsx +++ b/src/components/balances/AssetsTable/index.tsx @@ -1,5 +1,14 @@ +import EthHashInfo from '@/components/common/EthHashInfo' +import QRCode from '@/components/common/QRCode' +import { AppRoutes } from '@/config/routes' +import { useCurrentChain } from '@/hooks/useChains' +import useSafeAddress from '@/hooks/useSafeAddress' +import { useAppSelector } from '@/store' +import { selectSettings } from '@/store/settingsSlice' +import Link from 'next/link' +import { useRouter } from 'next/router' import { type ReactElement, useMemo, useContext } from 'react' -import { Button, Tooltip, Typography, SvgIcon, IconButton, Box, Checkbox, Skeleton } from '@mui/material' +import { Button, Tooltip, Typography, SvgIcon, IconButton, Box, Checkbox, Skeleton, Paper, Grid } from '@mui/material' import type { TokenInfo } from '@safe-global/safe-gateway-typescript-sdk' import { TokenType } from '@safe-global/safe-gateway-typescript-sdk' import css from './styles.module.css' @@ -20,6 +29,7 @@ import CheckWallet from '@/components/common/CheckWallet' import useSpendingLimit from '@/hooks/useSpendingLimit' import { TxModalContext } from '@/components/tx-flow' import TokenTransferFlow from '@/components/tx-flow/flows/TokenTransfer' +import AddIcon from '@mui/icons-material/Add' const skeletonCells: EnhancedTableProps['rows'][0]['cells'] = { asset: { @@ -137,6 +147,8 @@ 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) => { @@ -247,11 +259,55 @@ const AssetsTable = ({ showHiddenAssets={showHiddenAssets} /> -
- -
+ {hasNoAssets ? ( + + ) : ( +
+ +
+ )} ) } +const NoAssets = () => { + const router = useRouter() + const safeAddress = useSafeAddress() + const chain = useCurrentChain() + const settings = useAppSelector(selectSettings) + const qrPrefix = settings.shortName.qr ? `${chain?.shortName}:` : '' + const qrCode = `${qrPrefix}${safeAddress}` + + return ( + + + + + + + + + + Add funds to get started + + + Add funds directly from your bank account or copy your address to send tokens from a different account. + + + + + + {/* TODO: Insert link for Ramp app */} + + + + + + + + ) +} + export default AssetsTable