From 73ede6097d5fcd871522a87d02a0c5bc9db00464 Mon Sep 17 00:00:00 2001 From: Joffrey BION Date: Sun, 29 Apr 2018 21:10:55 +0200 Subject: Remove default exports everywhere --- frontend/src/scenes/GameBrowser/index.js | 65 ++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 frontend/src/scenes/GameBrowser/index.js (limited to 'frontend/src/scenes/GameBrowser') diff --git a/frontend/src/scenes/GameBrowser/index.js b/frontend/src/scenes/GameBrowser/index.js new file mode 100644 index 00000000..20a835d1 --- /dev/null +++ b/frontend/src/scenes/GameBrowser/index.js @@ -0,0 +1,65 @@ +// @flow +import type { List } from 'immutable'; +import React, { Component } from 'react'; +import { connect } from 'react-redux'; +import { InlineForm, Space, Text } from 'rebass'; +import { Flex } from 'reflexbox'; +import { GameList } from '../../components/gameList'; +import type { Game } from '../../models/games'; +import type { Player } from '../../models/players'; +import { actions, getAllGames } from '../../redux/games'; +import { getCurrentPlayer } from '../../redux/players'; + +class GameBrowserPresenter extends Component { + props: { + currentPlayer: Player, + games: List, + createGame: (gameName: string) => void, + joinGame: (gameId: string) => void + }; + + _gameName: string | void = undefined; + + createGame = (e: SyntheticEvent): void => { + e.preventDefault(); + if (this._gameName !== undefined) { + this.props.createGame(this._gameName); + } + }; + + render() { + return ( +
+ + (this._gameName = e.target.value)} + onClick={this.createGame} + /> + + + Username: + {' '} + {this.props.currentPlayer && this.props.currentPlayer.displayName} + + + + +
+ ); + } +} + +const mapStateToProps = state => ({ + currentPlayer: getCurrentPlayer(state.get('players')), + games: getAllGames(state.get('games')), +}); + +const mapDispatchToProps = { + createGame: actions.requestCreateGame, + joinGame: actions.requestJoinGame, +}; + +export const GameBrowser = connect(mapStateToProps, mapDispatchToProps)(GameBrowserPresenter); -- cgit