visual-identity/app/dapp.js

48 lines
1.1 KiB
JavaScript
Raw Normal View History

import React, { Fragment } from 'react';
2018-05-13 04:31:01 +00:00
import ReactDOM from 'react-dom';
import EmbarkJS from 'Embark/EmbarkJS';
import AdminView from './components/AdminView';
import Voting from './components/Voting';
import SNT from 'Embark/contracts/SNT';
window['SNT'] = SNT;
2018-05-13 04:31:01 +00:00
import './dapp.css';
class App extends React.Component {
constructor(props) {
super(props);
}
state = { admin: false };
2018-05-13 04:31:01 +00:00
2018-05-21 18:29:57 +00:00
componentDidMount(){
2018-05-13 04:31:01 +00:00
__embarkContext.execWhenReady(() => {
});
}
2018-05-22 13:49:22 +00:00
setAccount(_account){
this.setState({account: _account});
}
2018-05-13 04:31:01 +00:00
2018-05-17 19:53:23 +00:00
_renderStatus(title, available) {
2018-05-13 04:31:01 +00:00
let className = available ? 'pull-right status-online' : 'pull-right status-offline';
return <Fragment>
2018-05-21 18:29:57 +00:00
{title}
2018-05-13 04:31:01 +00:00
<span className={className}></span>
</Fragment>;
2018-05-13 04:31:01 +00:00
}
render(){
const { admin } = this.state;
const toggleAdmin = () => this.setState({ admin: true });
2018-05-17 19:53:23 +00:00
return (
<Fragment>
{admin ? <AdminView setAccount={this.setAccount} /> : <Voting toggleAdmin={toggleAdmin} />}
</Fragment>
);
2018-05-13 04:31:01 +00:00
}
}
ReactDOM.render(<App></App>, document.getElementById('app'));