summaryrefslogtreecommitdiff
path: root/frontend/views/page/components/tile.edit.js
blob: 34205055491ac8231ed8382613377bbde2d51159 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import React, { Component } from 'react'
import { Link } from 'react-router-dom'
import { connect } from 'react-redux'

import { history } from '../../../store'
import actions from '../../../actions'

import { Loader } from '../../../common'

import TileForm from '../components/tile.form'

class TileEdit extends Component {
  componentDidMount() {
    console.log(this.props.match.params.id)
    actions.tile.show(this.props.match.params.id)
  }

  handleSubmit(data) {
    actions.tile.update(data)
      .then(response => {
        // response
        console.log(response)
      })
  }

  render() {
    const { show } = this.props.tile
    if (show.loading || !show.res) {
      return (
        <div className='form'>
          <Loader />
        </div>
      )
    }
    return (
      <TileForm
        data={show.res}
        graph={this.props.graph.show.res}
        onSubmit={this.handleSubmit.bind(this)}
      />
    )
  }
}

const mapStateToProps = state => ({
  graph: state.graph,
  page: state.page,
  tile: state.tile,
})

const mapDispatchToProps = dispatch => ({
  // searchActions: bindActionCreators({ ...searchActions }, dispatch),
})

export default connect(mapStateToProps, mapDispatchToProps)(TileEdit)