diff --git a/src/actions/proposals.js b/src/actions/proposals.js index 947e36a..9ca2d02 100644 --- a/src/actions/proposals.js +++ b/src/actions/proposals.js @@ -200,7 +200,7 @@ export const fetchProposalTally = (id) => (dispatch) => { }, }) .then((res) => { - dispatch(fetchProposalTallySuccess(res.data && res.data.result, id)); + dispatch(fetchProposalTallySuccess(res.data && res.data.tally, id)); }) .catch((error) => { dispatch(fetchProposalTallyError( diff --git a/src/containers/NavBar/index.js b/src/containers/NavBar/index.js index e35391b..8b5f1f9 100644 --- a/src/containers/NavBar/index.js +++ b/src/containers/NavBar/index.js @@ -79,7 +79,7 @@ class NavBar extends Component { array.push(val.proposal_id); } if (val.status === 2 || val.status === 'PROPOSAL_STATUS_VOTING_PERIOD') { - this.props.fetchProposalTally(val.proposal_id); + this.props.fetchProposalTally(val.id); } return null; @@ -102,7 +102,7 @@ class NavBar extends Component { array.push(val.proposal_id); } if (val.status === 2 || val.status === 'PROPOSAL_STATUS_VOTING_PERIOD') { - this.props.fetchProposalTally(val.proposal_id); + this.props.fetchProposalTally(val.id); } return null; @@ -154,7 +154,7 @@ class NavBar extends Component { if ((val.status === 2 || val.status === 'PROPOSAL_STATUS_VOTING_PERIOD') && !votedOption && this.props.address) { - this.props.fetchVoteDetails(val.proposal_id, this.props.address); + this.props.fetchVoteDetails(val.id, this.props.address); } return null; @@ -177,8 +177,8 @@ class NavBar extends Component { array.push(val.proposal_id); } if (val.status === 2 || val.status === 'PROPOSAL_STATUS_VOTING_PERIOD') { - this.props.fetchProposalTally(val.proposal_id); - this.props.fetchVoteDetails(val.proposal_id, this.props.address); + this.props.fetchProposalTally(val.id); + this.props.fetchVoteDetails(val.id, this.props.address); } return null; diff --git a/src/containers/Proposals/Cards.js b/src/containers/Proposals/Cards.js index 03ba829..575d3d3 100644 --- a/src/containers/Proposals/Cards.js +++ b/src/containers/Proposals/Cards.js @@ -32,11 +32,21 @@ const Cards = (props) => { const VoteCalculation = (proposal, val) => { if (proposal.status === 2 || proposal.status === 'PROPOSAL_STATUS_VOTING_PERIOD') { const value = props.tallyDetails && props.tallyDetails[proposal.id]; - const sum = value && value.yes_count && value.no_count && value.no_with_veto_count && value.abstain_count && - (parseInt(value.yes_count) + parseInt(value.no_count) + parseInt(value.no_with_veto_count) + parseInt(value.abstain_count)); - - return (props.tallyDetails && props.tallyDetails[proposal.id] && props.tallyDetails[proposal.id][val] - ? tally(props.tallyDetails[proposal.id][val], sum) : '0%'); + const sum = value && value.yes && value.no && value.no_with_veto && value.abstain && + (parseInt(value.yes) + parseInt(value.no) + parseInt(value.no_with_veto) + parseInt(value.abstain)); + let val1 = null; + if (val === 'yes_count') { + val1 = 'yes'; + } else if (val === 'no_count') { + val1 = 'no'; + } else if (val === 'no_with_veto_count') { + val1 = 'no_with_veto'; + } else if (val === 'abstain_count') { + val1 = 'abstain'; + } + + return (props.tallyDetails && props.tallyDetails[proposal.id] && props.tallyDetails[proposal.id][val1] + ? tally(props.tallyDetails[proposal.id][val1], sum) : '0%'); } else { const sum = proposal.final_tally_result && proposal.final_tally_result.yes_count && proposal.final_tally_result.no_count && proposal.final_tally_result.no_with_veto_count &&