Skip to content

Instantly share code, notes, and snippets.

@PaulieScanlon
Created June 16, 2024 14:37
Show Gist options
  • Save PaulieScanlon/b04932a386818c9a8d85c1f29e8add32 to your computer and use it in GitHub Desktop.
Save PaulieScanlon/b04932a386818c9a8d85c1f29e8add32 to your computer and use it in GitHub Desktop.
Result Page
// 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