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 >
@@ -126,9 +140,27 @@ const AttachedFileText: React.FC = () => (
126
140
interface IEvidenceCard extends Pick < Evidence , "evidence" | "timestamp" | "name" | "description" | "fileURI" > {
127
141
sender : string ;
128
142
index : number ;
143
+ transactionHash : string ;
129
144
}
130
145
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
+
132
164
return (
133
165
< StyledCard >
134
166
< TextContainer >
@@ -145,15 +177,19 @@ const EvidenceCard: React.FC<IEvidenceCard> = ({ evidence, sender, index, timest
145
177
< BottomShade >
146
178
< AccountContainer >
147
179
< 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 >
149
183
</ 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 !== "-" ? (
152
188
< StyledLink to = { `attachment/?url=${ getIpfsUrl ( fileURI ) } ` } >
153
189
< AttachmentIcon />
154
190
< AttachedFileText />
155
191
</ StyledLink >
156
- ) }
192
+ ) : null }
157
193
</ BottomShade >
158
194
</ StyledCard >
159
195
) ;
0 commit comments