11import React , { Component } from 'react' ;
2- import { Card , Grid } from 'semantic-ui-react' ;
2+ import { Button , Card , Grid } from 'semantic-ui-react' ;
33import { bindActionCreators } from 'redux' ;
44import { connect } from 'react-redux' ;
55import { convertCurrencies } from '../../actions' ;
6- import { fetchScaffoldItem } from "../../actions/index" ;
6+ import { deactivateScaffold , fetchScaffoldItem } from "../../actions/index" ;
77
88class ScaffoldSummary extends Component {
99
@@ -12,46 +12,54 @@ class ScaffoldSummary extends Component {
1212 this . props . actions . fetchScaffoldItem ( scaffoldAddress ) ;
1313 }
1414
15+ renderStatus ( ) {
16+ const { onchainScaffoldSummary} = this . props ;
17+ const scaffoldAddress = this . props . match . params . scaffoldAddress ;
18+ const status = onchainScaffoldSummary . enabled ;
19+ const activateMessage = (
20+ < div style = { { color : 'red' } } >
21+ Your scaffold is created but is inactive. To activate your scaffold you need to transfer 10 OPEN Tokens to it.
22+ </ div >
23+ ) ;
24+ const deactivateButton = < Button onClick = { ( ) => this . props . actions . deactivateScaffold ( scaffoldAddress ) } > Deactivate</ Button >
25+
26+ return (
27+ < div >
28+ Status: { status ? 'Active' : 'Disabled' }
29+ < div style = { { marginTop : '10px' } } >
30+ { status ? deactivateButton : activateMessage }
31+ </ div >
32+ </ div >
33+ )
34+ }
35+
1536 render ( ) {
1637 const { onchainScaffoldSummary} = this . props ;
1738
1839 return (
1940 < div style = { { marginTop : '20px' } } >
20- { /*<div style={{marginBottom: '20px'}}>Your scaffold is created but is inactive. To activate your scaffold you need to transfer 10 open tokens to it.</div>*/ }
2141 < Grid >
2242 < Grid . Row >
2343 < Grid . Column width = { 16 } >
2444 < Card fluid >
25- < Card . Content
26- header = "On-chain Scaffold Summary"
27- meta = "This data is coming from the Ethereum Network"
28- />
45+ < Card . Content header = "On-chain Scaffold Summary" meta = "This data is coming from the Ethereum Network" />
2946 < Card . Content >
30- < div >
31- Scaffold Description:{ ' ' }
32- { onchainScaffoldSummary . description }
33- </ div >
34- < div >
35- Scaffold Owner Address:{ ' ' }
36- { onchainScaffoldSummary . vendorAddress }
37- </ div >
47+ { this . renderStatus ( ) }
48+ </ Card . Content >
49+ < Card . Content >
50+ < div > Scaffold Description: { onchainScaffoldSummary . description } </ div >
51+ < div > Scaffold Owner Address: { onchainScaffoldSummary . vendorAddress } </ div >
3852 </ Card . Content >
3953 < Card . Content >
4054 < div >
4155 < div style = { { width : '64%' , display : 'inline-block' } } >
42- Scaffold Amount:{ ' ' }
43- { ( Number . parseFloat ( onchainScaffoldSummary . amount ) ) . toFixed ( 5 ) } ether
56+ Scaffold Amount: { ( Number . parseFloat ( onchainScaffoldSummary . amount ) ) . toFixed ( 5 ) } ether
4457 </ div >
4558 < div style = { { width : '34%' , display : 'inline-block' } } >
46- { onchainScaffoldSummary . fiatAmount }
47- { ' ' }
48- { onchainScaffoldSummary . fiatCurrency }
59+ { onchainScaffoldSummary . fiatAmount } { onchainScaffoldSummary . fiatCurrency }
4960 </ div >
5061 </ div >
51- < div >
52- Scaffold Transactions:{ ' ' }
53- { onchainScaffoldSummary . transactionIndex }
54- </ div >
62+ < div > Scaffold Transactions: { onchainScaffoldSummary . transactionIndex } </ div >
5563 </ Card . Content >
5664 </ Card >
5765 </ Grid . Column >
@@ -65,13 +73,11 @@ class ScaffoldSummary extends Component {
6573 }
6674}
6775
68- const mapStateToProps = ( { auth, onchainScaffoldSummary, currencyConversionValue} ) => {
69- return { auth, onchainScaffoldSummary, currencyConversionValue} ;
70- } ;
76+ const mapStateToProps = ( { auth, onchainScaffoldSummary, currencyConversionValue} ) =>
77+ ( { auth, onchainScaffoldSummary, currencyConversionValue} ) ;
7178
72- const mapDispatchToProps = dispatch => ( {
73- actions : bindActionCreators ( { convertCurrencies, fetchScaffoldItem} , dispatch ) ,
74- } ) ;
79+ const mapDispatchToProps = dispatch =>
80+ ( { actions : bindActionCreators ( { convertCurrencies, fetchScaffoldItem, deactivateScaffold} , dispatch ) } ) ;
7581
7682ScaffoldSummary = connect ( mapStateToProps , mapDispatchToProps ) ( ScaffoldSummary ) ;
7783
0 commit comments