Merge branch '000-snt-voting-dapp' of https://github.com/status-im/contracts into 000-snt-voting-dapp
This commit is contained in:
commit
09d85cb00c
19
app/dapp.js
19
app/dapp.js
|
@ -1,7 +1,7 @@
|
|||
import React, { Fragment } from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
|
||||
import EmbarkJS from 'Embark/EmbarkJS';
|
||||
import PollManager from 'Embark/contracts/PollManager';
|
||||
import AdminView from './components/AdminView';
|
||||
import Voting from './components/Voting';
|
||||
import SNT from 'Embark/contracts/SNT';
|
||||
|
@ -9,6 +9,15 @@ window['SNT'] = SNT;
|
|||
|
||||
import './dapp.css';
|
||||
|
||||
const getPolls = (number, pollMethod) => {
|
||||
const polls = [];
|
||||
for (let i = number-1; i >= 0; i--) {
|
||||
const poll = pollMethod(i).call();
|
||||
polls.push(poll);
|
||||
}
|
||||
return Promise.all(polls);
|
||||
}
|
||||
|
||||
class App extends React.Component {
|
||||
|
||||
constructor(props) {
|
||||
|
@ -18,6 +27,7 @@ class App extends React.Component {
|
|||
|
||||
componentDidMount(){
|
||||
__embarkContext.execWhenReady(() => {
|
||||
this._getPolls();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -25,6 +35,13 @@ class App extends React.Component {
|
|||
this.setState({account: _account});
|
||||
}
|
||||
|
||||
async _getPolls(){
|
||||
const { nPolls, poll } = PollManager.methods;
|
||||
const polls = await nPolls.call();
|
||||
const total = await polls.call();
|
||||
getPolls(total, poll).then(rawPolls => { this.setState({ rawPolls })});
|
||||
}
|
||||
|
||||
_renderStatus(title, available) {
|
||||
let className = available ? 'pull-right status-online' : 'pull-right status-offline';
|
||||
return <Fragment>
|
||||
|
|
Loading…
Reference in New Issue