summaryrefslogtreecommitdiff
path: root/animism-align/frontend/app/views/viewer/checklist/checklist.container.js
blob: 11310e7aeb371e4e4aad4ecede6b40ef0562528c (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
import React, { Component } from 'react'
import { connect } from 'react-redux'

import actions from 'app/actions'

import ChecklistDropdown from './checklist.dropdown'
import ChecklistContent from './checklist.content'
import CreditsContent from './credits.content'

class Checklist extends Component {
  state = {
    checklistSection: 'all',
  }
  constructor(props) {
    super(props)
    this.handleSectionChange = this.handleSectionChange.bind(this)
  }
  handleSectionChange(checklistSection) {
    this.setState({ checklistSection })
  }
  render() {
    const { viewer } = this.props
    const { checklistSection } = this.state
    return (
      <div className="checklist">
        {viewer.checklist && (
          <div>
            <ChecklistDropdown
              checklistSection={checklistSection}
              onChange={this.handleSectionChange}
            />
            <ChecklistContent
              checklistSection={checklistSection}
            />
          </div>
        )}
        {viewer.credits && (
          <CreditsContent />
        )}
      </div>
    )
  }
}

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

export default connect(mapStateToProps)(Checklist)