summaryrefslogtreecommitdiff
path: root/frontend/src/containers/home.js
blob: cc35f2bc6781604d5c3f5c339901da3aa13635cc (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
import React, { Component } from 'react'
import { connect } from 'react-redux'
import { Heading, InlineForm } from 'rebass'
import { Link } from 'react-router'
class HomePage extends Component {

  play = (e) => {
    e.preventDefault()
    if (this._username !== undefined) {
      this.props.chooseUsername(this._username)
    }
  }

  render() {
    return (
      <div>
        <Heading>Enter your username to start playing!</Heading>
        <InlineForm
          buttonLabel="Play now!"
          label="Username"
          name="username"
          onChange={(e) => this._username = e.target.value}
          onClick={this.play}
        />
        <Link to="/somewhere">Take me somewhere</Link>
      </div>
    )
  }
}

const mapStateToProps = (state) => ({

})

import { actions } from '../redux/user'
const mapDispatchToProps = {
  chooseUsername: actions.chooseUsername
}

export default connect(mapStateToProps, mapDispatchToProps)(HomePage)
bgstack15