Update table
This commit is contained in:
parent
b239577718
commit
019ef38145
@ -55,5 +55,5 @@ span {
|
||||
gap: 30px;
|
||||
}
|
||||
.voting {
|
||||
margin: auto;
|
||||
margin: 15%;
|
||||
}
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user