summaryrefslogtreecommitdiff
path: root/src/main/js
diff options
context:
space:
mode:
authorVictor Chabbert <chabbertvi@eisti.eu>2016-12-19 18:18:37 +0100
committerVictor Chabbert <chabbertvi@eisti.eu>2016-12-19 18:18:37 +0100
commit5d958c67361905da3e0c1f44e4153fef07b5e224 (patch)
tree6a12d276f051faae5e4b276e3c5476b16a9b7445 /src/main/js
parentGameBrowser saga (diff)
downloadseven-wonders-5d958c67361905da3e0c1f44e4153fef07b5e224.tar.gz
seven-wonders-5d958c67361905da3e0c1f44e4153fef07b5e224.tar.bz2
seven-wonders-5d958c67361905da3e0c1f44e4153fef07b5e224.zip
List games
Diffstat (limited to 'src/main/js')
-rw-r--r--src/main/js/src/containers/GameBrowser/index.js26
-rw-r--r--src/main/js/src/containers/GameBrowser/reducer.js6
-rw-r--r--src/main/js/src/containers/GameBrowser/saga.js1
3 files changed, 26 insertions, 7 deletions
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 (<Flex key={key}>
+ <Text>{game.name}</Text>
+ <Space auto />
+ <a href="#">Join</a>
+ </Flex>)
+ })
+ }
+
render() {
return (
- <div>Game Browser</div>
+ <div>
+ {this.listGames(this.props.games)}
+ </div>
)
}
}
-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))
bgstack15