blob: 0cf3b6c7b6f2725a035d7892a20d9a0dff71ad7b (
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
import React, { Component } from 'react'
import { Link } from 'react-router-dom'
import { connect } from 'react-redux'
import { Loader } from 'app/common'
import actions from 'app/actions'
import EpisodeMenu from '../components/episode.menu'
// const { result, collectionLookup } = this.props
class EpisodeIndex extends Component {
componentDidMount() {
this.fetch()
}
fetch() {
actions.episode.index()
}
render() {
const { loading, lookup, order } = this.props.episode.index
if (loading) {
return (
<section>
<Loader />
</section>
)
}
if (!lookup || !order.length) {
return (
<section>
<div className="row episode-index">
<EpisodeMenu />
<div>
<h1>Episodes</h1>
<p className='gray'>
{"No episodes"}
</p>
</div>
</div>
</section>
)
}
return (
<section>
<div className="row episode-index">
<EpisodeMenu />
<div className="episode-list">
<h1>Episodes</h1>
{order.map(id => (
<div key={id}>
{'Episode '}{lookup[id].episode_number}{': '}
<Link to={"/episode/" + id + "/edit/"}>
lookup[id].title
</Link>
</div>
))}
</div>
</div>
{order.length >= 50 && <button className='loadMore' onClick={() => this.fetch(true)}>Load More</button>}
</section>
)
}
}
const mapStateToProps = state => ({
episode: state.episode,
})
export default connect(mapStateToProps)(EpisodeIndex)
|