diff --git a/src/routes/app/routes/forms/routes/steppers/components/VerticalNonLinear.js b/src/routes/app/routes/forms/routes/steppers/components/VerticalNonLinear.js
index a3f4894..2dc542b 100644
--- a/src/routes/app/routes/forms/routes/steppers/components/VerticalNonLinear.js
+++ b/src/routes/app/routes/forms/routes/steppers/components/VerticalNonLinear.js
@@ -38,6 +38,61 @@ let DateTimeFormat;
DateTimeFormat = global.Intl.DateTimeFormat;
+export class ValidationErrorsInfoDialog extends React.Component {
+
+ state = {
+ open: this.props.open,
+ }
+
+ componentWillReceiveProps(newProps){
+ this.setState({open: newProps.open});
+ }
+
+ handleOpen = () => {
+ this.setState({ open: true });
+ };
+
+ handleClose = () => {
+ this.setState({ open: false });
+ this.props.onDismiss();
+ };
+
+ render() {
+
+ const actions = [
+ ,
+ ];
+
+ return (
+
+
+
+ );
+ }
+}
+
+
export class DialogExampleSimple extends React.Component {
state = {
open: true,
@@ -398,6 +453,8 @@ class VerticalNonLinear extends React.Component {
},
return_time: new Date(),
pickupTimeHide: false,
+ showValidationErrors:false,
+ validationErrors:[],
};
}
@@ -498,7 +555,15 @@ class VerticalNonLinear extends React.Component {
Instance.getRawConn().post('/v1/nemt/rides', requestRide).then(function (res) {
self.handleRequestClose(self);
window.location.href = '/#/app/page/map/' + res.data.ride_uuid;
- }).catch(console.error);
+ }).catch(error => {
+ if (error.response.status === 422){
+ //Unprocessable Entity (validation failed)
+ self.setState(Object.assign(self.state, {
+ showValidationErrors:true,
+ validationErrors:error.response.data.data
+ }));
+ }
+ });
}
}
};
@@ -785,6 +850,12 @@ class VerticalNonLinear extends React.Component {
}
+ handleValidationErrosDialogDismiss(){
+ this.setState(Object.assign(this.state, {
+ showValidationErrors:false
+ }));
+ }
+
render() {
// const { stepIndex } = this.state;
this.getLocation();
@@ -848,6 +919,8 @@ class VerticalNonLinear extends React.Component {
+
+
{
- if (err.response.status === 422) {
- location.href = '/#/app/table/organizations';
- } else {
- console.error(err);
+ let errorMessage = '';
+ switch(err.response.status){
+ case 403:
+ errorMessage = 'Not authorized to add child organization';
+ break;
+ case 422:
+ location.href = '/#/app/table/organizations';
+ break;
+ default:
+ errorMessage = 'Error adding child organization';
+ console.error(err);
}
+ this.setState(Object.assign(this.state, { showErrorMessage:true, errorMessage:errorMessage }));
+
});
}
@@ -613,10 +626,32 @@ class Organization extends React.Component {
this.getOrganization(organization.id);
}
+ handleDialogDismiss(){
+ this.setState(Object.assign(this.state, { showErrorMessage:false }));
+ }
+
render() {
+
+ const actions = [
+ ,
+ ];
+
return (
+