1
- import React from "react" ;
1
+ import React , { useMemo } from "react" ;
2
2
import styled , { css } from "styled-components" ;
3
3
4
4
import Identicon from "react-identicons" ;
@@ -9,6 +9,7 @@ import { Card } from "@kleros/ui-components-library";
9
9
10
10
import AttachmentIcon from "svgs/icons/attachment.svg" ;
11
11
12
+ import { DEFAULT_CHAIN , getChain } from "consts/chains" ;
12
13
import { formatDate } from "utils/date" ;
13
14
import { getIpfsUrl } from "utils/getIpfsUrl" ;
14
15
import { shortenAddress } from "utils/shortenAddress" ;
@@ -116,6 +117,19 @@ const StyledLink = styled(Link)`
116
117
) }
117
118
` ;
118
119
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
+
119
133
const AttachedFileText : React . FC = ( ) => (
120
134
< >
121
135
< DesktopText > View attached file</ DesktopText >
@@ -128,7 +142,24 @@ interface IEvidenceCard extends Pick<Evidence, "evidence" | "timestamp" | "name"
128
142
index : number ;
129
143
}
130
144
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
+
132
163
return (
133
164
< StyledCard >
134
165
< TextContainer >
@@ -145,15 +176,19 @@ const EvidenceCard: React.FC<IEvidenceCard> = ({ evidence, sender, index, timest
145
176
< BottomShade >
146
177
< AccountContainer >
147
178
< 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 >
149
182
</ 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 !== "-" ? (
152
187
< StyledLink to = { `attachment/?url=${ getIpfsUrl ( fileURI ) } ` } >
153
188
< AttachmentIcon />
154
189
< AttachedFileText />
155
190
</ StyledLink >
156
- ) }
191
+ ) : null }
157
192
</ BottomShade >
158
193
</ StyledCard >
159
194
) ;
0 commit comments