From 7bb37545cc54e6cc380d7133367c9325616dd163 Mon Sep 17 00:00:00 2001 From: Bekiboo Date: Mon, 19 Jan 2026 15:01:21 +0300 Subject: [PATCH 1/2] fix: remove unnecessary imports and handle leading zero in point voting input --- platforms/eVoting/src/app/(app)/[id]/page.tsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/platforms/eVoting/src/app/(app)/[id]/page.tsx b/platforms/eVoting/src/app/(app)/[id]/page.tsx index 920a7bb1..da34da4a 100644 --- a/platforms/eVoting/src/app/(app)/[id]/page.tsx +++ b/platforms/eVoting/src/app/(app)/[id]/page.tsx @@ -24,7 +24,6 @@ import { pollApi, type Poll, type PollResults, type BlindVoteResults, type VoteD import Link from "next/link"; import BlindVotingInterface from "@/components/blind-voting-interface"; -import VotingInterface from "@/components/voting-interface"; import { SigningInterface } from "@/components/signing-interface"; export default function Vote({ params }: { params: Promise<{ id: string }> }) { @@ -594,7 +593,7 @@ export default function Vote({ params }: { params: Promise<{ id: string }> }) { (() => { const voteData = voteStatus?.vote?.data; if (!voteData) return "Unknown option"; - + if (voteData.mode === "normal" && Array.isArray(voteData.data)) { const optionIndex = parseInt(voteData.data[0] || "0"); return selectedPoll.options[optionIndex] || "Unknown option"; @@ -633,7 +632,7 @@ export default function Vote({ params }: { params: Promise<{ id: string }> }) { const isUserChoice = (() => { const voteData = voteStatus?.vote?.data; if (!voteData) return false; - + if (voteData.mode === "normal" && Array.isArray(voteData.data)) { return voteData.data.includes(index.toString()); } 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 }> }) { const userChoiceDetails = (() => { const voteData = voteStatus?.vote?.data; if (!voteData) return null; - + if (voteData.mode === "normal" && Array.isArray(voteData.data)) { return voteData.data.includes(index.toString()) ? "← You voted for this option" : null; } else if (voteData.mode === "point" && typeof voteData.data === "object" && !Array.isArray(voteData.data)) { @@ -1115,12 +1114,17 @@ export default function Vote({ params }: { params: Promise<{ id: string }> }) { max="100" value={pointVotes[index] || 0} onChange={(e) => { - const value = parseInt(e.target.value) || 0; + const value = parseInt(e.target.value, 10) || 0; setPointVotes(prev => ({ ...prev, [index]: value })); }} + onInput={(e) => { + const target = e.target as HTMLInputElement; + const value = parseInt(target.value, 10) || 0; + target.value = value.toString(); + }} className="w-20 px-3 py-2 border border-gray-300 rounded-md text-center" disabled={!isVotingAllowed} /> From 57ba6b5ab51ee563b86e1c61158ffb8997a4395d Mon Sep 17 00:00:00 2001 From: Bekiboo Date: Tue, 20 Jan 2026 11:29:03 +0300 Subject: [PATCH 2/2] fix: update point voting input to handle leading zeros and restrict to numeric values --- platforms/eVoting/src/app/(app)/[id]/page.tsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/platforms/eVoting/src/app/(app)/[id]/page.tsx b/platforms/eVoting/src/app/(app)/[id]/page.tsx index da34da4a..a03993f7 100644 --- a/platforms/eVoting/src/app/(app)/[id]/page.tsx +++ b/platforms/eVoting/src/app/(app)/[id]/page.tsx @@ -1109,12 +1109,14 @@ export default function Vote({ params }: { params: Promise<{ id: string }> }) {
{ - const value = parseInt(e.target.value, 10) || 0; + const input = e.target.value; + // Allow only digits + const numericValue = input.replace(/\D/g, ''); + const value = numericValue ? Math.min(Math.max(parseInt(numericValue, 10), 0), 100) : 0; setPointVotes(prev => ({ ...prev, [index]: value @@ -1122,7 +1124,9 @@ export default function Vote({ params }: { params: Promise<{ id: string }> }) { }} onInput={(e) => { const target = e.target as HTMLInputElement; - const value = parseInt(target.value, 10) || 0; + // Remove non-numeric characters and leading zeros + const cleaned = target.value.replace(/\D/g, ''); + const value = cleaned ? Math.min(Math.max(parseInt(cleaned, 10), 0), 100) : 0; target.value = value.toString(); }} className="w-20 px-3 py-2 border border-gray-300 rounded-md text-center"