Compare commits

..

16 Commits

Author SHA1 Message Date
GotPPay
3c6f17186e round time on vreate visit page 2018-05-28 18:35:30 +02:00
GotPPay
22d5b32c71 use indentation for list items in error message 2018-05-28 16:26:02 +02:00
GotPPay
d1d5cacddb use draggable dialog 2018-05-28 16:21:12 +02:00
GotPPay
6c0abf2a70 missing brack 2018-05-28 16:12:02 +02:00
GotPPay
4070ca2b29 use existing role checking system 2018-05-28 15:51:30 +02:00
GotPPay
4099c9231a replace form validation messages with dialog 2018-05-28 15:51:30 +02:00
GotPPay
bc888503b2 show error if member is not eligible 2018-05-28 15:50:59 +02:00
GotPPay
8a370c6b30 set mouse cursor to move type in whole dialog 2018-05-28 15:50:38 +02:00
GotPPay
aaed238946 apply material design ; make whole dialog draggable 2018-05-28 15:50:38 +02:00
GotPPay
091055eab0 remove react-dialog as package and include as part of the project 2018-05-28 15:50:38 +02:00
GotPPay
fd1b7e06c1 integrate draggable dialog package 2018-05-28 15:50:38 +02:00
GotPPay
1ed7d8bcec add draggable component 2018-05-28 15:50:38 +02:00
GotPPay
7728262f29 Show validation errors on eligibility check 2018-05-28 15:50:38 +02:00
GotPPay
6ec37630f3 hide profile from top menu and substitute book ride for visit 2018-05-28 15:50:38 +02:00
GotPPay
9d87501112 selective redirect based on auth user role 2018-05-28 15:50:38 +02:00
GotPPay
7e48797bea redirect login to visit page 2018-05-28 15:50:38 +02:00
6 changed files with 104 additions and 69 deletions

View File

@@ -4,6 +4,12 @@ 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'
@@ -48,20 +54,33 @@ class NavRightList extends React.Component {
targetOrigin={{ horizontal: 'right', vertical: 'top' }} targetOrigin={{ horizontal: 'right', vertical: 'top' }}
menuStyle={{ minWidth: '150px' }} menuStyle={{ minWidth: '150px' }}
> >
<MenuItem {!loggedUser.anyOf(visitReporter) &&
onTouchTap={(e) => this.handleChange(e, `/app/authorizedusers/${this.state.useruuid}`)} <MenuItem
primaryText="Profile" onTouchTap={(e) => this.handleChange(e, `/app/authorizedusers/${this.state.useruuid}`)}
style={{ fontSize: '14px', lineHeight: '48px' }} primaryText="Profile"
innerDivStyle={listItemStyle} style={{ fontSize: '14px', lineHeight: '48px' }}
leftIcon={<i className="material-icons">account_circle</i>} innerDivStyle={listItemStyle}
/> leftIcon={<i className="material-icons">account_circle</i>}
<MenuItem />
onTouchTap={(e) => this.handleChange(e, `/app/form/steppers/${this.state.useruuid}`)} }
primaryText="Book Ride" {!loggedUser.anyOf(visitReporter) &&
innerDivStyle={listItemStyle} <MenuItem
style={{ fontSize: '14px', lineHeight: '48px' }} onTouchTap={(e) => this.handleChange(e, `/app/form/steppers/${this.state.useruuid}`)}
leftIcon={<i className="material-icons">mode_edit</i>} primaryText="Book Ride"
/> 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,14 +48,16 @@ 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=>{
return ( const oneValidationMessage = (<span><a>{errorMessage.message}</a><br /></span>);
<div> const oneValidationMessageWithTab = (<span><li style={{marginLeft:2 + "em"}}>{errorMessage.message}</li></span>);
<a>{errorMessage.message}</a>
<br/> if (errorMessage.field_name === "password-tab"){
</div> return oneValidationMessageWithTab;
);}) } 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,16 +564,18 @@ 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(), visitTime: new Date(Math.round(dateNow.getTime() / roundingTime) * roundingTime),
pickupLocation: null, pickupLocation: null,
pickupTime: new Date(), pickupTime: new Date(Math.round(dateNow.getTime() / roundingTime) * roundingTime),
pickupTimeReturn: new Date(), pickupTimeReturn: new Date(Math.round(dateNow.getTime() / roundingTime) * roundingTime),
pickupTimeReturnDisplayMode: 'none', pickupTimeReturnDisplayMode: 'none',
open: false, open: false,
message: 'Adding Visit', message: 'Adding Visit',
@@ -638,10 +640,12 @@ class VerticalNonLinear extends React.Component {
}); });
} }
let visitTime = new Date(new Date().getTime() + (1 * 60 * 60 * 1000)); let date = new Date();
let visitDate = visitTime;
let pickupTime = new Date(visitTime.getTime() - (0.5 * 60 * 60 * 1000)); let visitTime = new Date(Math.round((date.getTime() + (1 * 60 * 60 * 1000)) / roundingTime) * roundingTime);
let pickupTimeReturn = new Date(visitTime.getTime() - (0.5 * 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);
this.setState(Object.assign(this.state, { this.setState(Object.assign(this.state, {
visitDate: visitDate, visitDate: visitDate,
@@ -768,10 +772,10 @@ class VerticalNonLinear extends React.Component {
handleDate(event, date, state) { handleDate(event, date, state) {
let self = 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 visitDate = date;
let pickupTime = 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(visitTime.getTime() - (0.5 * 60 * 60 * 1000)); let pickupTimeReturn = new Date(Math.round((visitTime.getTime() - (0.5 * 60 * 60 * 1000)) / roundingTime) * roundingTime);
self.setState(Object.assign(self.state, { self.setState(Object.assign(self.state, {
visitDate: visitDate, visitDate: visitDate,

View File

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

View File

@@ -8,6 +8,11 @@ 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);
@@ -76,9 +81,16 @@ 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));
Instance.setToken(auth.token); console.log("....");
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,6 +17,8 @@ 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);
@@ -144,29 +146,13 @@ class SignUp extends React.Component {
}); });
} }
handleDismiss() { handleValidationErrosDialogDismiss() {
this.setState(Object.assign(this.state, { showErrorMessage: false })); this.setState(Object.assign(this.state, {
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">
@@ -245,10 +231,7 @@ 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>
<div className="divider" /> <ValidationErrorsInfoDialog open={this.state.showValidationErrors} errorMessages={this.state.validationErrors} onDismiss={this.handleValidationErrosDialogDismiss.bind(this)} />
<div className="form-group">
{validationErrors}
</div>
</fieldset> </fieldset>
</form> </form>
</div> </div>