-
+
@@ -43,15 +44,15 @@ export default function Games({ context: { gamesReducer, gamesApi }, players })
)
};
-function ViewSelector() {
- // TODO: counter Wating for YOU
+function ViewSelector({ games }) {
+ const awaiting = countGames(games.gamesList);
return (
-
)
-}
\ No newline at end of file
+}
+
+function countGames(gamesList) {
+
+ var awaiting = {
+ proposals: 0,
+ active: 0
+ };
+
+ if (!gamesList)
+ return awaiting;
+
+ for (const game of gamesList) {
+ switch (game.status) {
+ case 'GAME_PROPOSAL_WAIT_FOR_YOU':
+ awaiting.proposals++;
+ break;
+ case 'GAME_BOARD_WAIT_FOR_YOU':
+ case 'DRAW_REQUEST_WAIT_FOR_YO':
+ awaiting.active++;
+ break;
+ default:
+ break;
+ }
+ }
+
+ return awaiting;
+}
diff --git a/webapp/src/container/games/view/GameSelector.css b/webapp/src/container/games/view/GameSelector.css
index c6e46d9..592ed6b 100644
--- a/webapp/src/container/games/view/GameSelector.css
+++ b/webapp/src/container/games/view/GameSelector.css
@@ -46,6 +46,10 @@ hr {
margin-bottom: 7px;
}
+.Separator .Counter {
+ background-color: darkgray;
+}
+
.Selectable .Title {
display: flex;
flex-direction: row;
diff --git a/webapp/src/container/games/view/GameSelector.jsx b/webapp/src/container/games/view/GameSelector.jsx
index 932991c..11a33f4 100644
--- a/webapp/src/container/games/view/GameSelector.jsx
+++ b/webapp/src/container/games/view/GameSelector.jsx
@@ -4,6 +4,7 @@ import { GamesContext } from '../../../context/games';
import { Color, Player } from '../../../components/Checkers';
import Loading from '../../../components/Loading';
+import Counter from '../../../components/Counter';
export default function GameSelector({ yours, opponents, onClick }) {
@@ -49,7 +50,8 @@ function Selectable({ game, onClick }) {
function Separator({ counter }) {
return (
- waiting for opponent ({counter})
+ waiting for opponent
+
)
}
\ No newline at end of file