blob: 2ac03b013f6e303ee56a48232b460229d412ff58 (
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
|
import React, { Component } from 'react'
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
import * as actions from '../actions'
import { Loader } from '../common'
class PaperManager extends Component {
componentDidMount() {
this.props.actions.getPaperInfo(this.props.match.params.key)
}
componentDidUpdate(oldProps) {
if (this.props.match.params.key !== oldProps.match.params.key) {
this.props.actions.getPaperInfo(this.props.match.params.key)
}
}
render() {
if (!this.props.match.params.key) return null
if (this.props.api.paperInfo.loading) return <Loader />
if (!this.props.api.paperInfo.dataset) return <div className='paperInfo'>Metadata not found</div>
return null
}
}
const mapStateToProps = state => ({
api: state.api,
})
const mapDispatchToProps = dispatch => ({
actions: bindActionCreators({ ...actions }, dispatch),
})
export default connect(mapStateToProps, mapDispatchToProps)(PaperManager)
|