@@ -493,15 +493,7 @@ export default function Vote({ params }: { params: Promise<{ id: string }> }) {
493493 let isWinner : boolean ;
494494 let percentage : number ;
495495
496- if ( resultsData . mode === "point" || resultsData . mode === "ereputation" || result . totalPoints !== undefined ) {
497- // Point-based voting: show total points and average
498- // Check for totalPoints to handle eReputation weighted points-based voting (mode: "ereputation")
499- const totalPoints = result . totalPoints || 0 ;
500- displayValue = `${ totalPoints } points${ result . averagePoints !== undefined ? ` (avg: ${ result . averagePoints } )` : '' } ` ;
501- isWinner = totalPoints === Math . max ( ...resultsData . results . map ( r => r . totalPoints || 0 ) ) ;
502- const totalAllPoints = resultsData . results . reduce ( ( sum , r ) => sum + ( r . totalPoints || 0 ) , 0 ) ;
503- percentage = totalAllPoints > 0 ? ( totalPoints / totalAllPoints ) * 100 : 0 ;
504- } else if ( resultsData . mode === "rank" ) {
496+ if ( resultsData . mode === "rank" ) {
505497 // Rank-based voting: show winner status instead of misleading vote counts
506498 if ( result . isTied ) {
507499 displayValue = "🏆 Tied Winner" ;
@@ -518,10 +510,18 @@ export default function Vote({ params }: { params: Promise<{ id: string }> }) {
518510 // If multiple rounds, there might have been ties
519511 console . log ( `[IRV Debug] Poll had ${ resultsData . irvDetails . rounds . length } rounds, check console for tie warnings` ) ;
520512 }
513+ } else if ( resultsData . mode === "point" || resultsData . mode === "ereputation" ) {
514+ // Point-based voting: show total points and average
515+ // Check for eReputation weighted points-based voting (mode: "ereputation")
516+ const totalPoints = result . totalPoints || 0 ;
517+ displayValue = `${ totalPoints } points${ result . averagePoints !== undefined ? ` (avg: ${ result . averagePoints } )` : '' } ` ;
518+ isWinner = totalPoints === Math . max ( ...resultsData . results . map ( r => r . totalPoints || 0 ) ) ;
519+ const totalAllPoints = resultsData . results . reduce ( ( sum , r ) => sum + ( r . totalPoints || 0 ) , 0 ) ;
520+ percentage = totalAllPoints > 0 ? ( totalPoints / totalAllPoints ) * 100 : 0 ;
521521 } else {
522522 // Normal voting: show votes and percentage
523523 displayValue = `${ result . votes } votes` ;
524- isWinner = result . votes === Math . max ( ...resultsData . results . map ( r => r . votes ) ) ;
524+ isWinner = result . votes === Math . max ( ...resultsData . results . map ( r => r . votes || 0 ) ) ;
525525 percentage = resultsData . totalVotes > 0 ? ( result . votes / resultsData . totalVotes ) * 100 : 0 ;
526526 }
527527
0 commit comments