summaryrefslogtreecommitdiff
path: root/client/nameSearch/nameSearch.query.js
blob: b82e324bca4a27cc9b026e834cf29931c232eef5 (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
import React, { Component } from 'react'
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'

import * as actions from './nameSearch.actions'

class NameSearchQuery extends Component {
  state = {
    value: null
  }

  handleInput(value) {
    this.setState({ q: value })
    if (value.length > 2) {
      this.props.actions.search(this.props.payload, value)
    }
  }

  render() {
    return (
      <div className='query'>
        <h2>Find Your Name</h2>
        <h3>Searching {13456} identities</h3>
        <p>
          {'Enter your name to see if you were included in this dataset..'}
        </p>
        <input
          type="text"
          class="q"
          placeholder="Enter your name"
          value={this.state.q}
          onInput={e => this.handleInput(e.target.value)}
        />
      </div>
    )
  }
}

const mapStateToProps = state => ({
  result: state.nameSearch.result,
  options: state.nameSearch.options,
})

const mapDispatchToProps = dispatch => ({
  actions: bindActionCreators({ ...actions }, dispatch),
})

export default connect(mapStateToProps, mapDispatchToProps)(NameSearchQuery)