mirror of
https://github.com/siv-org/siv.git
synced 2026-01-09 10:27:57 -05:00
Admin posts decrypted results
This commit is contained in:
@@ -27,7 +27,7 @@ TODO:
|
||||
- [x] Admin can see which voters submitted
|
||||
- [x] Admin can manually close voting early
|
||||
- [x] Admin does first shuffle
|
||||
- [ ] Admin posts final results
|
||||
- [x] Admin posts final results
|
||||
|
||||
For strong privacy:
|
||||
|
||||
|
||||
27
src/status/DecryptedVotes.tsx
Normal file
27
src/status/DecryptedVotes.tsx
Normal file
@@ -0,0 +1,27 @@
|
||||
import ms from 'ms'
|
||||
import { useRouter } from 'next/router'
|
||||
import useSWR from 'swr'
|
||||
|
||||
const fetcher = (url: string) => fetch(url).then((r) => r.json())
|
||||
|
||||
export const DecryptedVotes = (): JSX.Element => {
|
||||
const { election_id } = useRouter().query
|
||||
|
||||
// Grab votes from api
|
||||
const { data } = useSWR(election_id ? `/api/election/${election_id}/decrypted-votes` : null, fetcher, {
|
||||
refreshInterval: ms('10s'),
|
||||
})
|
||||
|
||||
if (!data) return <></>
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h3>Decrypted Votes</h3>
|
||||
<ol>
|
||||
{data.map((vote: NodeJS.Dict<string>, index: number) => (
|
||||
<li key={index}>{JSON.stringify(vote)}</li>
|
||||
))}
|
||||
</ol>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -3,6 +3,7 @@ import { useRouter } from 'next/router'
|
||||
import { GlobalCSS } from '../GlobalCSS'
|
||||
import { Head } from '../Head'
|
||||
import { AcceptedVotes } from './AcceptedVotes'
|
||||
import { DecryptedVotes } from './DecryptedVotes'
|
||||
|
||||
export const ElectionStatusPage = (): JSX.Element => {
|
||||
const { election_id } = useRouter().query
|
||||
@@ -14,6 +15,7 @@ export const ElectionStatusPage = (): JSX.Element => {
|
||||
<h1>Election Status</h1>
|
||||
<h2>ID: {election_id}</h2>
|
||||
<AcceptedVotes />
|
||||
<DecryptedVotes />
|
||||
</main>
|
||||
|
||||
<style jsx>{`
|
||||
|
||||
Reference in New Issue
Block a user