@@ -24,7 +24,6 @@ import { pollApi, type Poll, type PollResults, type BlindVoteResults, type VoteD
2424import Link from "next/link" ;
2525
2626import BlindVotingInterface from "@/components/blind-voting-interface" ;
27- import VotingInterface from "@/components/voting-interface" ;
2827import { SigningInterface } from "@/components/signing-interface" ;
2928
3029export default function Vote ( { params } : { params : Promise < { id : string } > } ) {
@@ -594,7 +593,7 @@ export default function Vote({ params }: { params: Promise<{ id: string }> }) {
594593 ( ( ) => {
595594 const voteData = voteStatus ?. vote ?. data ;
596595 if ( ! voteData ) return "Unknown option" ;
597-
596+
598597 if ( voteData . mode === "normal" && Array . isArray ( voteData . data ) ) {
599598 const optionIndex = parseInt ( voteData . data [ 0 ] || "0" ) ;
600599 return selectedPoll . options [ optionIndex ] || "Unknown option" ;
@@ -633,7 +632,7 @@ export default function Vote({ params }: { params: Promise<{ id: string }> }) {
633632 const isUserChoice = ( ( ) => {
634633 const voteData = voteStatus ?. vote ?. data ;
635634 if ( ! voteData ) return false ;
636-
635+
637636 if ( voteData . mode === "normal" && Array . isArray ( voteData . data ) ) {
638637 return voteData . data . includes ( index . toString ( ) ) ;
639638 } else if ( voteData . mode === "point" && typeof voteData . data === "object" && ! Array . isArray ( voteData . data ) ) {
@@ -650,7 +649,7 @@ export default function Vote({ params }: { params: Promise<{ id: string }> }) {
650649 const userChoiceDetails = ( ( ) => {
651650 const voteData = voteStatus ?. vote ?. data ;
652651 if ( ! voteData ) return null ;
653-
652+
654653 if ( voteData . mode === "normal" && Array . isArray ( voteData . data ) ) {
655654 return voteData . data . includes ( index . toString ( ) ) ? "← You voted for this option" : null ;
656655 } else if ( voteData . mode === "point" && typeof voteData . data === "object" && ! Array . isArray ( voteData . data ) ) {
@@ -1110,17 +1109,26 @@ export default function Vote({ params }: { params: Promise<{ id: string }> }) {
11101109 </ div >
11111110 < div className = "flex items-center space-x-2" >
11121111 < input
1113- type = "number"
1114- min = "0"
1115- max = "100"
1112+ type = "text"
1113+ inputMode = "numeric"
11161114 value = { pointVotes [ index ] || 0 }
11171115 onChange = { ( e ) => {
1118- const value = parseInt ( e . target . value ) || 0 ;
1116+ const input = e . target . value ;
1117+ // Allow only digits
1118+ const numericValue = input . replace ( / \D / g, '' ) ;
1119+ const value = numericValue ? Math . min ( Math . max ( parseInt ( numericValue , 10 ) , 0 ) , 100 ) : 0 ;
11191120 setPointVotes ( prev => ( {
11201121 ...prev ,
11211122 [ index ] : value
11221123 } ) ) ;
11231124 } }
1125+ onInput = { ( e ) => {
1126+ const target = e . target as HTMLInputElement ;
1127+ // Remove non-numeric characters and leading zeros
1128+ const cleaned = target . value . replace ( / \D / g, '' ) ;
1129+ const value = cleaned ? Math . min ( Math . max ( parseInt ( cleaned , 10 ) , 0 ) , 100 ) : 0 ;
1130+ target . value = value . toString ( ) ;
1131+ } }
11241132 className = "w-20 px-3 py-2 border border-gray-300 rounded-md text-center"
11251133 disabled = { ! isVotingAllowed }
11261134 />
0 commit comments