diff --git a/infrastructure/eid-wallet/src/routes/(app)/scan-qr/+page.svelte b/infrastructure/eid-wallet/src/routes/(app)/scan-qr/+page.svelte index ea8aef92..e0fe7d25 100644 --- a/infrastructure/eid-wallet/src/routes/(app)/scan-qr/+page.svelte +++ b/infrastructure/eid-wallet/src/routes/(app)/scan-qr/+page.svelte @@ -1171,86 +1171,6 @@ {signingData?.pollId ?? "Unknown"}
- -- You selected: Option {parseInt(signingData.voteData.optionId) + - 1} -
-- (This is the option number from the poll) -
- {:else if signingData?.voteData?.ranks} - -Your ranking order:
-- (1st = most preferred, 2nd = second choice, etc.) -
- {:else if signingData?.voteData?.points} - -Your point distribution:
-- (Total: {Object.values( - signingData.voteData.points, - ).reduce( - (sum, points) => - (sum as number) + ((points as number) || 0), - 0, - )}/100 points) -
- {:else} -Vote data not available
- {/if} -- You voted for:{" "} - { - selectedPoll.options[ - parseInt(voteStatus.vote?.optionId || "0") - ] - } -
-- Here are the current results for this - poll. -
+ )}- Private Poll - Your vote is hidden -
-- This is a private poll. Your individual vote remains hidden until revealed. -
+ ) : selectedPoll.visibility !== "private" ? ( + /* For public polls that have ended, show final results */ +- {selectedPoll.mode === "rank" ? "Points" : "Votes"} -
-- {resultsData?.totalVotes || 0} -
+ ) : ( + <> + {/* For active polls, show user's vote choice */} + {selectedPoll.visibility !== "private" && ( ++ You voted:{" "} + { + (() => { + if (voteStatus?.vote?.data?.mode === "normal" && Array.isArray(voteStatus.vote.data.data)) { + const optionIndex = parseInt(voteStatus.vote.data.data[0] || "0"); + return selectedPoll.options[optionIndex] || "Unknown option"; + } else if (voteStatus?.vote?.data?.mode === "point" && Array.isArray(voteStatus.vote.data.data)) { + const pointData = voteStatus.vote.data.data; + const totalPoints = pointData.reduce((sum, item) => sum + (item.points || 0), 0); + return `distributed ${totalPoints} points across options`; + } else if (voteStatus?.vote?.data?.mode === "rank" && Array.isArray(voteStatus.vote.data.data)) { + const rankData = voteStatus.vote.data.data; + const sortedRanks = [...rankData].sort((a, b) => a.points - b.points); + const topChoice = selectedPoll.options[parseInt(sortedRanks[0]?.option || "0")]; + return `ranked options (${topChoice} as 1st choice)`; + } + return "Unknown option"; + })() + } +
++ {isVotingAllowed + ? "Your vote has been submitted. Results will be shown when the poll ends." + : "Here are the final results for this poll." + } +
+- Status -
-- Voting has ended for this poll -
-- The voting deadline has passed. Here are - the final results. -
+You have already voted on this poll
+Results will be shown when the poll ends
- Voter details are available for - active polls with results. -
-+ You voted for:{" "} + { + (() => { + if (voteStatus?.vote?.data?.mode === "normal" && Array.isArray(voteStatus.vote.data.data)) { + const optionIndex = parseInt(voteStatus.vote.data.data[0] || "0"); + return selectedPoll.options[optionIndex] || "Unknown option"; + } + return "Unknown option"; + })() + } +
++ Your vote has been submitted. Results will be shown when the poll ends. +
+- You have 100 points to distribute. Assign points to each option based on your preference. -
- Rank your top 3 choices from most preferred (1) to least preferred (3). -
-+ Rank your top 3 choices from most preferred (1) to least preferred (3). +
+- Leave empty for no deadline. Voting will be open indefinitely. + Set a deadline for when voting will end.
{errors.deadline && (@@ -234,6 +234,59 @@ export default function CreatePoll() { )}
+ {errors.visibility.message} +
+ )} +Coming soon - currently disabled
- {errors.visibility.message} -
- )} -- Create a new vote with custom options and voting - modes -
- -handleSort("title")} + > + Title {getSortIcon("title")} + | +handleSort("mode")} + > + Mode {getSortIcon("mode")} + | +handleSort("visibility")} + > + Visibility {getSortIcon("visibility")} + | +handleSort("status")} + > + Status {getSortIcon("status")} + | +handleSort("deadline")} + > + Deadline {getSortIcon("deadline")} + | +
---|---|---|---|---|
+ + {poll.title} + + | +
+ |
+
+ |
+
+ |
+ + {poll.deadline ? new Date(poll.deadline).toLocaleDateString() : "No deadline"} + | +
You have already voted on this poll
-Your private vote has been submitted successfully
+This is a blind vote - your choice remains hidden until revealed
++ Note: Your vote cannot be revealed and you can check back for results once they are declared. +
+You have already voted on this poll
+Results will be shown when the poll ends
+