diff --git a/app/components/flow/Results.js b/app/components/flow/Results.js index fa659f9..f6ae662 100644 --- a/app/components/flow/Results.js +++ b/app/components/flow/Results.js @@ -2,36 +2,56 @@ import {Link} from "react-router-dom"; import Button from '@material-ui/core/Button'; import React, {Component} from 'react'; import Typography from '@material-ui/core/Typography' +import PollManager from 'Embark/contracts/PollManager'; class Results extends Component { state = { - isError: false + isError: false, + poll: null + } + + constructor(props){ + super(props); + + if(props.polls && props.polls.length) + this.state.poll = props.polls[0]; // TODO: + } + + updatePoll(){ + const idPoll = 0; // TODO: + PollManager.methods.poll(idPoll).call().then(poll => { + this.setState({poll}); + }) } componentDidMount(){ const {transaction} = this.props; - transaction.then(receipt => { + const idPoll = 0; // TODO: + this.updatePoll(); + + transaction.then(receipt => { + this.updatePoll(); }) .catch(err => { this.setState({isError: true}); - }) - - + }); } render(){ const {polls} = this.props; - const {isError} = this.state; + const {isError, poll} = this.state; - if(!polls || !polls.length){ + const title = polls[0].content.title; + const ballots = polls[0].content.ballots; + + if(!poll){ return null; } return
- { isError &&
Transaction failed Copy with apologies and invitation to try again @@ -40,9 +60,20 @@ class Results extends Component {
} { !isError &&
-

Transaction details here

-

Voting results here

-
} +

TODO: Transaction details here

+ + { title } + { ballots.map((item, i) => { + return
+

{item.title}

+

Voters: ???

+

Total votes: {poll._quadraticVotes[i]}

+

Total SNT: {web3.utils.fromWei(poll._tokenTotal[i], "ether")}

+ +
+ })} + +
} ; } }