|
1 | | -import React from "react"; |
| 1 | +import React, { useMemo } from "react"; |
2 | 2 | import styled from "styled-components"; |
3 | 3 |
|
| 4 | +import { useAccount } from "wagmi"; |
| 5 | + |
| 6 | +import { DEFAULT_CHAIN, getChain } from "consts/chains"; |
| 7 | + |
4 | 8 | import ArrowIcon from "svgs/icons/arrow.svg"; |
| 9 | +import NewTabIcon from "svgs/icons/new-tab.svg"; |
5 | 10 |
|
6 | 11 | import { IdenticonOrAvatar, AddressOrName } from "components/ConnectWallet/AccountDisplay"; |
7 | 12 | import { StyledArrowLink } from "components/StyledArrowLink"; |
8 | | -import { useAccount } from "wagmi"; |
9 | 13 |
|
10 | 14 | const Container = styled.div` |
11 | 15 | display: flex; |
@@ -36,26 +40,34 @@ export const ReStyledArrowLink = styled(StyledArrowLink)` |
36 | 40 | } |
37 | 41 | `; |
38 | 42 |
|
39 | | -interface IJurorTitle { |
| 43 | +interface IJurorLink { |
40 | 44 | address: string; |
| 45 | + isInternalLink?: boolean; |
41 | 46 | } |
42 | 47 |
|
43 | | -const JurorTitle: React.FC<IJurorTitle> = ({ address }) => { |
| 48 | +const JurorLink: React.FC<IJurorLink> = ({ address, isInternalLink = true }) => { |
44 | 49 | const { isConnected, address: connectedAddress } = useAccount(); |
45 | 50 | const profileLink = |
46 | 51 | isConnected && connectedAddress?.toLowerCase() === address.toLowerCase() |
47 | 52 | ? "/profile/1/desc/all" |
48 | 53 | : `/profile/1/desc/all?address=${address}`; |
| 54 | + const addressExplorerLink = useMemo(() => { |
| 55 | + return `${getChain(DEFAULT_CHAIN)?.blockExplorers?.default.url}/address/${address}`; |
| 56 | + }, [address]); |
49 | 57 |
|
50 | 58 | return ( |
51 | 59 | <Container> |
52 | 60 | <IdenticonOrAvatar address={address} /> |
53 | | - <ReStyledArrowLink to={profileLink}> |
| 61 | + <ReStyledArrowLink |
| 62 | + to={isInternalLink ? profileLink : addressExplorerLink} |
| 63 | + rel={`${isInternalLink ? "" : "noopener noreferrer"}`} |
| 64 | + target={`${isInternalLink ? "" : "_blank"}`} |
| 65 | + > |
54 | 66 | <AddressOrName address={address} /> |
55 | | - <ArrowIcon /> |
| 67 | + {isInternalLink ? <ArrowIcon /> : <NewTabIcon />} |
56 | 68 | </ReStyledArrowLink> |
57 | 69 | </Container> |
58 | 70 | ); |
59 | 71 | }; |
60 | 72 |
|
61 | | -export default JurorTitle; |
| 73 | +export default JurorLink; |
0 commit comments