From 7e4a60f2bd13a59f77ca45263162561e82dd02d4 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Tue, 9 Jun 2020 20:10:16 +0200 Subject: edit page settings --- frontend/views/graph/components/page.edit.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'frontend/views/graph/components/page.edit.js') diff --git a/frontend/views/graph/components/page.edit.js b/frontend/views/graph/components/page.edit.js index 1e59647..5bc64d6 100644 --- a/frontend/views/graph/components/page.edit.js +++ b/frontend/views/graph/components/page.edit.js @@ -1,9 +1,12 @@ import React, { Component } from 'react' import { Link } from 'react-router-dom' import { connect } from 'react-redux' +import { bindActionCreators } from 'redux' import { history } from '../../../store' import actions from '../../../actions' +import * as siteActions from '../../site/site.actions' +import * as graphActions from '../../graph/graph.actions' import { Loader } from '../../../common' @@ -11,16 +14,22 @@ import PageForm from '../components/page.form' class PageEdit extends Component { componentDidMount() { - console.log(this.props.match.params.id) - actions.page.show(this.props.match.params.id) + // actions.page.show(this.props.match.params.id) } handleSubmit(data) { + const { path: graphPath } = this.props.graph.show.res + const { path: oldPagePath } = this.props.page.show.res + const { path: newPagePath } = data actions.page.update(data) .then(response => { - // response - console.log(response) - // history.push('/' + data.path) + // console.log(response) + actions.site.setSiteTitle(response.res.title) + this.props.graphActions.hideEditPageForm() + if (oldPagePath !== newPagePath) { + const newPath = '/' + graphPath + '/' + newPagePath + history.push(newPath) + } }) } @@ -49,7 +58,8 @@ const mapStateToProps = state => ({ }) const mapDispatchToProps = dispatch => ({ - // searchActions: bindActionCreators({ ...searchActions }, dispatch), + siteActions: bindActionCreators({ ...siteActions }, dispatch), + graphActions: bindActionCreators({ ...graphActions }, dispatch), }) export default connect(mapStateToProps, mapDispatchToProps)(PageEdit) -- cgit v1.2.3-70-g09d2