blob: a14d925f67e01f848ede8273b98ec11e52180776 (
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 { NavLink } from 'react-router-dom'
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
import { history } from '../store'
import * as actions from '../actions'
class Header extends Component {
componentDidMount() {
this.props.actions.getInstitutions()
this.props.actions.getPapers()
}
pickPaper(e) {
console.log(e.target.value)
history.push('/paper/' + e.target.value + '/info/')
// this.props.actions.getPaperData(e.target.value)
}
render() {
let { papers } = this.props.api.papers
papers = papers || {}
const paperOptions = Object.keys(papers).map(key => (
<option key={key} value={key}>{papers[key][1]}</option>
))
return (
<header>
<section>
<select onChange={this.pickPaper.bind(this)}>
{paperOptions}
</select>
</section>
<section></section>
</header>
)
}
}
const mapStateToProps = state => ({
api: state.api
})
const mapDispatchToProps = dispatch => ({
actions: bindActionCreators({ ...actions }, dispatch),
})
export default connect(mapStateToProps, mapDispatchToProps)(Header)
|