From fe9384bd25f8f5e1cdddaa3275f20ca2c93aed56 Mon Sep 17 00:00:00 2001 From: ManhND <260794539+ManhND226677@users.noreply.github.com> Date: Tue, 12 May 2026 11:34:11 +0700 Subject: [PATCH] Fix proposal vote percentage for missing vote counts --- pages/proposals/_id/index.vue | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/pages/proposals/_id/index.vue b/pages/proposals/_id/index.vue index 73ecbd4..c7fdcf3 100644 --- a/pages/proposals/_id/index.vue +++ b/pages/proposals/_id/index.vue @@ -426,8 +426,21 @@ export default { return this.voterComments.slice(0, this.commentListLength) } }, + totalProposalVoteWeight (proposal) { + if (!proposal || !Array.isArray(proposal.vote_counts)) { + return 0 + } + + return proposal.vote_counts.reduce((total, voteCount) => total + Number(voteCount.value || 0), 0) + }, votePercentage (vote, proposal) { - return (vote.weight / (proposal.vote_counts[0].value + proposal.vote_counts[1].value + proposal.vote_counts[2].value) * 100).toFixed(2) + const totalWeight = this.totalProposalVoteWeight(proposal) + + if (!totalWeight) { + return '0.00' + } + + return (vote.weight / totalWeight * 100).toFixed(2) }, async assignToNextCycle () { if (this.$dao.proposalConfig && this.proposal) {