diff --git a/app/components/simple-voting/PollsList.js b/app/components/simple-voting/PollsList.js
index c2b0958..52f63fd 100644
--- a/app/components/simple-voting/PollsList.js
+++ b/app/components/simple-voting/PollsList.js
@@ -20,7 +20,7 @@ const Poll = ({ _question, _totalCensus, _voters }) => (
const PollsList = ({ rawPolls }) => (
- {rawPolls.map(poll => )}
+ {rawPolls.map((poll, idx) => )}
)
diff --git a/app/dapp.js b/app/dapp.js
index 39e275f..4d9c603 100644
--- a/app/dapp.js
+++ b/app/dapp.js
@@ -2,6 +2,7 @@ import React, { Fragment } from 'react';
import ReactDOM from 'react-dom';
import EmbarkJS from 'Embark/EmbarkJS';
import PollManager from 'Embark/contracts/PollManager';
+import SingleChoice from 'Embark/contracts/SingleChoice';
import AdminView from './components/AdminView';
import Voting from './components/Voting';
import SNT from 'Embark/contracts/SNT';
@@ -15,7 +16,7 @@ const getPolls = (number, pollMethod) => {
const poll = pollMethod(i).call();
polls.push(poll);
}
- return Promise.all(polls);
+ return Promise.all(polls.reverse());
}
class App extends React.Component {
@@ -28,6 +29,7 @@ class App extends React.Component {
componentDidMount(){
__embarkContext.execWhenReady(() => {
this._getPolls();
+ this._setVotingOptions();
});
}
@@ -39,9 +41,18 @@ class App extends React.Component {
const { nPolls, poll } = PollManager.methods;
const polls = await nPolls.call();
const total = await polls.call();
+ if (total) this._setVotingOptions();
getPolls(total, poll).then(rawPolls => { this.setState({ rawPolls })});
}
+ async _setVotingOptions(){
+ const poll = await PollManager.methods.poll(0).call();
+ SingleChoice.options.address = poll._pollContract;
+ const yes = await SingleChoice.methods.getBallot(0).call();
+ const no = await SingleChoice.methods.getBallot(1).call();
+ this.setState({ votingOptions: { yes, no } })
+ }
+
_renderStatus(title, available) {
let className = available ? 'pull-right status-online' : 'pull-right status-offline';
return