summaryrefslogtreecommitdiff
path: root/animism-align/frontend/app/views/venue/containers/venue.index.js
blob: cd8d9f686e6e06901bd7deb2a4fc1c9aa46a13c8 (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
72
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 VenueMenu from '../components/venue.menu'

// const { result, collectionLookup } = this.props

class VenueIndex extends Component {
  componentDidMount() {
    this.fetch()
  }

  fetch() {
    actions.venue.index()
  }

  render() {
    const { loading, lookup, order } = this.props.venue.index
    if (loading) {
      return (
        <section>
          <Loader />
        </section>
      )
    }
    if (!lookup || !order.length) {
      return (
        <section>
          <div className="row venue-index">
            <VenueMenu />
            <div>
              <h1>Venues</h1>
              <p className='gray'>
                {"No venues"}
              </p>
            </div>
          </div>
        </section>
      )
    }
    return (
      <section>
        <div className="row venue-index">
          <VenueMenu />
          <div className="venue-list">
            <h1>Venues</h1>
            {order.map(id => (
              <div key={id}>
                <Link to={"/venue/" + id + "/edit/"}>
                  {lookup[id].title}
                </Link>
                <br />
                {lookup[id].date}
              </div>
            ))}
          </div>
        </div>
        {order.length >= 50 && <button className='loadMore' onClick={() => this.fetch(true)}>Load More</button>}
      </section>
    )
  }
}

const mapStateToProps = state => ({
  venue: state.venue,
})

export default connect(mapStateToProps)(VenueIndex)