diff options
Diffstat (limited to 'animism-align/frontend/app/views/episode/containers/episode.new.js')
| -rw-r--r-- | animism-align/frontend/app/views/episode/containers/episode.new.js | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/animism-align/frontend/app/views/episode/containers/episode.new.js b/animism-align/frontend/app/views/episode/containers/episode.new.js index 42e9837..2ff279b 100644 --- a/animism-align/frontend/app/views/episode/containers/episode.new.js +++ b/animism-align/frontend/app/views/episode/containers/episode.new.js @@ -12,10 +12,26 @@ class EpisodeNew extends Component { state = { loading: true, initialData: {}, + project: {}, } - componentDidMount() { - this.setState({ loading: false }) + this.ready() + } + componentDidUpdate(prevProps) { + if (this.props.project.lookup !== prevProps.project.lookup) { + this.ready() + } + } + ready() { + if (!this.props.project.lookup) return + const { project_id } = this.props.match.params + const project = this.props.project.lookup[project_id] + this.setState({ + loading: false, + initialData: { project_id }, + project, + }) + console.log(this.props.match.params.project_id) } handleSubmit(data) { @@ -24,7 +40,7 @@ class EpisodeNew extends Component { .then(res => { console.log(res) if (res.res && res.res.id) { - history.push('/episode/') + history.push('/') } }) .catch(err => { @@ -44,6 +60,7 @@ class EpisodeNew extends Component { <EpisodeForm isNew data={this.state.initialData} + project={this.state.project} onSubmit={this.handleSubmit.bind(this)} /> </div> @@ -53,6 +70,7 @@ class EpisodeNew extends Component { const mapStateToProps = state => ({ episode: state.episode, + project: state.project.index, }) const mapDispatchToProps = dispatch => ({ |
