From a17b76ac75f506f5da6fe8adf9c36632b60d4226 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Sat, 26 Sep 2020 14:56:02 +0200 Subject: refactor to use app-rooted js imports --- frontend/app/views/graph/components/page.new.js | 47 +++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 frontend/app/views/graph/components/page.new.js (limited to 'frontend/app/views/graph/components/page.new.js') diff --git a/frontend/app/views/graph/components/page.new.js b/frontend/app/views/graph/components/page.new.js new file mode 100644 index 0000000..e7c3609 --- /dev/null +++ b/frontend/app/views/graph/components/page.new.js @@ -0,0 +1,47 @@ +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 PageForm from '../components/page.form' + +class PageNew extends Component { + handleSubmit(data) { + console.log(data) + actions.page.create(data) + .then(res => { + console.log(res) + const graph = this.props.graph.show.res + if (res.res && res.res.id) { + history.push('/' + graph.path + '/' + res.res.path) + } + }) + .catch(err => { + console.error('error', err) + }) + } + + render() { + return ( + + ) + } +} + +const mapStateToProps = state => ({ + graph: state.graph, + page: state.page, +}) + +const mapDispatchToProps = dispatch => ({ + // searchActions: bindActionCreators({ ...searchActions }, dispatch), +}) + +export default connect(mapStateToProps, mapDispatchToProps)(PageNew) -- cgit v1.2.3-70-g09d2