Commit 5a2f81c4 authored by eddie's avatar eddie Committed by GitHub

fix: show error message when token is not found (#6057)

* fix: show error message when token is not found

* fix: make onContinue optional
parent c34742c2
...@@ -4,7 +4,7 @@ import { ButtonPrimary } from 'components/Button' ...@@ -4,7 +4,7 @@ import { ButtonPrimary } from 'components/Button'
import { AutoColumn } from 'components/Column' import { AutoColumn } from 'components/Column'
import CurrencyLogo from 'components/Logo/CurrencyLogo' import CurrencyLogo from 'components/Logo/CurrencyLogo'
import TokenSafetyLabel from 'components/TokenSafety/TokenSafetyLabel' import TokenSafetyLabel from 'components/TokenSafety/TokenSafetyLabel'
import { checkWarning, getWarningCopy, TOKEN_SAFETY_ARTICLE, Warning } from 'constants/tokenSafety' import { checkWarning, getWarningCopy, TOKEN_SAFETY_ARTICLE, Warning, WARNING_LEVEL } from 'constants/tokenSafety'
import { useToken } from 'hooks/Tokens' import { useToken } from 'hooks/Tokens'
import { ExternalLink as LinkIconFeather } from 'react-feather' import { ExternalLink as LinkIconFeather } from 'react-feather'
import { Text } from 'rebass' import { Text } from 'rebass'
...@@ -77,7 +77,7 @@ const Buttons = ({ ...@@ -77,7 +77,7 @@ const Buttons = ({
showCancel, showCancel,
}: { }: {
warning: Warning warning: Warning
onContinue: () => void onContinue?: () => void
onCancel: () => void onCancel: () => void
onBlocked?: () => void onBlocked?: () => void
showCancel?: boolean showCancel?: boolean
...@@ -251,32 +251,49 @@ export default function TokenSafety({ ...@@ -251,32 +251,49 @@ export default function TokenSafety({
<Trans>Learn more</Trans> <Trans>Learn more</Trans>
</StyledExternalLink> </StyledExternalLink>
) )
const tokenNotFoundWarning = {
level: WARNING_LEVEL.UNKNOWN,
message: <Trans>Token not found</Trans>,
canProceed: false,
}
return ( return displayWarning ? (
displayWarning && ( <Wrapper>
<Wrapper> <Container>
<Container> <AutoColumn>
<AutoColumn> <LogoContainer>{logos}</LogoContainer>
<LogoContainer>{logos}</LogoContainer> </AutoColumn>
</AutoColumn> <ShortColumn>
<ShortColumn> <SafetyLabel warning={displayWarning} />
<SafetyLabel warning={displayWarning} /> </ShortColumn>
</ShortColumn> <ShortColumn>
<ShortColumn> <InfoText>
<InfoText> {heading} {description} {learnMoreUrl}
{heading} {description} {learnMoreUrl} </InfoText>
</InfoText> </ShortColumn>
</ShortColumn> <LinkColumn>{urls}</LinkColumn>
<LinkColumn>{urls}</LinkColumn> <Buttons
<Buttons warning={displayWarning}
warning={displayWarning} onContinue={acknowledge}
onContinue={acknowledge} onCancel={onCancel}
onCancel={onCancel} onBlocked={onBlocked}
onBlocked={onBlocked} showCancel={showCancel}
showCancel={showCancel} />
/> </Container>
</Container> </Wrapper>
</Wrapper> ) : (
) <Wrapper>
<Container>
<ShortColumn>
<SafetyLabel warning={tokenNotFoundWarning} />
</ShortColumn>
<ShortColumn>
<InfoText>
{heading} {description} {learnMoreUrl}
</InfoText>
</ShortColumn>
<Buttons warning={tokenNotFoundWarning} onCancel={onCancel} showCancel={true} />
</Container>
</Wrapper>
) )
} }
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