diff options
author | Victor Chabbert <chabbertvi@eisti.eu> | 2017-07-31 18:44:01 +0200 |
---|---|---|
committer | Victor Chabbert <chabbertvi@eisti.eu> | 2017-08-07 22:41:20 +0200 |
commit | be86c9d23cdae888598e1f7de7812d7e0f1ca12c (patch) | |
tree | f39e95e3e8781c336b6221ce91c557d9e7e84fb0 /frontend/src/scenes/Lobby | |
parent | Updrade react router and react router redux (diff) | |
download | seven-wonders-be86c9d23cdae888598e1f7de7812d7e0f1ca12c.tar.gz seven-wonders-be86c9d23cdae888598e1f7de7812d7e0f1ca12c.tar.bz2 seven-wonders-be86c9d23cdae888598e1f7de7812d7e0f1ca12c.zip |
Refactor routes to new structure
Diffstat (limited to 'frontend/src/scenes/Lobby')
-rw-r--r-- | frontend/src/scenes/Lobby/index.js | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/frontend/src/scenes/Lobby/index.js b/frontend/src/scenes/Lobby/index.js new file mode 100644 index 00000000..1b5a11ff --- /dev/null +++ b/frontend/src/scenes/Lobby/index.js @@ -0,0 +1,42 @@ +import { List } from 'immutable'; +import React, { Component } from 'react'; +import { connect } from 'react-redux'; +import { Button } from 'rebass'; +import PlayerList from '../../components/playerList'; +import { actions, getCurrentGame } from '../../redux/games'; +import { getPlayers } from '../../redux/players'; + +class Lobby extends Component { + getTitle() { + if (this.props.currentGame) { + return this.props.currentGame.name + ' — Lobby'; + } else { + return 'What are you doing here? You haven\'t joined a game yet!'; + } + } + + render() { + return ( + <div> + <h2>{this.getTitle()}</h2> + <PlayerList players={this.props.players} /> + <Button onClick={this.props.startGame}>Start Game</Button> + </div> + ); + } +} + +const mapStateToProps = state => { + const game = getCurrentGame(state.get('games')); + console.info(game); + return { + currentGame: game, + players: game ? getPlayers(state.get('players'), game.players) : new List(), + }; +}; + +const mapDispatchToProps = { + startGame: actions.requestStartGame, +}; + +export default connect(mapStateToProps, mapDispatchToProps)(Lobby); |