-
Notifications
You must be signed in to change notification settings - Fork 8
/
StreamEdit.js
39 lines (33 loc) · 927 Bytes
/
StreamEdit.js
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
import _ from 'lodash';
import React from 'react';
import { connect } from 'react-redux';
import { fetchStream, editStream } from '../../actions';
import StreamForm from './StreamForm';
class StreamEdit extends React.Component {
componentDidMount() {
this.props.fetchStream(this.props.match.params.id);
}
onSubmit = formValues => {
this.props.editStream(this.props.match.params.id, formValues);
};
render() {
if (!this.props.stream) {
return <div>Loading...</div>;
}
return (
<div>
<h3>Edit a Stream</h3>
<StreamForm
initialValues={_.pick(this.props.stream, 'title', 'description')}
onSubmit={this.onSubmit}
/>
</div>
);
}
}
const mapStateToProps = (state, ownProps) => {
return { stream: state.streams[ownProps.match.params.id] };
};
export default connect(mapStateToProps, { fetchStream, editStream })(
StreamEdit
);