Compare commits

..

1 Commits

Author SHA1 Message Date
GotPPay
768afa475b show error dialog if adding chaild organization fails 2018-05-10 18:25:22 +02:00
2 changed files with 13 additions and 88 deletions

View File

@@ -34,65 +34,10 @@ import Checkbox from 'material-ui/Checkbox';
import Popover from 'material-ui/Popover';
let DateTimeFormat;
const roundingTime = 1000 * 60 * 5; //5 minutes
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 = [
<FlatButton
label="Dismiss"
primary={true}
keyboardFocused={true}
onClick={this.handleClose}
/>,
];
return (
<div>
<Dialog
title="Erors"
actions={actions}
modal={false}
open={this.state.open}
onRequestClose={this.handleClose}
overlayStyle={{ backgroundColor: 'transparent' }}
>
{this.props.errorMessages.map(errorMessage => {
return (
<div>
<a>{errorMessage.message}</a>
<br />
</div>
);
})}
</Dialog>
</div>
);
}
}
export class DialogExampleSimple extends React.Component {
state = {
open: true,
@@ -416,18 +361,16 @@ class VerticalNonLinear extends React.Component {
constructor(props) {
super(props);
let dateNow = new Date();
this.state = {
stepIndex: 0,
rideTypeValue: 0,
providerID: 0,
providerName: '',
visitDate: new Date(),
visitTime: new Date(Math.round(dateNow.getTime() / roundingTime) * roundingTime),
visitTime: new Date(),
pickupLocation: null,
pickupTime: new Date(Math.round(dateNow.getTime() / roundingTime) * roundingTime),
pickupTimeReturn: new Date(Math.round(dateNow.getTime() / roundingTime) * roundingTime),
pickupTime: new Date(),
pickupTimeReturn: new Date(),
pickupTimeReturnDisplayMode: 'none',
open: false,
message: 'Booking Ride',
@@ -455,8 +398,6 @@ class VerticalNonLinear extends React.Component {
},
return_time: new Date(),
pickupTimeHide: false,
showValidationErrors: false,
validationErrors: [],
};
}
@@ -491,10 +432,10 @@ class VerticalNonLinear extends React.Component {
}
});
let visitTime = new Date(Math.round((date.getTime() + (1 * 60 * 60 * 1000)) / roundingTime) * roundingTime);
let visitDate = date;
let pickupTime = new Date(Math.round((visitTime.getTime() - (0.5 * 60 * 60 * 1000)) / roundingTime) * roundingTime);
let pickupTimeReturn = new Date(Math.round((visitTime.getTime() - (0.5 * 60 * 60 * 1000)) / roundingTime) * roundingTime);
let visitTime = new Date(new Date().getTime() + (1 * 60 * 60 * 1000));
let visitDate = visitTime;
let pickupTime = new Date(visitTime.getTime() - (0.5 * 60 * 60 * 1000));
let pickupTimeReturn = new Date(visitTime.getTime() - (0.5 * 60 * 60 * 1000));
this.setState(Object.assign(this.state, {
visitDate: visitDate,
@@ -557,15 +498,7 @@ 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(error => {
if (error.response.status === 422) {
//Unprocessable Entity (validation failed)
self.setState(Object.assign(self.state, {
showValidationErrors: true,
validationErrors: error.response.data.data
}));
}
});
}).catch(console.error);
}
}
};
@@ -602,10 +535,10 @@ class VerticalNonLinear extends React.Component {
handleDate(event, date, state) {
let self = state
let visitTime = new Date(Math.round((date.getTime() + (1 * 60 * 60 * 1000)) / roundingTime) * roundingTime);
let visitTime = new Date(date.getTime() + (1 * 60 * 60 * 1000));
let visitDate = date;
let pickupTime = new Date(Math.round((visitTime.getTime() - (0.5 * 60 * 60 * 1000)) / roundingTime) * roundingTime);
let pickupTimeReturn = new Date(Math.round((visitTime.getTime() - (0.5 * 60 * 60 * 1000)) / roundingTime) * roundingTime);
let pickupTime = new Date(visitTime.getTime() - (0.5 * 60 * 60 * 1000));
let pickupTimeReturn = new Date(visitTime.getTime() - (0.5 * 60 * 60 * 1000));
self.setState(Object.assign(self.state, {
visitDate: visitDate,
@@ -852,12 +785,6 @@ class VerticalNonLinear extends React.Component {
}
handleValidationErrosDialogDismiss() {
this.setState(Object.assign(this.state, {
showValidationErrors: false
}));
}
render() {
// const { stepIndex } = this.state;
this.getLocation();
@@ -921,8 +848,6 @@ class VerticalNonLinear extends React.Component {
<div className="box-body padding-xs">
<div style={{ maxWidth: 380, margin: 'auto' }}>
<ValidationErrorsInfoDialog open={this.state.showValidationErrors} errorMessages={this.state.validationErrors} onDismiss={this.handleValidationErrosDialogDismiss.bind(this)} />
<Stepper
activeStep={this.state.stepIndex}
linear={false}

View File

@@ -650,7 +650,7 @@ class Organization extends React.Component {
open={this.state.showErrorMessage}
onRequestClose={this.handleDialogDismiss.bind(this)}
>
{this.state.errorMessage}
{this.state.message}
</Dialog>
<Main organization={this.state.organization}
onAddressAdded={this.handleAddressAdded} onAddressRemoved={this.handleAddressRemoved}