Fix broken sending page
This commit is contained in:
@@ -8,6 +8,7 @@ import { withRouter } from 'react-router-dom';
|
|||||||
|
|
||||||
class Form extends React.Component {
|
class Form extends React.Component {
|
||||||
static defaultProps = {
|
static defaultProps = {
|
||||||
|
params: {},
|
||||||
errors: undefined,
|
errors: undefined,
|
||||||
fields: undefined,
|
fields: undefined,
|
||||||
item: undefined,
|
item: undefined,
|
||||||
@@ -22,6 +23,10 @@ class Form extends React.Component {
|
|||||||
id: '',
|
id: '',
|
||||||
onSubmit: undefined,
|
onSubmit: undefined,
|
||||||
automationId: '',
|
automationId: '',
|
||||||
|
messages: {
|
||||||
|
onUpdate: () => { /* no-op */ },
|
||||||
|
onCreate: () => { /* no-op */ },
|
||||||
|
},
|
||||||
endpoint: undefined,
|
endpoint: undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -151,14 +156,15 @@ class Form extends React.Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
handleValueChange = (e) => {
|
handleValueChange = (e) => {
|
||||||
|
const { name, value } = e.target;
|
||||||
if (this.props.onChange) {
|
if (this.props.onChange) {
|
||||||
return this.props.onChange(e);
|
return this.props.onChange(e);
|
||||||
}
|
}
|
||||||
this.setState((prevState) => {
|
this.setState((prevState) => {
|
||||||
const item = prevState.item;
|
const item = prevState.item;
|
||||||
const field = e.target.name;
|
const field = name;
|
||||||
|
|
||||||
item[field] = e.target.value;
|
item[field] = value;
|
||||||
|
|
||||||
return { item };
|
return { item };
|
||||||
});
|
});
|
||||||
@@ -259,7 +265,7 @@ class Form extends React.Component {
|
|||||||
Form.propTypes = {
|
Form.propTypes = {
|
||||||
params: PropTypes.shape({
|
params: PropTypes.shape({
|
||||||
id: PropTypes.string,
|
id: PropTypes.string,
|
||||||
}).isRequired,
|
}),
|
||||||
item: PropTypes.object, // eslint-disable-line react/forbid-prop-types
|
item: PropTypes.object, // eslint-disable-line react/forbid-prop-types
|
||||||
errors: PropTypes.arrayOf(PropTypes.object),
|
errors: PropTypes.arrayOf(PropTypes.object),
|
||||||
endpoint: PropTypes.string,
|
endpoint: PropTypes.string,
|
||||||
@@ -267,7 +273,7 @@ Form.propTypes = {
|
|||||||
messages: PropTypes.shape({
|
messages: PropTypes.shape({
|
||||||
onUpdate: PropTypes.func,
|
onUpdate: PropTypes.func,
|
||||||
onCreate: PropTypes.func,
|
onCreate: PropTypes.func,
|
||||||
}).isRequired,
|
}),
|
||||||
loading: PropTypes.bool,
|
loading: PropTypes.bool,
|
||||||
children: PropTypes.array, // eslint-disable-line react/forbid-prop-types
|
children: PropTypes.array, // eslint-disable-line react/forbid-prop-types
|
||||||
id: PropTypes.string,
|
id: PropTypes.string,
|
||||||
|
Reference in New Issue
Block a user