diff options
Diffstat (limited to 'animism-align/frontend/app/views/venue/containers/venue.new.js')
| -rw-r--r-- | animism-align/frontend/app/views/venue/containers/venue.new.js | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/animism-align/frontend/app/views/venue/containers/venue.new.js b/animism-align/frontend/app/views/venue/containers/venue.new.js index f39dc19..fdab291 100644 --- a/animism-align/frontend/app/views/venue/containers/venue.new.js +++ b/animism-align/frontend/app/views/venue/containers/venue.new.js @@ -13,9 +13,23 @@ class VenueNew extends Component { loading: true, initialData: {}, } - 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 = parseInt(this.props.project.lookup[project_id]) + this.setState({ + loading: false, + initialData: { project_id }, + project, + }) } handleSubmit(data) { @@ -24,7 +38,7 @@ class VenueNew extends Component { .then(res => { console.log(res) if (res.res && res.res.id) { - history.push('/venue/') + history.push(`/project/${res.res.project_id}/venues/`) } }) .catch(err => { @@ -44,6 +58,7 @@ class VenueNew extends Component { <VenueForm isNew data={this.state.initialData} + project={this.state.project} onSubmit={this.handleSubmit.bind(this)} /> </div> @@ -52,7 +67,7 @@ class VenueNew extends Component { } const mapStateToProps = state => ({ - venue: state.venue, + project: state.project.index, }) export default connect(mapStateToProps)(VenueNew) |
