diff --git a/app/components/DashboardTile.js b/app/components/DashboardTile.js index da4e78f..3136824 100644 --- a/app/components/DashboardTile.js +++ b/app/components/DashboardTile.js @@ -4,19 +4,6 @@ import styles from '@/app/styles/DashboardTile.module.css' import { useData } from '@/app/DataProvider' -// Calculate winner of match -const calculateWinner = (player1, player2) => { - const player1Total = player1.reduce( - (total, current) => (!isNaN(current.score) ? total + current.score : total), - 0 - ) - const player2Total = player2.reduce( - (total, current) => (!isNaN(current.score) ? total + current.score : total), - 0 - ) - return player1Total > player2Total -} - const DashboardTile = ({ clientTeam, opponentTeam, @@ -35,96 +22,100 @@ const DashboardTile = ({ const isOpaque = (player1Scores, player2Scores) => { return player1Scores.map((score, index) => { - const player1Score = !isNaN(score.score) ? score.score : 0; - const player2Score = !isNaN(player2Scores[index]?.score) ? player2Scores[index].score : 0; - return player1Score > player2Score; - }); - }; + const player1Score = !isNaN(score.score) ? score.score : 0 + const player2Score = !isNaN(player2Scores[index]?.score) + ? player2Scores[index].score + : 0 + return player1Score > player2Score + }) + } // Calculate opacity map before rendering - const player1Opacity = isOpaque(player1FinalScores, player2FinalScores); + const player1Opacity = isOpaque(player1FinalScores, player2FinalScores) useEffect(() => { setClientLogo(logos[clientTeam]) setOpponentLogo(logos[opponentTeam]) }, [clientTeam, opponentTeam, logos]) - // Render function for scores - const renderScore = (score, index, isPlayer1, tieScores) => { - const opacity = isPlayer1 ? - (player1Opacity[index] ? '100%' : '40%') : - (!player1Opacity[index] ? '100%' : '40%'); + // Render function for scores + const renderScore = (score, index, isPlayer1, tieScores) => { + const opacity = isPlayer1 + ? player1Opacity[index] + ? '100%' + : '40%' + : !player1Opacity[index] + ? '100%' + : '40%' - return ( - !isNaN(score.score) && ( -
Loading ...
-) : ( -Loading ...
+ ) : ( +- Live Score {isUnfinished && '(UF)'} - | +Live Score {isUnfinished && '(UF)'} | |||
---|---|---|---|---|
{player1Name} | {player1FinalScores.map((score, index) => - localPlayData && !isNaN(score.score) && index + 1 < localPlayData.setNum ? ( -player2FinalScores[index].score ? 1 : 0.4 + localPlayData && + !isNaN(score.score) && + index + 1 < localPlayData.setNum ? ( + | player2FinalScores[index].score ? 1 : 0.4 }} > {player1TieScores[index] ? ( @@ -67,7 +68,7 @@ const ScoreBoard = ({ fontSize: '0.6em', top: '0.1em', right: '0em', - letterSpacing: '1px', + letterSpacing: '1px' }} > {player1TieScores[index]} @@ -79,23 +80,28 @@ const ScoreBoard = ({ | ) : null )} - +{player1GameScore} | {pointScore ? player1PointScore : player1TiebreakScore} - {currentServerName && player1Name === currentServerName && •} + {currentServerName && player1Name === currentServerName && ( + • + )} |
{player2Name} | {player2FinalScores.map((score, index) => - localPlayData && !isNaN(score.score) && index + 1 < localPlayData.setNum ? ( -player1FinalScores[index].score ? 1 : 0.4 + localPlayData && + !isNaN(score.score) && + index + 1 < localPlayData.setNum ? ( + | player1FinalScores[index].score ? 1 : 0.4 }} > {player2TieScores[index] ? ( @@ -123,13 +129,15 @@ const ScoreBoard = ({ | {pointScore ? player2PointScore : player2TiebreakScore} - {currentServerName && player2Name === currentServerName && •} + {currentServerName && player2Name === currentServerName && ( + • + )} |