@@ -11,6 +11,8 @@ import { useEnumStore } from "@/store/enums"
1111const appStore = useAppStore ()
1212const enumStore = useEnumStore ()
1313
14+ const lastHead = computed (() => appStore .lastHead )
15+
1416const votes = computed (() => enumStore .enums .voteOption )
1517
1618const props = defineProps ({
@@ -21,30 +23,41 @@ const props = defineProps({
2123})
2224
2325const expand = ref ([" active" ].includes (props .proposal .status ))
26+
27+ const totalVotingPower = computed (() => {
28+ if (Number (props .proposal .total_voting_power )) return Number (props .proposal .total_voting_power )
29+ return lastHead .value ? .total_voting_power ?? 0
30+ })
31+
32+ const quorum = props .proposal .status === " active" ? Number (appStore .constants .gov .quorum ) : Number (props .proposal .quorum )
33+
34+ const isQuorumReached = computed (() => {
35+ return props .proposal .voting_power / 1_000_000 / totalVotingPower .value > quorum
36+ })
2437< / script>
2538
2639< template>
2740 < Flex direction= " column" gap= " 10" : class = " $style.wrapper" >
2841 < Flex @click= " expand = !expand" align= " center" justify= " between" class = " clickable" >
29- <Tooltip position =" start" :disabled =" !proposal.status === 'applied '" >
42+ < Tooltip position= " start" : disabled= " !isQuorumReached && proposal.status === 'active '" >
3043 < Flex align= " center" gap= " 6" >
3144 < Text size= " 12" weight= " 600" color= " secondary" > Voting power< / Text >
32- <Icon v-if =" proposal.status === 'applied '" name =" check-circle" size =" 12" color =" secondary" />
45+ < Icon v- if = " isQuorumReached && proposal.status !== 'active '" name= " check-circle" size= " 12" color= " secondary" / >
3346 < / Flex>
3447
35- <template #content > The quorum is reached - {{ Number(proposal. quorum) * 100 }}% </template >
48+ < template #content> The quorum is reached - {{ quorum * 100 }}% < / template>
3649 < / Tooltip>
3750
3851 < Icon name= " chevron" size= " 12" color= " secondary" : style= " { transform: `rotate(${expand ? '180deg' : '0deg'})` }" / >
3952 < / Flex>
4053
4154 < Flex align= " center" gap= " 4" : class = " $style.voting_wrapper" >
42- <div :style =" { left: `${Number(proposal. quorum) * 100}%` }" :class =" $style.threshold" />
55+ < div : style= " { left: `${quorum * 100}%` }" : class = " [ $style.threshold, !isQuorumReached && $style.red] " / >
4356
4457 < Tooltip
4558 v- if = " proposal.yes"
4659 wide
47- :trigger-width =" `${Math.max(5, (Number (proposal.yes_voting_power) * 100) / (proposal.voting_power * 2) )}%`"
60+ : trigger- width= " `${Math.max(5, ((proposal.yes_voting_power / 1_000_000 ) * 100) / totalVotingPower )}%`"
4861 >
4962 < div
5063 : style= " {
@@ -63,7 +76,7 @@ const expand = ref(["active"].includes(props.proposal.status))
6376 < Tooltip
6477 v- if = " proposal.no"
6578 wide
66- :trigger-width =" `${Math.max(5, (Number (proposal.no_voting_power) * 100) / (proposal.voting_power * 2) )}%`"
79+ : trigger- width= " `${Math.max(5, ((proposal.no_voting_power / 1_000_000 ) * 100) / totalVotingPower )}%`"
6780 >
6881 < div
6982 : style= " {
@@ -78,7 +91,7 @@ const expand = ref(["active"].includes(props.proposal.status))
7891 < Tooltip
7992 v- if = " proposal.no_with_veto"
8093 wide
81- :trigger-width =" `${Math.max(5, (Number (proposal.no_with_veto_voting_power) * 100) / (proposal.voting_power * 2) )}%`"
94+ : trigger- width= " `${Math.max(5, ((proposal.no_with_veto_voting_power / 1_000_000 ) * 100) / totalVotingPower )}%`"
8295 >
8396 < div
8497 : style= " {
@@ -93,7 +106,7 @@ const expand = ref(["active"].includes(props.proposal.status))
93106 < Tooltip
94107 v- if = " proposal.abstain"
95108 wide
96- :trigger-width =" `${Math.max(5, (Number (proposal.abstain_voting_power) * 100) / (proposal.voting_power * 2) )}%`"
109+ : trigger- width= " `${Math.max(5, ((proposal.abstain_voting_power / 1_000_000 ) * 100) / totalVotingPower )}%`"
97110 >
98111 < div
99112 : style= " {
@@ -171,6 +184,11 @@ const expand = ref(["active"].includes(props.proposal.status))
171184 z- index: 1 ;
172185
173186 transform: translateX (- 50 % );
187+
188+ & .red {
189+ background: var (-- red);
190+ box- shadow: 0 0 8px rgb (235 , 87 , 87 );
191+ }
174192}
175193
176194.voting_bar {
0 commit comments