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 (