mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-30 02:56:20 -05:00
Pass updates up from project updater to top-level redux store
This commit is contained in:
parent
db99c12d89
commit
8e57bb5493
1 changed files with 14 additions and 2 deletions
|
@ -1,11 +1,13 @@
|
||||||
const PropTypes = require('prop-types');
|
const PropTypes = require('prop-types');
|
||||||
const React = require('react');
|
const React = require('react');
|
||||||
const bindAll = require('lodash.bindall');
|
const bindAll = require('lodash.bindall');
|
||||||
const api = require('../../lib/api');
|
|
||||||
const connect = require('react-redux').connect;
|
const connect = require('react-redux').connect;
|
||||||
const injectIntl = require('react-intl').injectIntl;
|
const injectIntl = require('react-intl').injectIntl;
|
||||||
const intlShape = require('react-intl').intlShape;
|
const intlShape = require('react-intl').intlShape;
|
||||||
|
|
||||||
|
const api = require('../../lib/api');
|
||||||
|
const previewActions = require('../../redux/preview');
|
||||||
|
|
||||||
class FormsyProjectUpdater extends React.Component {
|
class FormsyProjectUpdater extends React.Component {
|
||||||
constructor (props) {
|
constructor (props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
@ -41,6 +43,7 @@ class FormsyProjectUpdater extends React.Component {
|
||||||
}, (err, body, res) => {
|
}, (err, body, res) => {
|
||||||
if (res.statusCode === 200) {
|
if (res.statusCode === 200) {
|
||||||
this.setState({value: body[this.props.field], error: false});
|
this.setState({value: body[this.props.field], error: false});
|
||||||
|
this.props.onUpdate(jsonData);
|
||||||
} else {
|
} else {
|
||||||
this.setState({error: res.statusCode});
|
this.setState({error: res.statusCode});
|
||||||
}
|
}
|
||||||
|
@ -63,6 +66,7 @@ FormsyProjectUpdater.propTypes = {
|
||||||
field: PropTypes.string,
|
field: PropTypes.string,
|
||||||
initialValue: PropTypes.string,
|
initialValue: PropTypes.string,
|
||||||
intl: intlShape,
|
intl: intlShape,
|
||||||
|
onUpdate: PropTypes.func,
|
||||||
projectInfo: PropTypes.shape({
|
projectInfo: PropTypes.shape({
|
||||||
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
||||||
}),
|
}),
|
||||||
|
@ -76,4 +80,12 @@ const mapStateToProps = state => ({
|
||||||
user: state.session.session.user
|
user: state.session.session.user
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = connect(mapStateToProps)(injectIntl(FormsyProjectUpdater));
|
const mapDispatchToProps = dispatch => ({
|
||||||
|
onUpdate: info => {
|
||||||
|
dispatch(previewActions.updateProjectInfo(info));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = connect(mapStateToProps, mapDispatchToProps)(
|
||||||
|
injectIntl(FormsyProjectUpdater)
|
||||||
|
);
|
||||||
|
|
Loading…
Reference in a new issue