import {Link} from "react-router-dom";
import Button from '@material-ui/core/Button';
import React, {Component, Fragment} from 'react';
import Typography from '@material-ui/core/Typography'
import PollManager from 'Embark/contracts/PollManager';
class Results extends Component {
state = {
isError: false,
poll: null,
isPending: true,
}
constructor(props){
super(props);
if(props.polls && props.polls.length)
this.state.poll = props.polls[props.idPoll];
}
updatePoll(){
const idPoll = this.props.idPoll;
PollManager.methods.poll(idPoll).call().then(poll => {
this.setState({poll});
})
}
componentDidMount(){
const {transaction, idPoll} = this.props;
EmbarkJS.onReady(() => {
this.updatePoll();
if(transaction){
transaction.then(receipt => {
this.setState({isPending: false});
this.updatePoll();
})
.catch(err => {
this.setState({isError: true});
});
}
});
}
render(){
const {polls, idPoll, transaction, transactionHash} = this.props;
let {isError, poll, isPending} = this.state;
if(!poll || !polls){
return null;
}
const title = polls[idPoll].content.title;
const ballots = polls[idPoll].content.ballots;
const totalVotes = poll._quadraticVotes.map(x => parseInt(x, 10)).reduce((x, y) => x + y, 0);
return
Your vote was posted.