diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2021-03-06 17:10:15 +0100 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2021-03-06 17:10:15 +0100 |
| commit | b5ceb782f40fc1e402d1e58bc1ced2e4038fd787 (patch) | |
| tree | 33c5e0f9fb50456e58f726d7d584c0699903105d /animism-align/frontend/app/views/project/containers/project.index.js | |
| parent | 9acd74cf1c09a03f832869988c7d14597b26e4c7 (diff) | |
adding project CRUD editor
Diffstat (limited to 'animism-align/frontend/app/views/project/containers/project.index.js')
| -rw-r--r-- | animism-align/frontend/app/views/project/containers/project.index.js | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/animism-align/frontend/app/views/project/containers/project.index.js b/animism-align/frontend/app/views/project/containers/project.index.js new file mode 100644 index 0000000..cf36970 --- /dev/null +++ b/animism-align/frontend/app/views/project/containers/project.index.js @@ -0,0 +1,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) |
