blob: bc3933fa45e1b22162e8cdbe2d75024a73971262 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
import React, { Component } from 'react'
import { connect } from 'react-redux'
import {
Space,
InlineForm,
Text
} from 'rebass'
import { Flex } from 'reflexbox'
import GamesList from '../components/gamesList'
class App extends Component {
createGame = (e) => {
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) => this._gameName = e.target.value}
onClick={this.createGame}
>
</InlineForm>
<Space auto />
<Text><b>Username:</b> {this.props.username}</Text>
<Space x={1} />
</Flex>
<GamesList games={this.props.games} />
</div>
)
}
}
const mapStateToProps = (state) => ({
username: state.players.get('all').get(state.players.get('current')).get('displayName'),
games: state.games
})
import { actions } from '../redux/games'
const mapDispatchToProps = {
createGame: actions.createGame
}
export default connect(mapStateToProps, mapDispatchToProps)(App)
|