import React, { Component } from 'react' import { connect } from 'react-redux' import { history } from 'app/store' import actions from 'app/actions' import { Loader } from 'app/common' import EpisodeForm from '../components/episode.form' import EpisodeMenu from '../components/episode.menu' class EpisodeEdit extends Component { state = { project: {}, } componentDidMount() { this.ready() } componentDidUpdate(prevProps) { if (this.props.project.lookup !== prevProps.project.lookup) { this.ready() } } ready() { if (!this.props.project.lookup) return console.log(this.props.match.params.id) actions.episode.show(this.props.match.params.id) .then(episode => { const project = this.props.project.lookup[episode.project_id] this.setState({ project }) }) } handleSubmit(data) { actions.episode.update(data) .then(response => { // response console.log(response) history.push('/') }) } render() { const { show } = this.props.episode if (show.loading || !show.res) { return (