Update table

This commit is contained in:
Dominic Zimmer 2022-10-28 18:12:55 +02:00
parent b239577718
commit 019ef38145
2 changed files with 5 additions and 4 deletions

View File

@ -55,5 +55,5 @@ span {
gap: 30px;
}
.voting {
margin: auto;
margin: 15%;
}

View File

@ -1,7 +1,7 @@
import { CSSProperties, useEffect, useState } from 'react';
import './TVMode.css';
import './Client.css';
import { buttonTypeList, WGPPState } from './types';
import { ButtonType, buttonTypeList, WGPPState } from './types';
const TVMode = () => {
@ -38,6 +38,7 @@ const TVMode = () => {
}, [])
const totalCount = buttonTypeList.reduce((acc, v) => (state?.votes?.[v]??0) + acc, 0);
const voteList = buttonTypeList.map(b => [b, state?.votes?.[b] ?? 0] as [ButtonType, number]);
return <div className="stream">
{state === undefined ?
@ -49,9 +50,9 @@ const TVMode = () => {
<span className="timer">{Math.round(state.timeUntilNextMode ?? 0)}s </span>
</div>
<div className="voting">
{buttonTypeList.map((b, index) =>
{voteList.map(([b, numVotes], index) =>
<div className="vote" key={index}>
<span>{b}</span><span> {state?.votes?.[b] ? Math.round(state?.votes?.[b] ?? 0 / totalCount / 100) : ""}</span>
<span>{b}</span><span> {numVotes ? Math.round(numVotes / totalCount * 100) + "%" : ""} </span>
</div>
)}
</div>