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 | 62 |
1 files changed, 62 insertions, 0 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 new file mode 100644 index 0000000..42e9837 --- /dev/null +++ b/animism-align/frontend/app/views/episode/containers/episode.new.js @@ -0,0 +1,62 @@ +import React, { Component } from 'react' +import { Link } from 'react-router-dom' +import { connect } from 'react-redux' + +import { history } from 'app/store' +import actions from 'app/actions' + +import EpisodeForm from '../components/episode.form' +import EpisodeMenu from '../components/episode.menu' + +class EpisodeNew extends Component { + state = { + loading: true, + initialData: {}, + } + + componentDidMount() { + this.setState({ loading: false }) + } + + handleSubmit(data) { + console.log(data) + actions.episode.create(data) + .then(res => { + console.log(res) + if (res.res && res.res.id) { + history.push('/episode/') + } + }) + .catch(err => { + console.error('error') + }) + } + + render() { + if (this.state.loading) { + return ( + <div className='row formContainer' /> + ) + } + return ( + <div className='row formContainer'> + <EpisodeMenu /> + <EpisodeForm + isNew + data={this.state.initialData} + onSubmit={this.handleSubmit.bind(this)} + /> + </div> + ) + } +} + +const mapStateToProps = state => ({ + episode: state.episode, +}) + +const mapDispatchToProps = dispatch => ({ + // uploadActions: bindActionCreators({ ...uploadActions }, dispatch), +}) + +export default connect(mapStateToProps, mapDispatchToProps)(EpisodeNew) |
