Skip to content

Commit

Permalink
proposal page fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
SrikanthSoparla committed Feb 5, 2024
1 parent f290a59 commit c6c994f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/actions/proposals.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export const fetchVoteDetails = (id, address) => (dispatch) => {
},
})
.then((res) => {
dispatch(fetchVoteDetailsSuccess(res.data && res.data.result));
dispatch(fetchVoteDetailsSuccess(res.data && res.data.vote));
})
.catch((error) => {
dispatch(fetchVoteDetailsError(
Expand Down
15 changes: 9 additions & 6 deletions src/containers/Proposals/Cards.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,12 @@ const Cards = (props) => {
{reversedItems.length &&
reversedItems.map((proposal, index) => {
if (index < (page * rowsPerPage) && index >= (page - 1) * rowsPerPage) {
const votedOption = props.voteDetails && props.voteDetails.length &&
let votedOption = props.voteDetails && props.voteDetails.length &&
proposal && proposal.id &&
props.voteDetails.filter((vote) => vote && vote.id === proposal.id)[0];
props.voteDetails.filter((vote) => vote && vote.proposal_id === proposal.id)[0];
if (votedOption && votedOption.options && votedOption.options.length && votedOption.options[0]) {
votedOption = votedOption.options[0];
}
let proposer = proposal.proposer;
props.proposalDetails && Object.keys(props.proposalDetails).length &&
Object.keys(props.proposalDetails).filter((key) => {
Expand Down Expand Up @@ -113,10 +116,10 @@ const Cards = (props) => {
votedOption
? <div className="details">
<p>your vote is taken: <b>
{votedOption && votedOption.option === 1 ? 'Yes'
: votedOption && votedOption.option === 2 ? 'Abstain'
: votedOption && votedOption.option === 3 ? 'No'
: votedOption && votedOption.option === 4 ? 'NoWithVeto'
{votedOption && (votedOption.option === 1 || votedOption.option === 'VOTE_OPTION_YES') ? 'Yes'
: votedOption && (votedOption.option === 2 || votedOption.option === 'VOTE_OPTION_ABSTAIN') ? 'Abstain'
: votedOption && (votedOption.option === 3 || votedOption.option === 'VOTE_OPTION_NO') ? 'No'
: votedOption && (votedOption.option === 4 || votedOption.option === 'VOTE_OPTION_NO_WITH_VETO') ? 'NoWithVeto'
: votedOption && votedOption.option}
</b></p>
<Button
Expand Down
17 changes: 9 additions & 8 deletions src/containers/Proposals/ProposalDialog/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@ class ProposalDialog extends Component {
}

componentDidMount () {
const votedOption = this.props.voteDetails && this.props.voteDetails.length && this.props.proposal && this.props.proposal.id &&
this.props.voteDetails.filter((vote) => vote.id === this.props.proposal.id)[0];

let votedOption = this.props.voteDetails && this.props.voteDetails.length && this.props.proposal && this.props.proposal.id &&
this.props.voteDetails.filter((vote) => vote.proposal_id === this.props.proposal.id)[0];
if (votedOption && votedOption.options && votedOption.options.length && votedOption.options[0]) {
votedOption = votedOption.options[0];
}
if (!votedOption && this.props.proposal && this.props.proposal.id && this.props.address) {
this.props.fetchVoteDetails(this.props.proposal.id, this.props.address);
}
Expand Down Expand Up @@ -110,7 +112,10 @@ class ProposalDialog extends Component {
render () {
let votedOption = this.props.voteDetails && this.props.voteDetails.length &&
this.props.proposal && this.props.proposal.id &&
this.props.voteDetails.filter((vote) => vote && vote.id === this.props.proposal.id)[0];
this.props.voteDetails.filter((vote) => vote && vote.proposal_id === this.props.proposal.id)[0];
if (votedOption && votedOption.options && votedOption.options.length && votedOption.options[0]) {
votedOption = votedOption.options[0];
}
let proposer = this.props.proposal && this.props.proposal.proposer;

this.props.proposalDetails && Object.keys(this.props.proposalDetails).length &&
Expand All @@ -130,10 +135,6 @@ class ProposalDialog extends Component {
return null;
});

if (votedOption && votedOption.options && votedOption.options.length) {
votedOption = votedOption.options[0];
}

const content = this.props.proposal && this.props.proposal.messages && this.props.proposal.messages[0] && this.props.proposal.messages[0].content;

return (
Expand Down

0 comments on commit c6c994f

Please sign in to comment.