diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2021-03-09 17:50:09 +0100 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2021-03-09 17:50:09 +0100 |
| commit | 786404a8a692448b04fd8df5dbca8013631a0abd (patch) | |
| tree | 3ac3169eb478776e3a99e57c7b90e2c90048e1a4 /animism-align/frontend/app/views/episode/containers/episode.new.js | |
| parent | d2cb17038b8537a609be06be2ed7013dbe27117e (diff) | |
adding episodes to projects
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 => ({ |
