refactor: removing duplicate AccountDetails code (#4329)

fixed redundant code
This commit is contained in:
cartcrom 2022-08-11 14:03:46 -04:00 committed by GitHub
parent fe55c7ae7a
commit acdca350a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -129,7 +129,7 @@ const AccountControl = styled.div`
}
`
const AddressLink = styled(ExternalLink)<{ hasENS: boolean; isENS: boolean }>`
const AddressLink = styled(ExternalLink)`
font-size: 0.825rem;
color: ${({ theme }) => theme.deprecated_text3};
margin-left: 1rem;
@ -281,59 +281,21 @@ export default function AccountDetails({
</AccountControl>
</AccountGroupingRow>
<AccountGroupingRow>
{ENSName ? (
<>
<AccountControl>
<div>
{account && (
<CopyHelper toCopy={account} iconPosition="left">
<span style={{ marginLeft: '4px' }}>
<Trans>Copy Address</Trans>
</span>
</CopyHelper>
)}
{chainId && account && (
<AddressLink
hasENS={!!ENSName}
isENS={true}
href={getExplorerLink(chainId, ENSName, ExplorerDataType.ADDRESS)}
>
<LinkIcon size={16} />
<span style={{ marginLeft: '4px' }}>
<Trans>View on Explorer</Trans>
</span>
</AddressLink>
)}
</div>
</AccountControl>
</>
) : (
<>
<AccountControl>
<div>
{account && (
<CopyHelper toCopy={account} iconPosition="left">
<span style={{ marginLeft: '4px' }}>
<Trans>Copy Address</Trans>
</span>
</CopyHelper>
)}
{chainId && account && (
<AddressLink
hasENS={!!ENSName}
isENS={false}
href={getExplorerLink(chainId, account, ExplorerDataType.ADDRESS)}
>
<LinkIcon size={16} />
<span style={{ marginLeft: '4px' }}>
<Trans>View on Explorer</Trans>
</span>
</AddressLink>
)}
</div>
</AccountControl>
</>
)}
<AccountControl>
<div>
{account && (
<CopyHelper toCopy={account} iconPosition="left">
<Trans>Copy Address</Trans>
</CopyHelper>
)}
{chainId && account && (
<AddressLink href={getExplorerLink(chainId, ENSName ?? account, ExplorerDataType.ADDRESS)}>
<LinkIcon size={16} />
<Trans>View on Explorer</Trans>
</AddressLink>
)}
</div>
</AccountControl>
</AccountGroupingRow>
</InfoCard>
</YourAccount>