diff options
Diffstat (limited to 'frontend/src')
-rw-r--r-- | frontend/src/index.js | 18 | ||||
-rw-r--r-- | frontend/src/scenes/Games/index.js | 65 | ||||
-rw-r--r-- | frontend/src/scenes/index.js | 4 |
3 files changed, 11 insertions, 76 deletions
diff --git a/frontend/src/index.js b/frontend/src/index.js index 235f3a0b..8c52b440 100644 --- a/frontend/src/index.js +++ b/frontend/src/index.js @@ -2,21 +2,23 @@ import 'babel-polyfill'; import React from 'react'; import ReactDOM from 'react-dom'; -import { ConnectedRouter } from 'react-router-redux'; import { Provider } from 'react-redux'; +import { ConnectedRouter } from 'react-router-redux'; import './global-styles.css'; import '@blueprintjs/core/dist/blueprint.css'; import configureStore from './store'; -import Routes from './scenes'; +import { Application } from './scenes'; const initialState = {}; const { store, history } = configureStore(initialState); -ReactDOM.render( - <Provider store={store}> +const rootElement = document.getElementById('root'); +if (rootElement) { + ReactDOM.render(<Provider store={store}> <ConnectedRouter history={history}> - <Routes /> + <Application/> </ConnectedRouter> - </Provider>, - document.getElementById('root') -); + </Provider>, rootElement); +} else { + console.error('Element with ID "root" was not found, cannot bootstrap react app'); +} diff --git a/frontend/src/scenes/Games/index.js b/frontend/src/scenes/Games/index.js deleted file mode 100644 index a2031030..00000000 --- a/frontend/src/scenes/Games/index.js +++ /dev/null @@ -1,65 +0,0 @@ -// @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 { Games } from '../../models/games'; -import type { Player } from '../../models/players'; -import { actions, getAllGames } from '../../redux/games'; -import { getCurrentPlayer } from '../../redux/players'; - -class GameBrowser extends Component { - props: { - currentPlayer: Player, - games: List<Games>, - 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 ( - <div> - <Flex align="center" p={1}> - <InlineForm - buttonLabel="Create Game" - label="Game name" - name="game_name" - onChange={(e: SyntheticInputEvent) => (this._gameName = e.target.value)} - onClick={this.createGame} - /> - <Space auto /> - <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} /> - </div> - ); - } -} - -const mapStateToProps = state => ({ - currentPlayer: getCurrentPlayer(state.get('players')), - games: getAllGames(state.get('games')), -}); - -const mapDispatchToProps = { - createGame: actions.requestCreateGame, - joinGame: actions.requestJoinGame, -}; - -export default connect(mapStateToProps, mapDispatchToProps)(GameBrowser); diff --git a/frontend/src/scenes/index.js b/frontend/src/scenes/index.js index 83554d48..ffc2c856 100644 --- a/frontend/src/scenes/index.js +++ b/frontend/src/scenes/index.js @@ -5,7 +5,7 @@ import SplashScreen from './SplashScreen'; import Games from './Games'; import Lobby from './Lobby'; -const Application = () => ( +export const Application = () => ( <Switch> <Route path="/splash-screen" component={SplashScreen} /> <Route path="/games" component={Games} /> @@ -13,5 +13,3 @@ const Application = () => ( <Redirect from="*" to="/splash-screen" /> </Switch> ); - -export default Application; |