blob: cf369705db523df36d53670f2ca80f20da94d75f (
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 ProjectMenu from '../components/project.menu'
// const { result, collectionLookup } = this.props
class ProjectIndex extends Component {
componentDidMount() {
this.fetch()
}
fetch() {
actions.project.index()
}
render() {
const { loading, lookup, order } = this.props.project.index
if (loading) {
return (
<section>
<Loader />
</section>
)
}
if (!lookup || !order.length) {
return (
<section>
<div className="row project-index">
<ProjectMenu />
<div>
<h1>Projects</h1>
<p className='gray'>
{"No projects"}
</p>
</div>
</div>
</section>
)
}
return (
<section>
<div className="row project-index">
<ProjectMenu />
<div className="project-list">
<h1>Projects</h1>
{order.map(id => (
<div key={id}>
{lookup[id].title}{': '}
<Link to={"/project/" + 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 => ({
project: state.project,
})
export default connect(mapStateToProps)(ProjectIndex)
|