@@ -17,6 +17,7 @@ import { TokenBalance } from "../reusables/BalanceDisplay";
1717import { ProposalStatusBadge } from "./ProposalBadge" ;
1818import { cn } from "@/lib/utils" ;
1919import { getProposalStatus , safeNumberFromBigInt } from "@/utils/proposal" ;
20+ import { useProposalVote } from "@/hooks/useProposalVote" ;
2021import type {
2122 ProposalVoteData ,
2223 ProposalVetoData ,
@@ -144,6 +145,12 @@ function NewProposalCard({
144145 vetoData,
145146 currentBlockHeight,
146147} : NewProposalCardProps ) {
148+ // Use the same vote hook as VoteStatusChart for consistent data
149+ const { voteDisplayData, calculations, hasData } = useProposalVote ( {
150+ proposal : proposal ,
151+ fallbackVotesFor : voteData ?. rawVotesFor ,
152+ fallbackVotesAgainst : voteData ?. rawVotesAgainst ,
153+ } ) ;
147154 const router = useRouter ( ) ;
148155
149156 // Compute status from props
@@ -160,8 +167,18 @@ function NewProposalCard({
160167 } ;
161168 } , [ proposal , currentBlockHeight ] ) ;
162169
163- // Use pre-fetched vote data - exact same logic as ProposalCard
170+ // Use vote data from useProposalVote hook ( same as VoteStatusChart)
164171 const voteSummary = useMemo ( ( ) => {
172+ if ( hasData && voteDisplayData && calculations ) {
173+ return {
174+ votesFor : calculations . votesForNum ,
175+ votesAgainst : calculations . votesAgainstNum ,
176+ totalVotes : calculations . totalVotes ,
177+ hasVoteData : true ,
178+ } ;
179+ }
180+
181+ // Fallback to pre-fetched batch data if available
165182 if ( voteData ?. hasVoteData ) {
166183 return {
167184 votesFor : voteData . votesFor ,
@@ -171,7 +188,7 @@ function NewProposalCard({
171188 } ;
172189 }
173190
174- // Fallback to proposal props
191+ // Final fallback to proposal props
175192 const hasVoteData =
176193 proposal . votes_for != null && proposal . votes_against != null ;
177194
@@ -192,7 +209,14 @@ function NewProposalCard({
192209 totalVotes : votesFor + votesAgainst ,
193210 hasVoteData : true ,
194211 } ;
195- } , [ voteData , proposal . votes_for , proposal . votes_against ] ) ;
212+ } , [
213+ hasData ,
214+ voteDisplayData ,
215+ calculations ,
216+ voteData ,
217+ proposal . votes_for ,
218+ proposal . votes_against ,
219+ ] ) ;
196220
197221 // Memoize reference extraction
198222 const references = useMemo (
@@ -214,8 +238,13 @@ function NewProposalCard({
214238 [ proposal . created_at ]
215239 ) ;
216240
217- // Check if vetoed
218- const isVetoed = vetoData ?. vetoExceedsForVote && ! isActive ;
241+ // Check if vetoed - use calculations if available, fallback to prop
242+ const isVetoed =
243+ ! isActive &&
244+ ( ( calculations && vetoData ?. totalVetoAmount
245+ ? vetoData . totalVetoAmount > calculations . votesForNum
246+ : false ) ||
247+ ( vetoData ?. vetoExceedsForVote ?? false ) ) ;
219248
220249 // Enhanced calculations for quorum and threshold display
221250 const enhancedCalculations = useMemo ( ( ) => {
@@ -247,7 +276,9 @@ function NewProposalCard({
247276 metThreshold,
248277 } ;
249278 } , [
250- voteSummary ,
279+ voteSummary . hasVoteData ,
280+ voteSummary . votesFor ,
281+ voteSummary . totalVotes ,
251282 proposal . liquid_tokens ,
252283 proposal . voting_quorum ,
253284 proposal . voting_threshold ,
@@ -413,17 +444,15 @@ function NewProposalCard({
413444 < ThumbsUp
414445 className = { cn (
415446 "h-5 w-5 transition-colors" ,
416- voteSummary . hasVoteData &&
417- status !== "PENDING" &&
418- status !== "DRAFT" &&
447+ voteSummary . totalVotes !== null &&
448+ voteSummary . totalVotes > 0 &&
419449 ( voteSummary . votesFor || 0 ) > 0
420450 ? "text-success fill-success"
421451 : "text-muted-foreground group-hover/btn:text-success"
422452 ) }
423453 />
424- { voteSummary . hasVoteData &&
425- status !== "PENDING" &&
426- status !== "DRAFT" && (
454+ { voteSummary . totalVotes !== null &&
455+ voteSummary . totalVotes > 0 && (
427456 < span
428457 className = { cn (
429458 "text-sm font-medium" ,
@@ -451,17 +480,15 @@ function NewProposalCard({
451480 < ThumbsDown
452481 className = { cn (
453482 "h-5 w-5 transition-colors" ,
454- voteSummary . hasVoteData &&
455- status !== "PENDING" &&
456- status !== "DRAFT" &&
483+ voteSummary . totalVotes !== null &&
484+ voteSummary . totalVotes > 0 &&
457485 ( voteSummary . votesAgainst || 0 ) > 0
458486 ? "text-destructive fill-destructive"
459487 : "text-muted-foreground group-hover/btn:text-destructive"
460488 ) }
461489 />
462- { voteSummary . hasVoteData &&
463- status !== "PENDING" &&
464- status !== "DRAFT" && (
490+ { voteSummary . totalVotes !== null &&
491+ voteSummary . totalVotes > 0 && (
465492 < span
466493 className = { cn (
467494 "text-sm font-medium" ,
0 commit comments