Skip to content

Commit

Permalink
fix: correct winning vote percentage
Browse files Browse the repository at this point in the history
  • Loading branch information
Th1nkK1D committed Oct 24, 2024
1 parent 720ad2c commit 8251617
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/routes/votings/[id]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@
{#if resultsByPerson.length === 0}
<div class="body-compact-01 my-3 text-center text-gray-60 md:my-8">ไม่พบข้อมูล</div>
{:else}
{@const winningOption = getWinningOption(voting.result)}
<div
class="voting-jumpnav sticky top-0 z-10 mt-4 flex w-full items-center gap-x-[1px] bg-white"
>
Expand Down Expand Up @@ -249,14 +250,12 @@
class="flex items-center gap-x-1 {resultColorLookup[voting.result] ?? 'text-purple-70'}"
>
<span class="fluid-heading-05 ml-0 md:ml-1">
{Math.round(
(results.reduce(
(max, result) => (result.total > max.total ? result : max),
results[0]
).total /
resultsByPerson.length) *
100
)}% {getWinningOption(voting.result)}
{#if resultColorLookup[voting.result]}
{Math.round(
((results.find((r) => r.voteOption === winningOption)?.total ?? 0) * 100) /
resultsByPerson.length
)}%
{/if}{winningOption}
</span>
</div>
<div
Expand Down

0 comments on commit 8251617

Please sign in to comment.