import React, { Component } from 'react' import { connect } from 'react-redux' import { Link } from 'react-router-dom' import './dashboard.css' // import actions from 'app/actions' import { Loader } from 'app/common' import { groupResponseBy } from 'app/utils/api.utils' class DashboardContainer extends Component { state = { ready: false, episodes: {}, venues: {}, } constructor(props) { super(props) } componentDidMount() { this.build() } componentDidUpdate(prevProps) { if ( !this.state.ready || (this.props.project !== prevProps.project) || (this.props.episode !== prevProps.episode) || (this.props.venue !== prevProps.venue) ) { this.build() } } build() { if (this.props.loading) return const episodes = groupResponseBy(this.props.episodes, 'project_id') const venues = groupResponseBy(this.props.venues, 'project_id') this.setState({ ready: true, episodes, venues }) } render() { const { loading, projects } = this.props const { episodes, venues, ready } = this.state if (loading || !ready) { return (
) } return (

Projects

+ Add Project
{projects.order.map((project_id) => { const project = projects.lookup[project_id] console.log(project) return (

{project.title}

{project.is_live && {"(published)"}}
+ Add Episode Venues Settings
{(episodes[project.id] || []).map(episode => (
{'Episode #' + episode.episode_number} {episode.is_live && {"(published)"}}
Viewer Timeline Transcript Settings
{episode.title}
))}
) })}
) } } const mapStateToProps = state => ({ loading: ( !state.project.index.lookup || !state.episode.index.lookup || !state.venue.index.lookup || state.project.index.loading || state.episode.index.loading || state.venue.index.loading ), projects: state.project.index, episodes: state.episode.index, venues: state.venue.index, }) export default connect(mapStateToProps)(DashboardContainer)