1- import React from "react" ;
1+ import React , { useMemo } from "react" ;
22import styled , { css } from "styled-components" ;
33
44import Identicon from "react-identicons" ;
@@ -9,6 +9,7 @@ import { Card } from "@kleros/ui-components-library";
99
1010import AttachmentIcon from "svgs/icons/attachment.svg" ;
1111
12+ import { DEFAULT_CHAIN , getChain } from "consts/chains" ;
1213import { formatDate } from "utils/date" ;
1314import { getIpfsUrl } from "utils/getIpfsUrl" ;
1415import { shortenAddress } from "utils/shortenAddress" ;
@@ -116,6 +117,19 @@ const StyledLink = styled(Link)`
116117 ) }
117118` ;
118119
120+ const StyledA = styled . a `
121+ :hover {
122+ text-decoration: underline;
123+ p {
124+ color: ${ ( { theme } ) => theme . primaryBlue } ;
125+ }
126+ label {
127+ cursor: pointer;
128+ color: ${ ( { theme } ) => theme . primaryBlue } ;
129+ }
130+ }
131+ ` ;
132+
119133const AttachedFileText : React . FC = ( ) => (
120134 < >
121135 < DesktopText > View attached file</ DesktopText >
@@ -126,9 +140,27 @@ const AttachedFileText: React.FC = () => (
126140interface IEvidenceCard extends Pick < Evidence , "evidence" | "timestamp" | "name" | "description" | "fileURI" > {
127141 sender : string ;
128142 index : number ;
143+ transactionHash : string ;
129144}
130145
131- const EvidenceCard : React . FC < IEvidenceCard > = ( { evidence, sender, index, timestamp, name, description, fileURI } ) => {
146+ const EvidenceCard : React . FC < IEvidenceCard > = ( {
147+ evidence,
148+ sender,
149+ index,
150+ timestamp,
151+ transactionHash,
152+ name,
153+ description,
154+ fileURI,
155+ } ) => {
156+ const addressExplorerLink = useMemo ( ( ) => {
157+ return `${ getChain ( DEFAULT_CHAIN ) ?. blockExplorers ?. default . url } /address/${ sender } ` ;
158+ } , [ sender ] ) ;
159+
160+ const transactionExplorerLink = useMemo ( ( ) => {
161+ return `${ getChain ( DEFAULT_CHAIN ) ?. blockExplorers ?. default . url } /tx/${ transactionHash } ` ;
162+ } , [ transactionHash ] ) ;
163+
132164 return (
133165 < StyledCard >
134166 < TextContainer >
@@ -145,15 +177,19 @@ const EvidenceCard: React.FC<IEvidenceCard> = ({ evidence, sender, index, timest
145177 < BottomShade >
146178 < AccountContainer >
147179 < Identicon size = "24" string = { sender } />
148- < p > { shortenAddress ( sender ) } </ p >
180+ < StyledA href = { addressExplorerLink } rel = "noopener noreferrer" target = "_blank" >
181+ < p > { shortenAddress ( sender ) } </ p >
182+ </ StyledA >
149183 </ AccountContainer >
150- < Timestamp > { formatDate ( Number ( timestamp ) , true ) } </ Timestamp >
151- { fileURI && (
184+ < StyledA href = { transactionExplorerLink } rel = "noopener noreferrer" target = "_blank" >
185+ < Timestamp > { formatDate ( Number ( timestamp ) , true ) } </ Timestamp >
186+ </ StyledA >
187+ { fileURI && fileURI !== "-" ? (
152188 < StyledLink to = { `attachment/?url=${ getIpfsUrl ( fileURI ) } ` } >
153189 < AttachmentIcon />
154190 < AttachedFileText />
155191 </ StyledLink >
156- ) }
192+ ) : null }
157193 </ BottomShade >
158194 </ StyledCard >
159195 ) ;
0 commit comments