Admin posts decrypted results

This commit is contained in:
Henry Wong
2020-08-15 16:29:18 -07:00
parent f8ad9f8765
commit 9770470a2f
3 changed files with 30 additions and 1 deletions

View File

@@ -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:

View 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>
)
}

View File

@@ -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>{`