From 6b8b75ba7ff0a512228d3ed33c148991fc564744 Mon Sep 17 00:00:00 2001 From: djmil Date: Thu, 9 Nov 2023 15:59:38 +0100 Subject: [PATCH] component params grouping --- webapp/src/App.js | 9 +++++++-- webapp/src/container/Games.jsx | 18 +++++++++--------- webapp/src/container/Leaderboard.jsx | 9 ++++----- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/webapp/src/App.js b/webapp/src/App.js index 549c55d..379665f 100644 --- a/webapp/src/App.js +++ b/webapp/src/App.js @@ -26,14 +26,19 @@ export default function App() { const gamesApi = useGamesApi(dispatchGames); gamesApi.list(pollingReducer); + const players = { + leaderboard, + isCurrentUser: (playerName) => user?.isCurrentUser(playerName) === true ? true : null + }; + return (
} /> } /> - } /> - } /> + } /> + } /> ) diff --git a/webapp/src/container/Games.jsx b/webapp/src/container/Games.jsx index fe5f91d..fcdeed3 100644 --- a/webapp/src/container/Games.jsx +++ b/webapp/src/container/Games.jsx @@ -21,13 +21,13 @@ import GameBoard from './games/GameBoard'; import { GamesContext, GamesDispatchContext, GamesApiContext } from '../context/games'; -export default function Games({ games, dispatchGames, gamesApi }) { +export default function Games({ context }) { return ( -
- - - + + + +
@@ -39,10 +39,10 @@ export default function Games({ games, dispatchGames, gamesApi }) { */}
- - - -
+
+ + + ) }; diff --git a/webapp/src/container/Leaderboard.jsx b/webapp/src/container/Leaderboard.jsx index 6d8863e..5e447eb 100644 --- a/webapp/src/container/Leaderboard.jsx +++ b/webapp/src/container/Leaderboard.jsx @@ -2,18 +2,17 @@ import './Leaderboard.css'; import React from "react" import Loading from '../components/Loading'; -export default function Leaderboard({ leaderboard, user }) { +export default function Leaderboard({ players }) { + + const leaderboard = players.leaderboard; if (leaderboard == null) return - const isCurrentUser = (playerName) => - user?.isCurrentUser(playerName) === true ? true : null; - const tableRows = Object.keys(leaderboard).map(playerName => { var rank = leaderboard[playerName]; - return + return {playerName} {rank.gamesPlayed} {rank.gamesWon}