Compare commits
7 Commits
show-error
...
ride-valid
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d2b12e11ee | ||
|
|
d6847aae33 | ||
|
|
adf2ba8232 | ||
|
|
c993a194a6 | ||
|
|
961a9f1448 | ||
|
|
0cff9ccae9 | ||
|
|
1fdce51b72 |
@@ -2340,19 +2340,19 @@ html.static.boxed {
|
||||
|
||||
@font-face {
|
||||
font-family: 'Lato';
|
||||
src: url(/assets/./fonts/646474e48f4c1ea783f43ac5e41fd111.woff2) format("woff2"), url(/assets/./fonts/374df2a818582454b6e6832804e52f86.woff) format("woff");
|
||||
src: url(/fonts/lato/lato-regular-webfont.woff2) format("woff2"), url(/fonts/lato/lato-regular-webfont.woff) format("woff");
|
||||
font-weight: bold;
|
||||
font-style: normal; }
|
||||
|
||||
@font-face {
|
||||
font-family: 'Lato';
|
||||
src: url(/assets/./fonts/5fa6d7ddc0a0d53311752343d7176d70.woff2) format("woff2"), url(/assets/./fonts/c53136193516ed2d4fac337d1dc6965a.woff) format("woff");
|
||||
src: url(/assets/./fonts/lato/lato-bolditalic-webfont.woff2) format("woff2"), url(/assets/./fonts/lato/lato-bolditalic-webfont.woff) format("woff");
|
||||
font-weight: bold;
|
||||
font-style: italic; }
|
||||
|
||||
@font-face {
|
||||
font-family: 'Lato';
|
||||
src: url(/assets/./fonts/9bcf055a732c0b22d2279ba79e20c577.woff2) format("woff2"), url(/assets/./fonts/c8eef482ac448a91ecca9d008634c044.woff) format("woff");
|
||||
src: url(/assets/./fonts/lato/lato-italic-webfont.woff2) format("woff2"), url(/assets/./fonts/lato/lato-italic-webfont.woff) format("woff");
|
||||
font-weight: normal;
|
||||
font-style: italic; }
|
||||
|
||||
|
||||
@@ -33,11 +33,69 @@ import Instance from '../../../../../../../components/Connection';
|
||||
import Checkbox from 'material-ui/Checkbox';
|
||||
import Popover from 'material-ui/Popover';
|
||||
|
||||
const ADDRESS_TYPE_HOME = "home";
|
||||
|
||||
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 +419,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 +458,8 @@ class VerticalNonLinear extends React.Component {
|
||||
},
|
||||
return_time: new Date(),
|
||||
pickupTimeHide: false,
|
||||
showValidationErrors:false,
|
||||
validationErrors:[],
|
||||
};
|
||||
}
|
||||
|
||||
@@ -412,6 +474,16 @@ class VerticalNonLinear extends React.Component {
|
||||
if (user.useruuid !== loggedUser.useruuid) {
|
||||
Instance.getRawConn().get(`/v1/nemt/users/member/${user.useruuid}`)
|
||||
.then(function (res) {
|
||||
let userHomeAddress = null;
|
||||
res.data.addresses.forEach(address => {
|
||||
if (address.address_type === ADDRESS_TYPE_HOME) {
|
||||
userHomeAddress = address;
|
||||
}
|
||||
});
|
||||
if (userHomeAddress != null) {
|
||||
userHomeAddress.name = "Home";
|
||||
state.handlePickupChanged(userHomeAddress, state);
|
||||
}
|
||||
state.setState(Object.assign(state.state, { user: res.data, showUserSelection: true, userSelectionText: `${res.data.member} - ${res.data.name}` }));
|
||||
})
|
||||
.catch(err => {
|
||||
@@ -432,17 +504,19 @@ 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 date = new Date();
|
||||
|
||||
this.setState(Object.assign(this.state, {
|
||||
visitDate: visitDate,
|
||||
visitTime: visitTime,
|
||||
pickupTime: pickupTime,
|
||||
pickupTimeReturn: pickupTimeReturn,
|
||||
}));
|
||||
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,
|
||||
visitTime: visitTime,
|
||||
pickupTime: pickupTime,
|
||||
pickupTimeReturn: pickupTimeReturn,
|
||||
}));
|
||||
}
|
||||
//for snackbar
|
||||
handleTouchTap() {
|
||||
@@ -466,7 +540,8 @@ class VerticalNonLinear extends React.Component {
|
||||
if (stepIndex === 3) {
|
||||
self.handleTouchTap();
|
||||
var requestRide = {
|
||||
user_uuid: state.state.user.useruuid,
|
||||
user_uuid: state.state.user ? state.state.user.useruuid : '',
|
||||
user_consent: state.state.checked,
|
||||
ride_type: "lyft",
|
||||
origin: state.state.origin,
|
||||
destination: state.state.destination,
|
||||
@@ -498,7 +573,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 +618,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,
|
||||
@@ -739,7 +822,7 @@ class VerticalNonLinear extends React.Component {
|
||||
|
||||
handlePickupChanged = (res, state) => {
|
||||
let origin = {
|
||||
id: res.id,
|
||||
id: res.address_uuid ? res.address_uuid : res.id,
|
||||
name: res.name,
|
||||
lat: res.lat,
|
||||
lng: res.lng,
|
||||
@@ -785,6 +868,12 @@ class VerticalNonLinear extends React.Component {
|
||||
|
||||
}
|
||||
|
||||
handleValidationErrosDialogDismiss(){
|
||||
this.setState(Object.assign(this.state, {
|
||||
showValidationErrors:false
|
||||
}));
|
||||
}
|
||||
|
||||
render() {
|
||||
// const { stepIndex } = this.state;
|
||||
this.getLocation();
|
||||
@@ -823,7 +912,17 @@ class VerticalNonLinear extends React.Component {
|
||||
|
||||
if (this.state.showUserSelection && this.state.users.length > 0) {
|
||||
const handleAutocomplete = (u) => {
|
||||
state.setState(Object.assign(state.state, { user: u, userSelectionText: u.userdata }));
|
||||
let userHomeAddress = null;
|
||||
u.addresses.forEach(address => {
|
||||
if (address.address_type === ADDRESS_TYPE_HOME) {
|
||||
userHomeAddress = address;
|
||||
}
|
||||
});
|
||||
if (userHomeAddress != null) {
|
||||
userHomeAddress.name = "Home";
|
||||
state.handlePickupChanged(userHomeAddress,state);
|
||||
}
|
||||
state.setState(Object.assign(state.state, { user: u, userSelectionText: u.userdata }));
|
||||
}
|
||||
const datasourceConfig = { text: 'userdata', value: 'useruuid' }
|
||||
userSelection = (
|
||||
@@ -848,6 +947,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}
|
||||
|
||||
@@ -650,7 +650,7 @@ class Organization extends React.Component {
|
||||
open={this.state.showErrorMessage}
|
||||
onRequestClose={this.handleDialogDismiss.bind(this)}
|
||||
>
|
||||
{this.state.message}
|
||||
{this.state.errorMessage}
|
||||
</Dialog>
|
||||
<Main organization={this.state.organization}
|
||||
onAddressAdded={this.handleAddressAdded} onAddressRemoved={this.handleAddressRemoved}
|
||||
|
||||
@@ -47,7 +47,9 @@ class SignUp extends React.Component {
|
||||
"role": { name: "", key: "SP", desc: "" },
|
||||
"profiles": [],
|
||||
"types": [],
|
||||
"organizations": []
|
||||
"organizations": [],
|
||||
showValidationErrors : false,
|
||||
validationErrors: []
|
||||
}
|
||||
|
||||
this.buttonValidated = this.buttonValidated.bind(this);
|
||||
@@ -226,12 +228,42 @@ class SignUp extends React.Component {
|
||||
localStorage.removeItem('loggedUser');
|
||||
location.href = '/#/login';
|
||||
}).catch(function (err) {
|
||||
alert('Error to log in: ' + err.message);
|
||||
if (err.response.status === 422){
|
||||
//Unprocessable Entity (validation failed)
|
||||
state.setState(Object.assign(state.state, {
|
||||
showValidationErrors:true,
|
||||
validationErrors:err.response.data.data
|
||||
}));
|
||||
}else{
|
||||
alert('Error to log in: ' + err.message);
|
||||
}
|
||||
console.error(err);
|
||||
});
|
||||
}
|
||||
|
||||
handleDismiss(){
|
||||
this.setState(Object.assign(this.state, { showErrorMessage: false }));
|
||||
}
|
||||
|
||||
render() {
|
||||
let validationErrors = null;
|
||||
if (this.state.showValidationErrors){
|
||||
validationErrors = (
|
||||
<ul>
|
||||
{this.state.validationErrors.map(errorMessage=>{
|
||||
const oneValidationMessage = (<li>{errorMessage.message}</li>);
|
||||
const oneValidationMessageWithTab = (<span><li style={{marginLeft:2 + "em"}}>{errorMessage.message}</li></span>);
|
||||
|
||||
if (errorMessage.field_name === "password-tab"){
|
||||
return oneValidationMessageWithTab;
|
||||
} else{
|
||||
return oneValidationMessage;
|
||||
}
|
||||
})}
|
||||
</ul>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="body-inner">
|
||||
|
||||
@@ -334,6 +366,10 @@ class SignUp extends React.Component {
|
||||
<div className="form-group">
|
||||
<p className="text-small">By clicking on sign up, you agree to <a href="javascript:;"><i>terms</i></a> and <a href="javascript:;"><i>privacy policy</i></a></p>
|
||||
</div>
|
||||
<div className="divider" />
|
||||
<div className="form-group">
|
||||
{validationErrors}
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user