blob: 2f084979d6b6e970958af30601b9833534b16c6f (
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
54
55
56
57
|
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.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
let { dataset } = this.props.api.paperInfo
papers = papers || {}
const paperOptions = Object.keys(papers).map(key => (
<option key={key} value={key}>{papers[key].name}</option>
))
return (
<header>
<section>
<select value={dataset && dataset.key} onChange={this.pickPaper.bind(this)}>
{paperOptions}
</select>
{dataset &&
<div>
{dataset.name_full}{' - '}
<a href={"/paper/" + dataset.key + "/info"}>Info</a>{' - '}
<a href={"/paper/" + dataset.key + "/citations/"}>Citations</a>{' - '}
<a href={"/paper/" + dataset.key + "/unknown/"}>Unknown</a>{' - '}
<a href={"/paper/" + dataset.key + "/random/"}>Random</a>
</div>
}
</section>
<section></section>
</header>
)
}
}
const mapStateToProps = state => ({
api: state.api
})
const mapDispatchToProps = dispatch => ({
actions: bindActionCreators({ ...actions }, dispatch),
})
export default connect(mapStateToProps, mapDispatchToProps)(Header)
|