Skip to content

Commit

Permalink
vote details fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
SrikanthSoparla committed Mar 19, 2024
1 parent 755f9e1 commit c5c6d61
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 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
2 changes: 1 addition & 1 deletion src/constants/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ export const PROPOSALS_LIST_URL = `${REST_URL}/cosmos/gov/v1beta1/proposals?pagi
export const getDelegatedValidatorsURL = (address) => `${REST_URL}/cosmos/staking/v1beta1/delegators/${address}/validators`;
export const urlFetchProposalVotes = (id) => `${REST_URL}/cosmos/gov/v1beta1/proposals/${id}/votes`;
export const urlFetchTallyDetails = (id) => `${REST_URL}/cosmos/gov/v1beta1/proposals/${id}/tally`;
export const urlFetchProposalDetails = (id) => `${REST_URL}/cosmos/tx/v1beta1/txs?events=submit_proposal.proposal_id=${id}`;
export const urlFetchProposalDetails = (id) => `${REST_URL}/cosmos/gov/v1/proposals/${id}`;

export const validatorImageURL = (id) => `https://keybase.io/_/api/1.0/user/lookup.json?fields=pictures&key_suffix=${id}`;
13 changes: 8 additions & 5 deletions src/containers/Proposals/Cards.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,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.proposal_id &&
props.voteDetails.filter((vote) => vote && (vote.proposal_id === proposal.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 @@ -102,10 +105,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

0 comments on commit c5c6d61

Please sign in to comment.