From 33e3b361d4e9758bbbab1d23ac6b51a2af21e781 Mon Sep 17 00:00:00 2001 From: Victor Chabbert Date: Sat, 20 May 2017 15:00:13 +0200 Subject: Upgrade react-scripts to 1.0.1 --- frontend/src/containers/gameBrowser.js | 54 ++++++++++++++++------------------ frontend/src/containers/lobby.js | 39 ++++++++++++------------ 2 files changed, 45 insertions(+), 48 deletions(-) (limited to 'frontend/src/containers') 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} - > - + /> - Username: {this.props.currentPlayer && this.props.currentPlayer.displayName} + + Username: + {" "} + {this.props.currentPlayer && this.props.currentPlayer.displayName} + - + - ) + ); } } -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 (

{this.getTitle()}

- +
- ) + ); } } -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); -- cgit