diff options
author | Victor Chabbert <chabbertvi@eisti.eu> | 2017-05-20 15:00:13 +0200 |
---|---|---|
committer | Victor Chabbert <chabbertvi@eisti.eu> | 2017-05-20 15:00:13 +0200 |
commit | 33e3b361d4e9758bbbab1d23ac6b51a2af21e781 (patch) | |
tree | 8670e3b4f4e76dc52a852a46d6c8170c982ec9f0 /frontend/src/containers | |
parent | Fixed 'unused React' warning (diff) | |
download | seven-wonders-33e3b361d4e9758bbbab1d23ac6b51a2af21e781.tar.gz seven-wonders-33e3b361d4e9758bbbab1d23ac6b51a2af21e781.tar.bz2 seven-wonders-33e3b361d4e9758bbbab1d23ac6b51a2af21e781.zip |
Upgrade react-scripts to 1.0.1
Diffstat (limited to 'frontend/src/containers')
-rw-r--r-- | frontend/src/containers/gameBrowser.js | 54 | ||||
-rw-r--r-- | frontend/src/containers/lobby.js | 39 |
2 files changed, 45 insertions, 48 deletions
diff --git a/frontend/src/containers/gameBrowser.js b/frontend/src/containers/gameBrowser.js index 5db3c1cb..d9d3d363 100644 --- a/frontend/src/containers/gameBrowser.js +++ b/frontend/src/containers/gameBrowser.js @@ -1,21 +1,19 @@ -import React, { Component } from 'react' -import { connect } from 'react-redux' -import { - Space, - InlineForm, - Text -} from 'rebass' -import { Flex } from 'reflexbox' -import GameList from '../components/gameList' +import React, { Component } from "react"; +import { connect } from "react-redux"; +import { Space, InlineForm, Text } from "rebass"; +import { Flex } from "reflexbox"; +import GameList from "../components/gameList"; -class GameBrowser extends Component { +import { getCurrentPlayer } from "../redux/players"; +import { getAllGames, actions } from "../redux/games"; - createGame = (e) => { - e.preventDefault() +class GameBrowser extends Component { + createGame = e => { + e.preventDefault(); if (this._gameName !== undefined) { - this.props.createGame(this._gameName) + this.props.createGame(this._gameName); } - } + }; render() { return ( @@ -25,31 +23,31 @@ class GameBrowser extends Component { buttonLabel="Create Game" label="Game name" name="game_name" - onChange={(e) => this._gameName = e.target.value} + onChange={e => (this._gameName = e.target.value)} onClick={this.createGame} - > - </InlineForm> + /> <Space auto /> - <Text><b>Username:</b> {this.props.currentPlayer && this.props.currentPlayer.displayName}</Text> + <Text> + <b>Username:</b> + {" "} + {this.props.currentPlayer && this.props.currentPlayer.displayName} + </Text> <Space x={1} /> </Flex> - <GameList games={this.props.games} joinGame={this.props.joinGame}/> + <GameList games={this.props.games} joinGame={this.props.joinGame} /> </div> - ) + ); } } -import { getCurrentPlayer } from '../redux/players' -import { getAllGames, actions } from '../redux/games' - -const mapStateToProps = (state) => ({ - currentPlayer: getCurrentPlayer(state) || {displayName: '[ERROR]'}, +const mapStateToProps = state => ({ + currentPlayer: getCurrentPlayer(state) || { displayName: "[ERROR]" }, games: getAllGames(state) -}) +}); const mapDispatchToProps = { createGame: actions.requestCreateGame, joinGame: actions.requestJoinGame -} +}; -export default connect(mapStateToProps, mapDispatchToProps)(GameBrowser) +export default connect(mapStateToProps, mapDispatchToProps)(GameBrowser); diff --git a/frontend/src/containers/lobby.js b/frontend/src/containers/lobby.js index e326698f..8c3e5e4c 100644 --- a/frontend/src/containers/lobby.js +++ b/frontend/src/containers/lobby.js @@ -1,16 +1,18 @@ -import React, { Component } from 'react' -import { connect } from 'react-redux' -import Immutable from 'seamless-immutable' -import { Button } from 'rebass' -import PlayerList from '../components/playerList' +import React, { Component } from "react"; +import { connect } from "react-redux"; +import Immutable from "seamless-immutable"; +import { Button } from "rebass"; +import PlayerList from "../components/playerList"; -class Lobby extends Component { +import { getPlayers } from "../redux/players"; +import { getCurrentGame, actions } from "../redux/games"; +class Lobby extends Component { getTitle() { if (this.props.currentGame) { - return this.props.currentGame.name + ' — Lobby' + return this.props.currentGame.name + " — Lobby"; } else { - return 'What are you doing here? You haven\'t joined a game yet!' + return "What are you doing here? You haven't joined a game yet!"; } } @@ -18,26 +20,23 @@ class Lobby extends Component { return ( <div> <h2>{this.getTitle()}</h2> - <PlayerList players={this.props.players}/> + <PlayerList players={this.props.players} /> <Button onClick={this.props.startGame}>Start Game</Button> </div> - ) + ); } } -import { getPlayers } from '../redux/players' -import { getCurrentGame, actions } from '../redux/games' - -const mapStateToProps = (state) => { - const game = getCurrentGame(state) - return ({ +const mapStateToProps = state => { + const game = getCurrentGame(state); + return { currentGame: game, players: game ? getPlayers(state, game.players) : Immutable([]) - }) -} + }; +}; const mapDispatchToProps = { startGame: actions.requestStartGame -} +}; -export default connect(mapStateToProps, mapDispatchToProps)(Lobby) +export default connect(mapStateToProps, mapDispatchToProps)(Lobby); |