Compare commits
4 Commits
show-error
...
round-up-d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
591d7be308 | ||
|
|
961a9f1448 | ||
|
|
0cff9ccae9 | ||
|
|
1fdce51b72 |
@@ -34,10 +34,65 @@ 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,
|
||||
@@ -361,16 +416,18 @@ 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(),
|
||||
visitTime: new Date(Math.round(dateNow.getTime() / roundingTime) * roundingTime),
|
||||
pickupLocation: null,
|
||||
pickupTime: new Date(),
|
||||
pickupTimeReturn: new Date(),
|
||||
pickupTime: new Date(Math.round(dateNow.getTime() / roundingTime) * roundingTime),
|
||||
pickupTimeReturn: new Date(Math.round(dateNow.getTime() / roundingTime) * roundingTime),
|
||||
pickupTimeReturnDisplayMode: 'none',
|
||||
open: false,
|
||||
message: 'Booking Ride',
|
||||
@@ -398,6 +455,8 @@ class VerticalNonLinear extends React.Component {
|
||||
},
|
||||
return_time: new Date(),
|
||||
pickupTimeHide: false,
|
||||
showValidationErrors: false,
|
||||
validationErrors: [],
|
||||
};
|
||||
}
|
||||
|
||||
@@ -432,10 +491,10 @@ class VerticalNonLinear extends React.Component {
|
||||
}
|
||||
});
|
||||
|
||||
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));
|
||||
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);
|
||||
|
||||
this.setState(Object.assign(this.state, {
|
||||
visitDate: visitDate,
|
||||
@@ -498,7 +557,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
|
||||
}));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -535,10 +602,10 @@ class VerticalNonLinear extends React.Component {
|
||||
|
||||
handleDate(event, date, state) {
|
||||
let self = state
|
||||
let visitTime = new Date(date.getTime() + (1 * 60 * 60 * 1000));
|
||||
let visitTime = new Date(Math.round((date.getTime() + (1 * 60 * 60 * 1000)) / roundingTime) * roundingTime);
|
||||
let visitDate = date;
|
||||
let pickupTime = new Date(visitTime.getTime() - (0.5 * 60 * 60 * 1000));
|
||||
let pickupTimeReturn = new Date(visitTime.getTime() - (0.5 * 60 * 60 * 1000));
|
||||
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);
|
||||
|
||||
self.setState(Object.assign(self.state, {
|
||||
visitDate: visitDate,
|
||||
@@ -785,6 +852,12 @@ class VerticalNonLinear extends React.Component {
|
||||
|
||||
}
|
||||
|
||||
handleValidationErrosDialogDismiss() {
|
||||
this.setState(Object.assign(this.state, {
|
||||
showValidationErrors: false
|
||||
}));
|
||||
}
|
||||
|
||||
render() {
|
||||
// const { stepIndex } = this.state;
|
||||
this.getLocation();
|
||||
@@ -848,6 +921,8 @@ 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}
|
||||
|
||||
@@ -11,6 +11,8 @@ import {
|
||||
import moment from 'moment';
|
||||
import Delete from 'material-ui/svg-icons/action/delete';
|
||||
import IconButton from 'material-ui/IconButton';
|
||||
import FlatButton from 'material-ui/FlatButton';
|
||||
import Dialog from 'material-ui/Dialog';
|
||||
|
||||
import GoogleAddressComponent from './GoogleAddressComponent';
|
||||
import ContactComponent from './ContactComponent';
|
||||
@@ -463,7 +465,9 @@ class Organization extends React.Component {
|
||||
"useruuid": "",
|
||||
"name": "",
|
||||
}
|
||||
}
|
||||
},
|
||||
showErrorMessage : false,
|
||||
errorMessage : ''
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
@@ -597,11 +601,20 @@ class Organization extends React.Component {
|
||||
self.setState(Object.assign(self.state, { organization: res.data }));
|
||||
})
|
||||
.catch(err => {
|
||||
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 = [
|
||||
<FlatButton
|
||||
label="Dismiss"
|
||||
primary={true}
|
||||
onClick={this.handleDialogDismiss.bind(this)}
|
||||
/>,
|
||||
];
|
||||
|
||||
return (
|
||||
<div className="container-fluid no-breadcrumbs page-dashboard">
|
||||
<QueueAnim type="bottom" className="ui-animate">
|
||||
<Dialog
|
||||
title="Error"
|
||||
actions={actions}
|
||||
modal={false}
|
||||
open={this.state.showErrorMessage}
|
||||
onRequestClose={this.handleDialogDismiss.bind(this)}
|
||||
>
|
||||
{this.state.errorMessage}
|
||||
</Dialog>
|
||||
<Main organization={this.state.organization}
|
||||
onAddressAdded={this.handleAddressAdded} onAddressRemoved={this.handleAddressRemoved}
|
||||
onContactAdded={this.handleContactAdded} onContactRemoved={this.handleContactRemoved}
|
||||
|
||||
Reference in New Issue
Block a user