summaryrefslogtreecommitdiff
path: root/frontend/views/page/components/tile.edit.js
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/views/page/components/tile.edit.js')
-rw-r--r--frontend/views/page/components/tile.edit.js23
1 files changed, 17 insertions, 6 deletions
diff --git a/frontend/views/page/components/tile.edit.js b/frontend/views/page/components/tile.edit.js
index 4943c10..cb339c9 100644
--- a/frontend/views/page/components/tile.edit.js
+++ b/frontend/views/page/components/tile.edit.js
@@ -5,6 +5,7 @@ import { connect } from 'react-redux'
// import { history } from '../../../store'
import actions from '../../../actions'
+import * as pageActions from '../../page/page.actions'
import * as tileActions from '../../tile/tile.actions'
import { Loader } from '../../../common'
@@ -12,24 +13,33 @@ import { Loader } from '../../../common'
import TileForm from '../components/tile.form'
class TileEdit extends Component {
+ state = {
+ tile: null
+ }
componentDidMount() {
- console.log(this.props.match.params.id)
- actions.tile.show(this.props.match.params.id)
+ const { currentEditTileId } = this.props.page.editor
+ const tile = this.props.page.show.res.tiles.filter(tile => tile.id === currentEditTileId)[0]
+ console.log('edit', currentEditTileId)
+ this.setState({ tile })
+ // actions.tile.show(this.props.match.params.id)
}
handleSubmit(data) {
actions.tile.update(data)
.then(response => {
// response
- console.log(response)
+ // console.log(response)
+ if (response.status === 'ok') {
+ this.props.pageActions.updatePageTile(response.res)
+ }
this.props.pageActions.hideEditTileForm()
this.props.tileActions.clearTemporaryTile()
})
}
render() {
- const { show } = this.props.tile
- if (show.loading || !show.res) {
+ const { tile } = this.state
+ if (!tile) {
return (
<div className='form'>
<Loader />
@@ -38,7 +48,7 @@ class TileEdit extends Component {
}
return (
<TileForm
- initialData={show.res}
+ initialData={tile}
graph={this.props.graph.show.res}
page={this.props.page.show.res}
onSubmit={this.handleSubmit.bind(this)}
@@ -54,6 +64,7 @@ const mapStateToProps = state => ({
})
const mapDispatchToProps = dispatch => ({
+ pageActions: bindActionCreators({ ...pageActions }, dispatch),
tileActions: bindActionCreators({ ...tileActions }, dispatch),
})