blob: 4d55c6efa463251a39bbc3eb5547c014537c1541 (
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
|
import React, { Component } from 'react'
import { connect } from 'react-redux'
import { history } from 'app/store'
import actions from 'app/actions'
import { Loader } from 'app/common'
import VenueForm from '../components/venue.form'
import VenueMenu from '../components/venue.menu'
class VenueEdit extends Component {
componentDidMount() {
console.log(this.props.match.params.id)
actions.venue.show(this.props.match.params.id)
}
handleSubmit(data) {
actions.venue.update(data)
.then(response => {
// response
console.log(response)
history.push('/venue/')
})
}
render() {
const { show } = this.props.venue
if (show.loading || !show.res) {
return (
<div className='form'>
<Loader />
</div>
)
}
return (
<div className='row formContainer'>
<VenueMenu />
<VenueForm
data={show.res}
onSubmit={this.handleSubmit.bind(this)}
/>
</div>
)
}
}
const mapStateToProps = state => ({
venue: state.venue,
})
export default connect(mapStateToProps)(VenueEdit)
|