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 >
@@ -128,7 +142,24 @@ interface IEvidenceCard extends Pick<Evidence, "evidence" | "timestamp" | "name"
128142 index : number ;
129143}
130144
131- const EvidenceCard : React . FC < IEvidenceCard > = ( { evidence, sender, index, timestamp, name, description, fileURI } ) => {
145+ const EvidenceCard : React . FC < IEvidenceCard > = ( {
146+ evidence,
147+ sender,
148+ index,
149+ timestamp,
150+ transactionHash,
151+ name,
152+ description,
153+ fileURI,
154+ } ) => {
155+ const addressExplorerLink = useMemo ( ( ) => {
156+ return `${ getChain ( DEFAULT_CHAIN ) ?. blockExplorers ?. default . url } /address/${ sender } ` ;
157+ } , [ sender ] ) ;
158+
159+ const transactionExplorerLink = useMemo ( ( ) => {
160+ return `${ getChain ( DEFAULT_CHAIN ) ?. blockExplorers ?. default . url } /tx/${ transactionHash } ` ;
161+ } , [ transactionHash ] ) ;
162+
132163 return (
133164 < StyledCard >
134165 < TextContainer >
@@ -145,15 +176,19 @@ const EvidenceCard: React.FC<IEvidenceCard> = ({ evidence, sender, index, timest
145176 < BottomShade >
146177 < AccountContainer >
147178 < Identicon size = "24" string = { sender } />
148- < p > { shortenAddress ( sender ) } </ p >
179+ < StyledA href = { addressExplorerLink } rel = "noreferrer" target = "_blank" >
180+ < p > { shortenAddress ( sender ) } </ p >
181+ </ StyledA >
149182 </ AccountContainer >
150- < Timestamp > { formatDate ( Number ( timestamp ) , true ) } </ Timestamp >
151- { fileURI && (
183+ < StyledA href = { transactionExplorerLink } rel = "noreferrer" target = "_blank" >
184+ < Timestamp > { formatDate ( Number ( timestamp ) , true ) } </ Timestamp >
185+ </ StyledA >
186+ { fileURI && fileURI !== "-" ? (
152187 < StyledLink to = { `attachment/?url=${ getIpfsUrl ( fileURI ) } ` } >
153188 < AttachmentIcon />
154189 < AttachedFileText />
155190 </ StyledLink >
156- ) }
191+ ) : null }
157192 </ BottomShade >
158193 </ StyledCard >
159194 ) ;
0 commit comments