Compare commits

..

6 Commits

Author SHA1 Message Date
GotPPay
ec447fb376 set mouse cursor to move type in whole dialog 2018-05-28 10:43:03 +02:00
GotPPay
330a59edc7 apply material design ; make whole dialog draggable 2018-05-28 10:43:03 +02:00
GotPPay
4ae32afae6 remove react-dialog as package and include as part of the project 2018-05-28 10:43:03 +02:00
GotPPay
0ec2b0cbe4 integrate draggable dialog package 2018-05-28 10:43:03 +02:00
GotPPay
b06a6f3488 add draggable component 2018-05-28 10:43:03 +02:00
GotPPay
5202f91954 Show validation errors on eligibility check 2018-05-28 10:43:03 +02:00
6 changed files with 69 additions and 104 deletions

View File

@@ -4,12 +4,6 @@ import MenuItem from 'material-ui/MenuItem';
import IconButton from 'material-ui/IconButton/IconButton'; import IconButton from 'material-ui/IconButton/IconButton';
import { hashHistory } from 'react-router'; import { hashHistory } from 'react-router';
import {
loggedUser,
visitReporter,
} from 'utils/authorization';
const ImgIconButtonStyle = { const ImgIconButtonStyle = {
width: '60px', width: '60px',
height: '60px' height: '60px'
@@ -54,33 +48,20 @@ class NavRightList extends React.Component {
targetOrigin={{ horizontal: 'right', vertical: 'top' }} targetOrigin={{ horizontal: 'right', vertical: 'top' }}
menuStyle={{ minWidth: '150px' }} menuStyle={{ minWidth: '150px' }}
> >
{!loggedUser.anyOf(visitReporter) && <MenuItem
<MenuItem onTouchTap={(e) => this.handleChange(e, `/app/authorizedusers/${this.state.useruuid}`)}
onTouchTap={(e) => this.handleChange(e, `/app/authorizedusers/${this.state.useruuid}`)} primaryText="Profile"
primaryText="Profile" style={{ fontSize: '14px', lineHeight: '48px' }}
style={{ fontSize: '14px', lineHeight: '48px' }} innerDivStyle={listItemStyle}
innerDivStyle={listItemStyle} leftIcon={<i className="material-icons">account_circle</i>}
leftIcon={<i className="material-icons">account_circle</i>} />
/> <MenuItem
} onTouchTap={(e) => this.handleChange(e, `/app/form/steppers/${this.state.useruuid}`)}
{!loggedUser.anyOf(visitReporter) && primaryText="Book Ride"
<MenuItem innerDivStyle={listItemStyle}
onTouchTap={(e) => this.handleChange(e, `/app/form/steppers/${this.state.useruuid}`)} style={{ fontSize: '14px', lineHeight: '48px' }}
primaryText="Book Ride" leftIcon={<i className="material-icons">mode_edit</i>}
innerDivStyle={listItemStyle} />
style={{ fontSize: '14px', lineHeight: '48px' }}
leftIcon={<i className="material-icons">mode_edit</i>}
/>
}
{loggedUser.anyOf(visitReporter) &&
<MenuItem
onTouchTap={(e) => this.handleChange(e, `/app/form/visit/${this.state.useruuid}`)}
primaryText="Create Visit"
innerDivStyle={listItemStyle}
style={{ fontSize: '14px', lineHeight: '48px' }}
leftIcon={<i className="material-icons">mode_edit</i>}
/>
}
<MenuItem <MenuItem
onTouchTap={(e) => this.handleChange(e, `/login`)} onTouchTap={(e) => this.handleChange(e, `/login`)}
primaryText="Log Out" primaryText="Log Out"

View File

@@ -48,16 +48,14 @@ export class ValidationErrorsInfoDialog extends React.Component {
modal={this.props.modal ? this.props.modal : false} modal={this.props.modal ? this.props.modal : false}
height={defaultDialogHeight + this.props.errorMessages.length * dialogHeightPerLine} height={defaultDialogHeight + this.props.errorMessages.length * dialogHeightPerLine}
> >
{this.props.errorMessages.map(errorMessage=>{ {this.props.errorMessages.map(errorMessage => {
const oneValidationMessage = (<span><a>{errorMessage.message}</a><br /></span>); return (
const oneValidationMessageWithTab = (<span><li style={{marginLeft:2 + "em"}}>{errorMessage.message}</li></span>); <div>
<a>{errorMessage.message}</a>
if (errorMessage.field_name === "password-tab"){ <br/>
return oneValidationMessageWithTab; </div>
} else{ );})
return oneValidationMessage; }
}
})}
</Dialog> </Dialog>
} }
</div> </div>

View File

@@ -35,7 +35,7 @@ import Popover from 'material-ui/Popover';
import ValidationErrorsInfoDialog from '../../../../../../../components/Shared/ValidationErrorsInfoDialog'; import ValidationErrorsInfoDialog from '../../../../../../../components/Shared/ValidationErrorsInfoDialog';
let DateTimeFormat; let DateTimeFormat;
const roundingTime = 1000 * 60 * 5; //5 minutes
DateTimeFormat = global.Intl.DateTimeFormat; DateTimeFormat = global.Intl.DateTimeFormat;
@@ -564,18 +564,16 @@ class VerticalNonLinear extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
let dateNow = new Date();
this.state = { this.state = {
stepIndex: 0, stepIndex: 0,
rideTypeValue: 0, rideTypeValue: 0,
providerID: 0, providerID: 0,
providerName: '', providerName: '',
visitDate: new Date(), visitDate: new Date(),
visitTime: new Date(Math.round(dateNow.getTime() / roundingTime) * roundingTime), visitTime: new Date(),
pickupLocation: null, pickupLocation: null,
pickupTime: new Date(Math.round(dateNow.getTime() / roundingTime) * roundingTime), pickupTime: new Date(),
pickupTimeReturn: new Date(Math.round(dateNow.getTime() / roundingTime) * roundingTime), pickupTimeReturn: new Date(),
pickupTimeReturnDisplayMode: 'none', pickupTimeReturnDisplayMode: 'none',
open: false, open: false,
message: 'Adding Visit', message: 'Adding Visit',
@@ -640,12 +638,10 @@ class VerticalNonLinear extends React.Component {
}); });
} }
let date = new Date(); let visitTime = new Date(new Date().getTime() + (1 * 60 * 60 * 1000));
let visitDate = visitTime;
let visitTime = new Date(Math.round((date.getTime() + (1 * 60 * 60 * 1000)) / roundingTime) * roundingTime); let pickupTime = new Date(visitTime.getTime() - (0.5 * 60 * 60 * 1000));
let visitDate = date; 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);
this.setState(Object.assign(this.state, { this.setState(Object.assign(this.state, {
visitDate: visitDate, visitDate: visitDate,
@@ -772,10 +768,10 @@ class VerticalNonLinear extends React.Component {
handleDate(event, date, state) { handleDate(event, date, state) {
let self = 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 visitDate = date;
let pickupTime = 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(Math.round((visitTime.getTime() - (0.5 * 60 * 60 * 1000)) / roundingTime) * roundingTime); let pickupTimeReturn = new Date(visitTime.getTime() - (0.5 * 60 * 60 * 1000));
self.setState(Object.assign(self.state, { self.setState(Object.assign(self.state, {
visitDate: visitDate, visitDate: visitDate,

View File

@@ -37,8 +37,7 @@ class SignUp extends React.Component {
validated: false, validated: false,
memberType:"S", memberType:"S",
showValidationErrors: false, showValidationErrors: false,
validationErrors:[], validationErrors:[]
draggableDialog:false
} }
componentDidMount = () => { componentDidMount = () => {
@@ -64,8 +63,7 @@ class SignUp extends React.Component {
"phonenumber": this.state.phonenumber, "phonenumber": this.state.phonenumber,
"birthdate": this.state.birthdate.toISOString(), "birthdate": this.state.birthdate.toISOString(),
"consent" : this.state.agreedTerms, "consent" : this.state.agreedTerms,
"type": this.state.memberType, "type": this.state.memberType
"useruuid": "1234567"
// "eligibility": { // "eligibility": {
// "tracking_id": "1234567", // "tracking_id": "1234567",
@@ -107,26 +105,13 @@ class SignUp extends React.Component {
// alert('NO benefits found for this member'); // alert('NO benefits found for this member');
// } // }
}).catch(function (err) { }).catch(function (err) {
switch(err.response.status){ if (err.response.status === 422){
case 403: //Unprocessable Entity (validation failed)
//Forbidden (not eligible) state.setState(Object.assign(state.state, {showValidationErrors:true, validationErrors:err.response.data.data}))
console.log(err.response.data); }else{
let messageArray = [ console.log('Error to get eligibility: ', err);
{ alert('NO benefits found for this member');
message:err.response.data.message this.handleRequestClose();
}
]
state.setState(Object.assign(state.state, {showValidationErrors:true, validationErrors:messageArray, draggableDialog:false}))
break;
case 422:
//Unprocessable Entity (validation failed)
state.setState(Object.assign(state.state, {showValidationErrors:true, validationErrors:err.response.data.data, draggableDialog:true}))
break;
default:
console.log('Error to get eligibility: ', err);
alert('NO benefits found for this member');
this.handleRequestClose();
} }
}); });
} }
@@ -207,7 +192,7 @@ class SignUp extends React.Component {
return ( return (
<form className=""> <form className="">
<fieldset> <fieldset>
<ValidationErrorsInfoDialog open = {this.state.showValidationErrors} errorMessages = {this.state.validationErrors} draggable={this.state.draggableDialog} onDismiss={this.handleValidationErrosDialogDismiss.bind(this)}/> <ValidationErrorsInfoDialog open = {this.state.showValidationErrors} errorMessages = {this.state.validationErrors} draggable={false} modal={true} onDismiss={this.handleValidationErrosDialogDismiss.bind(this)}/>
<div className="form-group"> <div className="form-group">
<TextField <TextField
floatingLabelText="First Name" floatingLabelText="First Name"

View File

@@ -8,11 +8,6 @@ import Dialog from 'material-ui/Dialog';
import Instance from '../../../components/Connection'; import Instance from '../../../components/Connection';
import {
loggedUser,
visitReporter,
} from 'utils/authorization';
class Login extends React.Component { class Login extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
@@ -81,16 +76,9 @@ class Login extends React.Component {
state.setCookie('token', auth.token, auth.valid_time); state.setCookie('token', auth.token, auth.valid_time);
localStorage.setItem('loggedUser', JSON.stringify(auth.user)); localStorage.setItem('loggedUser', JSON.stringify(auth.user));
console.log("...."); Instance.setToken(auth.token);
console.log(loggedUser.anyOf(visitReporter));
if (loggedUser.anyOf(visitReporter)){
location.href = '/#/app/form/visit/' + auth.user.useruuid;
}else{
location.href = '/#/app/table/rides';
}
location.href = '/#/';
}).catch(function (err) { }).catch(function (err) {
state.setState(Object.assign(state.state, { state.setState(Object.assign(state.state, {
message: (err.response.data.message), message: (err.response.data.message),

View File

@@ -17,8 +17,6 @@ import Toggle from 'material-ui/Toggle';
import Snackbar from 'material-ui/Snackbar'; import Snackbar from 'material-ui/Snackbar';
import Instance from '../../../components/Connection'; import Instance from '../../../components/Connection';
import ValidationErrorsInfoDialog from '../../../components/Shared/ValidationErrorsInfoDialog';
class SignUp extends React.Component { class SignUp extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
@@ -146,13 +144,29 @@ class SignUp extends React.Component {
}); });
} }
handleValidationErrosDialogDismiss() { handleDismiss() {
this.setState(Object.assign(this.state, { this.setState(Object.assign(this.state, { showErrorMessage: false }));
showValidationErrors: false
}));
} }
render() { 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 ( return (
<div className="body-inner"> <div className="body-inner">
@@ -231,7 +245,10 @@ class SignUp extends React.Component {
<div className="form-group"> <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> <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>
<ValidationErrorsInfoDialog open={this.state.showValidationErrors} errorMessages={this.state.validationErrors} onDismiss={this.handleValidationErrosDialogDismiss.bind(this)} /> <div className="divider" />
<div className="form-group">
{validationErrors}
</div>
</fieldset> </fieldset>
</form> </form>
</div> </div>