From 5d958c67361905da3e0c1f44e4153fef07b5e224 Mon Sep 17 00:00:00 2001 From: Victor Chabbert Date: Mon, 19 Dec 2016 18:18:37 +0100 Subject: List games --- src/main/js/src/containers/GameBrowser/index.js | 26 +++++++++++++++++++++-- src/main/js/src/containers/GameBrowser/reducer.js | 6 +----- src/main/js/src/containers/GameBrowser/saga.js | 1 + 3 files changed, 26 insertions(+), 7 deletions(-) (limited to 'src/main/js') diff --git a/src/main/js/src/containers/GameBrowser/index.js b/src/main/js/src/containers/GameBrowser/index.js index 34a50d53..f9b3b29c 100644 --- a/src/main/js/src/containers/GameBrowser/index.js +++ b/src/main/js/src/containers/GameBrowser/index.js @@ -1,11 +1,33 @@ import React, { Component } from 'react' +import { connect } from 'react-redux' +import { Flex } from 'reflexbox' +import { Text, Space } from 'rebass' class GameBrowser extends Component { + + listGames = (games) => { + return Object.keys(games).map(key => { + const game = games[key] + console.log('game', game, key) + return ( + {game.name} + + Join + ) + }) + } + render() { return ( -
Game Browser
+
+ {this.listGames(this.props.games)} +
) } } -export default GameBrowser \ No newline at end of file +const mapStateToProps = (state) => ({ + games: state.games +}) + +export default connect(mapStateToProps, {})(GameBrowser) diff --git a/src/main/js/src/containers/GameBrowser/reducer.js b/src/main/js/src/containers/GameBrowser/reducer.js index 533f6455..5f98bfad 100644 --- a/src/main/js/src/containers/GameBrowser/reducer.js +++ b/src/main/js/src/containers/GameBrowser/reducer.js @@ -1,7 +1,6 @@ import { NEW_GAME } from './constants' const initialState = { - games: {} } export default function reducer(state = initialState, action) { @@ -9,10 +8,7 @@ export default function reducer(state = initialState, action) { case NEW_GAME: return { ...state, - games: { - ...state.games, - [action.game.id]: action.game - } + [action.game.id]: action.game } default: return state diff --git a/src/main/js/src/containers/GameBrowser/saga.js b/src/main/js/src/containers/GameBrowser/saga.js index da45c3a3..f09b5932 100644 --- a/src/main/js/src/containers/GameBrowser/saga.js +++ b/src/main/js/src/containers/GameBrowser/saga.js @@ -45,6 +45,7 @@ export function* watchOnNewGames() { while (true) { const { type, response } = yield take(socketChannel) + console.info('RESPONSE', response) switch (type) { case NEW_GAME: yield put(newGame(response)) -- cgit