diff options
Diffstat (limited to 'animism-align/frontend/app/views/episode/containers/episode.edit.js')
| -rw-r--r-- | animism-align/frontend/app/views/episode/containers/episode.edit.js | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/animism-align/frontend/app/views/episode/containers/episode.edit.js b/animism-align/frontend/app/views/episode/containers/episode.edit.js index 4d7e270..8ba16ae 100644 --- a/animism-align/frontend/app/views/episode/containers/episode.edit.js +++ b/animism-align/frontend/app/views/episode/containers/episode.edit.js @@ -10,9 +10,25 @@ 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) { @@ -20,7 +36,7 @@ class EpisodeEdit extends Component { .then(response => { // response console.log(response) - history.push('/episode/') + history.push('/') }) } @@ -38,6 +54,7 @@ class EpisodeEdit extends Component { <EpisodeMenu episodeActions={this.props.episodeActions} /> <EpisodeForm data={show.res} + project={this.state.project} onSubmit={this.handleSubmit.bind(this)} /> </div> @@ -47,6 +64,7 @@ class EpisodeEdit extends Component { const mapStateToProps = state => ({ episode: state.episode, + project: state.episode.index, }) export default connect(mapStateToProps)(EpisodeEdit) |
