Skip to content

Commit

Permalink
fix null balance and result num
Browse files Browse the repository at this point in the history
  • Loading branch information
tom2drum committed Sep 10, 2024
1 parent b60bf30 commit 30e2b1c
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion types/api/addresses.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { AddressParam } from './addressParams';

export type AddressesItem = AddressParam &{ tx_count: string; coin_balance: string }
export type AddressesItem = AddressParam & { tx_count: string; coin_balance: string | null }

export type AddressesResponse = {
items: Array<AddressesItem>;
Expand Down
2 changes: 1 addition & 1 deletion ui/addresses/AddressesListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const AddressesListItem = ({
isLoading,
}: Props) => {

const addressBalance = BigNumber(item.coin_balance).div(BigNumber(10 ** config.chain.currency.decimals));
const addressBalance = BigNumber(item.coin_balance || 0).div(BigNumber(10 ** config.chain.currency.decimals));

return (
<ListItemMobile rowGap={ 3 }>
Expand Down
2 changes: 1 addition & 1 deletion ui/addresses/AddressesTableItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const AddressesTableItem = ({
isLoading,
}: Props) => {

const addressBalance = BigNumber(item.coin_balance).div(BigNumber(10 ** config.chain.currency.decimals));
const addressBalance = BigNumber(item.coin_balance || 0).div(BigNumber(10 ** config.chain.currency.decimals));
const addressBalanceChunks = addressBalance.dp(8).toFormat().split('.');

return (
Expand Down
2 changes: 1 addition & 1 deletion ui/addressesLabelSearch/AddressesLabelSearchListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const AddressesLabelSearchListItem = ({
isLoading,
}: Props) => {

const addressBalance = BigNumber(item.coin_balance).div(BigNumber(10 ** config.chain.currency.decimals));
const addressBalance = BigNumber(item.coin_balance || 0).div(BigNumber(10 ** config.chain.currency.decimals));

return (
<ListItemMobile rowGap={ 3 }>
Expand Down
2 changes: 1 addition & 1 deletion ui/addressesLabelSearch/AddressesLabelSearchTableItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const AddressesLabelSearchTableItem = ({
isLoading,
}: Props) => {

const addressBalance = BigNumber(item.coin_balance).div(BigNumber(10 ** config.chain.currency.decimals));
const addressBalance = BigNumber(item.coin_balance || 0).div(BigNumber(10 ** config.chain.currency.decimals));
const addressBalanceChunks = addressBalance.dp(8).toFormat().split('.');

return (
Expand Down
2 changes: 1 addition & 1 deletion ui/pages/AccountsLabelSearch.pw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const addresses: AddressesMetadataSearchResult = {
{
...addressMocks.eoa,
tx_count: '420',
coin_balance: '123456',
coin_balance: null,
},
],
next_page_params: null,
Expand Down
8 changes: 6 additions & 2 deletions ui/pages/AccountsLabelSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const AccountsLabelSearch = () => {
options: {
placeholderData: generateListStub<'addresses_metadata_search'>(
TOP_ADDRESS,
5,
50,
{
next_page_params: null,
},
Expand Down Expand Up @@ -83,7 +83,11 @@ const AccountsLabelSearch = () => {
isLoaded={ !isPlaceholderData }
display="inline-block"
>
Found <chakra.span fontWeight={ 700 }>{ num }</chakra.span> matching result{ num > 1 ? 's' : '' } for
Found{ ' ' }
<chakra.span fontWeight={ 700 }>
{ num }{ data?.next_page_params || pagination.page > 1 ? '+' : '' }
</chakra.span>{ ' ' }
matching result{ num > 1 ? 's' : '' } for
</Skeleton>
<EntityTag data={ tagData } isLoading={ isPlaceholderData } noLink/>
</Flex>
Expand Down

0 comments on commit 30e2b1c

Please sign in to comment.