Skip to content

Commit

Permalink
fix: display account wallet partially while loading (#420)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cafe137 authored Jun 21, 2022
1 parent f238c43 commit f43de77
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 33 deletions.
45 changes: 26 additions & 19 deletions src/pages/account/chequebook/AccountChequebook.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,37 @@ export function AccountChequebook(): ReactElement {

if (status.all === CheckState.ERROR) return <TroubleshootConnectionCard />

const showChequebook = chequebookBalance?.totalBalance !== undefined

return (
<>
<Header />
<AccountNavigation active="CHEQUEBOOK" />
<div>
<ExpandableList label="Chequebook" defaultOpen>
<ExpandableListItem label="Total Balance" value={`${chequebookBalance?.totalBalance.toFixedDecimal()} BZZ`} />
<ExpandableListItem
label="Available Uncommitted Balance"
value={`${chequebookBalance?.availableBalance.toFixedDecimal()} BZZ`}
/>
<ExpandableListItem
label="Total Cheques Amount Sent"
value={`${settlements?.totalSent.toFixedDecimal()} BZZ`}
/>
<ExpandableListItem
label="Total Cheques Amount Received"
value={`${settlements?.totalReceived.toFixedDecimal()} BZZ`}
/>
<ExpandableListItemActions>
<WithdrawModal />
<DepositModal />
</ExpandableListItemActions>
</ExpandableList>
{showChequebook && (
<ExpandableList label="Chequebook" defaultOpen>
<ExpandableListItem
label="Total Balance"
value={`${chequebookBalance?.totalBalance.toFixedDecimal()} BZZ`}
/>
<ExpandableListItem
label="Available Uncommitted Balance"
value={`${chequebookBalance?.availableBalance.toFixedDecimal()} BZZ`}
/>
<ExpandableListItem
label="Total Cheques Amount Sent"
value={`${settlements?.totalSent.toFixedDecimal()} BZZ`}
/>
<ExpandableListItem
label="Total Cheques Amount Received"
value={`${settlements?.totalReceived.toFixedDecimal()} BZZ`}
/>
<ExpandableListItemActions>
<WithdrawModal />
<DepositModal />
</ExpandableListItemActions>
</ExpandableList>
)}
<ExpandableList label="Blockchain" defaultOpen>
<ExpandableListItemKey label="Ethereum address" value={nodeAddresses?.ethereum || ''} />
<ExpandableListItemKey
Expand Down
32 changes: 18 additions & 14 deletions src/pages/account/wallet/AccountWallet.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Box, Grid, Typography } from '@material-ui/core'
import { ReactElement, useContext } from 'react'
import { useNavigate } from 'react-router'
import Download from 'remixicon-react/DownloadLineIcon'
import Gift from 'remixicon-react/GiftLineIcon'
import Link from 'remixicon-react/LinkIcon'
import { useNavigate } from 'react-router'
import ExpandableListItem from '../../../components/ExpandableListItem'
import ExpandableListItemActions from '../../../components/ExpandableListItemActions'
import ExpandableListItemKey from '../../../components/ExpandableListItemKey'
Expand All @@ -19,10 +19,6 @@ export function AccountWallet(): ReactElement {

const navigate = useNavigate()

if (!balance || !nodeAddresses) {
return <Loading />
}

function onCheckTransactions() {
window.open(`https://blockscout.com/xdai/mainnet/address/${nodeAddresses?.ethereum}/transactions`, '_blank')
}
Expand All @@ -47,15 +43,23 @@ export function AccountWallet(): ReactElement {
</SwarmButton>
</Grid>
</Box>
<Box mb={0.25}>
<ExpandableListItemKey label="Node wallet address" value={nodeAddresses.ethereum} expanded />
</Box>
<Box mb={0.25}>
<ExpandableListItem label="XDAI balance" value={`${balance.dai.toSignificantDigits(4)} XDAI`} />
</Box>
<Box mb={2}>
<ExpandableListItem label="BZZ balance" value={`${balance.bzz.toSignificantDigits(4)} BZZ`} />
</Box>
{balance && nodeAddresses ? (
<>
<Box mb={0.25}>
<ExpandableListItemKey label="Node wallet address" value={nodeAddresses.ethereum} expanded />
</Box>
<Box mb={0.25}>
<ExpandableListItem label="XDAI balance" value={`${balance.dai.toSignificantDigits(4)} XDAI`} />
</Box>
<Box mb={2}>
<ExpandableListItem label="BZZ balance" value={`${balance.bzz.toSignificantDigits(4)} BZZ`} />
</Box>
</>
) : (
<Box mb={8}>
<Loading />
</Box>
)}
<ExpandableListItemActions>
<SwarmButton onClick={onCheckTransactions} iconType={Link}>
Check transactions on Blockscout
Expand Down

0 comments on commit f43de77

Please sign in to comment.