Commit 73f78457 authored by tom's avatar tom

handle empty token info response

parent 56409552
...@@ -249,7 +249,7 @@ const TokenPageContent = () => { ...@@ -249,7 +249,7 @@ const TokenPageContent = () => {
) } ) }
additionalsRight={ tagsNode } additionalsRight={ tagsNode }
afterTitle={ afterTitle={
verifiedInfoQuery.data ? verifiedInfoQuery.data?.tokenAddress ?
<Icon as={ iconSuccess } color="green.500" boxSize={ 4 } verticalAlign="top"/> : <Icon as={ iconSuccess } color="green.500" boxSize={ 4 } verticalAlign="top"/> :
<Box boxSize={ 4 } display="inline-block"/> <Box boxSize={ 4 } display="inline-block"/>
} }
......
...@@ -3,6 +3,8 @@ import { useQueryClient } from '@tanstack/react-query'; ...@@ -3,6 +3,8 @@ import { useQueryClient } from '@tanstack/react-query';
import { useRouter } from 'next/router'; import { useRouter } from 'next/router';
import React from 'react'; import React from 'react';
import type { TokenVerifiedInfo } from 'types/api/token';
import appConfig from 'configs/app/config'; import appConfig from 'configs/app/config';
import iconEdit from 'icons/edit.svg'; import iconEdit from 'icons/edit.svg';
import useApiQuery, { getResourceKey } from 'lib/api/useApiQuery'; import useApiQuery, { getResourceKey } from 'lib/api/useApiQuery';
...@@ -50,13 +52,18 @@ const TokenInfoMenuItem = ({ className, hash }: Props) => { ...@@ -50,13 +52,18 @@ const TokenInfoMenuItem = ({ className, hash }: Props) => {
const icon = <Icon as={ iconEdit } boxSize={ 6 } mr={ 2 } p={ 1 }/>; const icon = <Icon as={ iconEdit } boxSize={ 6 } mr={ 2 } p={ 1 }/>;
const content = (() => { const content = (() => {
const verifiedTokenInfo = queryClient.getQueryData(getResourceKey('token_verified_info', { pathParams: { hash, chainId: appConfig.network.id } })); const verifiedTokenInfo = queryClient.getQueryData<TokenVerifiedInfo>(
getResourceKey(
'token_verified_info',
{ pathParams: { hash, chainId: appConfig.network.id } },
),
);
if (!verifiedAddressesQuery.data?.verifiedAddresses.find(({ contractAddress }) => contractAddress.toLowerCase() === hash.toLowerCase())) { if (!verifiedAddressesQuery.data?.verifiedAddresses.find(({ contractAddress }) => contractAddress.toLowerCase() === hash.toLowerCase())) {
return ( return (
<MenuItem className={ className } onClick={ handleAddAddressClick }> <MenuItem className={ className } onClick={ handleAddAddressClick }>
{ icon } { icon }
<span>{ verifiedTokenInfo ? 'Update token info' : 'Add token info' }</span> <span>{ verifiedTokenInfo?.tokenAddress ? 'Update token info' : 'Add token info' }</span>
</MenuItem> </MenuItem>
); );
} }
...@@ -68,7 +75,7 @@ const TokenInfoMenuItem = ({ className, hash }: Props) => { ...@@ -68,7 +75,7 @@ const TokenInfoMenuItem = ({ className, hash }: Props) => {
{ icon } { icon }
<span> <span>
{ {
hasApplication || verifiedTokenInfo ? hasApplication || verifiedTokenInfo?.tokenAddress ?
'Update token info' : 'Update token info' :
'Add token info' 'Add token info'
} }
......
...@@ -55,7 +55,7 @@ const TokenVerifiedInfo = ({ verifiedInfoQuery, isVerifiedInfoEnabled, hash }: P ...@@ -55,7 +55,7 @@ const TokenVerifiedInfo = ({ verifiedInfoQuery, isVerifiedInfoEnabled, hash }: P
return ( return (
<> <>
{ websiteLink } { websiteLink }
{ Boolean(data) && <TokenProjectInfo data={ data }/> } { Boolean(data.tokenAddress) && <TokenProjectInfo data={ data }/> }
{ explorers } { explorers }
</> </>
); );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment