@@ -63,6 +63,34 @@ const VoteStatusChart = ({
6363 [ refreshVoteData ]
6464 ) ;
6565
66+ // Calculate progress bar size based on quorum (must be before early returns)
67+ const progressBarCalculations = useMemo ( ( ) => {
68+ if ( ! proposal || ! calculations ) return null ;
69+
70+ const quorumPercentage = safeNumberFromBigInt ( proposal . voting_quorum ) ;
71+ const liquidTokensNum = calculations . liquidTokensNum ;
72+
73+ // Calculate quorum amount in tokens
74+ const quorumAmount = ( liquidTokensNum * quorumPercentage ) / 100 ;
75+
76+ // Bar width is quorum + 10%, or total votes if exceeded
77+ const barWidth = Math . max ( quorumAmount * 1.1 , calculations . totalVotes ) ;
78+
79+ // Calculate percentages based on the bar width
80+ const votesForPercentage = ( calculations . votesForNum / barWidth ) * 100 ;
81+ const votesAgainstPercentage =
82+ ( calculations . votesAgainstNum / barWidth ) * 100 ;
83+ const quorumLinePercentage = ( quorumAmount / barWidth ) * 100 ;
84+
85+ return {
86+ votesForPercentage,
87+ votesAgainstPercentage,
88+ quorumLinePercentage,
89+ quorumAmount,
90+ barWidth,
91+ } ;
92+ } , [ proposal , calculations ] ) ;
93+
6694 // Show loading state
6795 if ( isLoadingVotes && ! error ) {
6896 return (
@@ -101,47 +129,7 @@ const VoteStatusChart = ({
101129 ) ;
102130 }
103131
104- if ( ! voteDisplayData || ! calculations ) {
105- return (
106- < div className = "flex items-center justify-center p-4" >
107- < span className = "text-sm text-muted-foreground" >
108- No vote data available
109- </ span >
110- </ div >
111- ) ;
112- }
113-
114- // const isRefreshingAny = localRefreshing || refreshing;
115-
116- // Calculate progress bar size based on quorum
117- const progressBarCalculations = useMemo ( ( ) => {
118- if ( ! proposal || ! calculations ) return null ;
119-
120- const quorumPercentage = safeNumberFromBigInt ( proposal . voting_quorum ) ;
121- const liquidTokensNum = calculations . liquidTokensNum ;
122-
123- // Calculate quorum amount in tokens
124- const quorumAmount = ( liquidTokensNum * quorumPercentage ) / 100 ;
125-
126- // Bar width is quorum + 10%, or total votes if exceeded
127- const barWidth = Math . max ( quorumAmount * 1.1 , calculations . totalVotes ) ;
128-
129- // Calculate percentages based on the bar width
130- const votesForPercentage = ( calculations . votesForNum / barWidth ) * 100 ;
131- const votesAgainstPercentage =
132- ( calculations . votesAgainstNum / barWidth ) * 100 ;
133- const quorumLinePercentage = ( quorumAmount / barWidth ) * 100 ;
134-
135- return {
136- votesForPercentage,
137- votesAgainstPercentage,
138- quorumLinePercentage,
139- quorumAmount,
140- barWidth,
141- } ;
142- } , [ proposal , calculations ] ) ;
143-
144- if ( ! progressBarCalculations ) {
132+ if ( ! voteDisplayData || ! calculations || ! progressBarCalculations ) {
145133 return (
146134 < div className = "flex items-center justify-center p-4" >
147135 < span className = "text-sm text-muted-foreground" >
0 commit comments