@@ -10,18 +10,22 @@ import ProtocolParameters from "../ProtocolParameters";
10
10
import SignerTable from "../SignerTable" ;
11
11
import VerifyCertificateModal from "../VerifyCertificate/VerifyCertificateModal" ;
12
12
13
- export default function CertificateModal ( props ) {
13
+ export default function CertificateModal ( {
14
+ hash,
15
+ hideButtons = false ,
16
+ onHashChange = ( hash ) => { } ,
17
+ } ) {
14
18
const [ certificate , setCertificate ] = useState ( { } ) ;
15
19
const [ charts , setCharts ] = useState ( {
16
20
stakesBreakdown : { } ,
17
21
} ) ;
18
22
const [ showVerifyCertificateModal , setShowVerifyCertificateModal ] = useState ( false ) ;
19
23
const certificateEndpoint = useSelector (
20
- ( state ) => `${ selectedAggregator ( state ) } /certificate/${ props . hash } ` ,
24
+ ( state ) => `${ selectedAggregator ( state ) } /certificate/${ hash } ` ,
21
25
) ;
22
26
23
27
useEffect ( ( ) => {
24
- if ( ! props . hash ) {
28
+ if ( ! hash ) {
25
29
return ;
26
30
}
27
31
@@ -37,19 +41,19 @@ export default function CertificateModal(props) {
37
41
setCertificate ( { } ) ;
38
42
console . error ( "Fetch certificate error:" , error ) ;
39
43
} ) ;
40
- } , [ certificateEndpoint , props . hash ] ) ;
44
+ } , [ certificateEndpoint , hash ] ) ;
41
45
42
46
function showPrevious ( ) {
43
- props . onHashChange ( certificate . previous_hash ) ;
47
+ onHashChange ( certificate . previous_hash ) ;
44
48
}
45
49
46
50
function close ( ) {
47
- props . onHashChange ( undefined ) ;
51
+ onHashChange ( undefined ) ;
48
52
}
49
53
50
54
return (
51
55
< Modal
52
- show = { props . hash !== undefined }
56
+ show = { hash !== undefined }
53
57
onHide = { close }
54
58
size = "xl"
55
59
aria-labelledby = "contained-modal-title-vcenter"
@@ -161,28 +165,32 @@ export default function CertificateModal(props) {
161
165
) }
162
166
</ Modal . Body >
163
167
< Modal . Footer >
164
- < Button
165
- size = "sm"
166
- onClick = { ( ) => setShowVerifyCertificateModal ( true ) }
167
- className = "text-break" >
168
- Verify certificate
169
- </ Button >
168
+ { ! hideButtons && (
169
+ < Button
170
+ size = "sm"
171
+ onClick = { ( ) => setShowVerifyCertificateModal ( true ) }
172
+ className = "text-break" >
173
+ Verify certificate
174
+ </ Button >
175
+ ) }
170
176
{ certificate . genesis_signature !== "" ? (
171
177
< Badge bg = "warning" > Genesis</ Badge >
172
178
) : (
173
- < >
179
+ ! hideButtons && (
174
180
< Button size = "sm" onClick = { showPrevious } className = "text-break" >
175
181
Previous hash: { certificate . previous_hash }
176
182
</ Button >
177
- </ >
183
+ )
178
184
) }
179
185
< RawJsonButton href = { certificateEndpoint } size = "sm" />
180
186
</ Modal . Footer >
181
- < VerifyCertificateModal
182
- show = { showVerifyCertificateModal }
183
- onClose = { ( ) => setShowVerifyCertificateModal ( false ) }
184
- certificateHash = { certificate . hash }
185
- />
187
+ { ! hideButtons && (
188
+ < VerifyCertificateModal
189
+ show = { showVerifyCertificateModal }
190
+ onClose = { ( ) => setShowVerifyCertificateModal ( false ) }
191
+ certificateHash = { certificate . hash }
192
+ />
193
+ ) }
186
194
</ Modal >
187
195
) ;
188
196
}
0 commit comments