Compare commits

...

3 Commits

Author SHA1 Message Date
GotPPay
21e6759a70 Show validation errors on eligibility check 2018-05-21 17:21:23 +02:00
Senad Uka
adf2ba8232 Upstream sync 2018-05-17 19:02:54 +02:00
Senad Uka
c993a194a6 upstream sync 2018-05-16 18:41:24 +02:00
5 changed files with 167 additions and 83 deletions

View File

@@ -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; }

View File

@@ -0,0 +1,59 @@
import React, { Component } from 'react';
import Dialog from 'material-ui/Dialog';
import FlatButton from 'material-ui/FlatButton';
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={this.props.modal ? this.props.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>
);
}
}
module.exports = ValidationErrorsInfoDialog;

View File

@@ -30,68 +30,18 @@ import Close from 'material-ui/svg-icons/navigation/close'
import CommunicationCall from 'material-ui/svg-icons/communication/call'
import Message from 'material-ui/svg-icons/communication/message'
import Instance from '../../../../../../../components/Connection';
import ValidationErrorsInfoDialog from '../../../../../../../components/Shared/ValidationErrorsInfoDialog';
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 = {
@@ -416,16 +366,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',
@@ -469,6 +421,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 => {
@@ -489,17 +451,17 @@ 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));
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() {
@@ -523,7 +485,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,
@@ -600,10 +563,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,
@@ -894,7 +857,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 = (

View File

@@ -14,6 +14,7 @@ import RaisedButton from 'material-ui/RaisedButton';
import SelectField from 'material-ui/SelectField';
import Checkbox from 'material-ui/Checkbox';
import Instance from '../../../../../../../components/Connection';
import ValidationErrorsInfoDialog from '../../../../../../../components/Shared/ValidationErrorsInfoDialog';
class SignUp extends React.Component {
constructor(props) {
@@ -34,7 +35,9 @@ class SignUp extends React.Component {
gender: null,
agreedTerms: false,
validated: false,
memberType:"S"
memberType:"S",
showValidationErrors: false,
validationErrors:[]
}
componentDidMount = () => {
@@ -58,7 +61,10 @@ class SignUp extends React.Component {
"member": this.state.member,
"email": this.state.email,
"phonenumber": this.state.phonenumber,
"birthdate": this.state.birthdate.toISOString()
"birthdate": this.state.birthdate.toISOString(),
"consent" : this.state.agreedTerms,
"type": this.state.memberType
// "eligibility": {
// "tracking_id": "1234567",
// "payer": {
@@ -99,9 +105,14 @@ class SignUp extends React.Component {
// alert('NO benefits found for this member');
// }
}).catch(function (err) {
console.log('Error to get eligibility: ', err);
alert('NO benefits found for this member');
this.handleRequestClose();
if (err.response.status === 422){
//Unprocessable Entity (validation failed)
state.setState(Object.assign(state.state, {showValidationErrors:true, validationErrors:err.response.data.data}))
}else{
console.log('Error to get eligibility: ', err);
alert('NO benefits found for this member');
this.handleRequestClose();
}
});
}
@@ -173,10 +184,15 @@ class SignUp extends React.Component {
this.setState(Object.assign(this.state, { validated: validated }));
}
handleValidationErrosDialogDismiss(){
this.setState(Object.assign(this.state, {showValidationErrors:false}));
}
render() {
return (
<form className="">
<fieldset>
<ValidationErrorsInfoDialog open = {this.state.showValidationErrors} errorMessages = {this.state.validationErrors} modal={true} onDismiss={this.handleValidationErrosDialogDismiss.bind(this)}/>
<div className="form-group">
<TextField
floatingLabelText="First Name"

View File

@@ -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>