Created
June 16, 2024 14:37
-
-
Save PaulieScanlon/b04932a386818c9a8d85c1f29e8add32 to your computer and use it in GitHub Desktop.
Result Page
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// app/results/page.tsx | |
import Link from 'next/link'; | |
import getAllVotes from './get-all-votes'; | |
export default async function Page() { | |
const votes = await getAllVotes(); | |
return ( | |
<> | |
<Link href='/'>Back</Link> | |
<h1>Results</h1> | |
<ul> | |
{votes.results.map((result, index) => { | |
const { value, count, percent, max } = result; | |
return ( | |
<li key={index}> | |
<div> | |
<span>{value}</span> | |
<span>{` ${percent}%`}</span> | |
</div> | |
<progress value={count} max={max} /> | |
</li> | |
); | |
})} | |
<p> {`${votes.total} votes`}</p> | |
</ul> | |
</> | |
); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment