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 {
createGame = (e) => {
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}
)
}
}
import { getCurrentPlayer } from '../redux/players'
import { getAllGames, actions } from '../redux/games'
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)