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

View File

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

View File

@@ -35,7 +35,7 @@ import Popover from 'material-ui/Popover';
import ValidationErrorsInfoDialog from '../../../../../../../components/Shared/ValidationErrorsInfoDialog';
let DateTimeFormat;
const roundingTime = 1000 * 60 * 5; //5 minutes
DateTimeFormat = global.Intl.DateTimeFormat;
@@ -564,16 +564,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: 'Adding Visit',
@@ -638,10 +640,12 @@ 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();
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,
@@ -768,10 +772,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,

View File

@@ -37,7 +37,8 @@ class SignUp extends React.Component {
validated: false,
memberType:"S",
showValidationErrors: false,
validationErrors:[]
validationErrors:[],
draggableDialog:false
}
componentDidMount = () => {
@@ -63,7 +64,8 @@ class SignUp extends React.Component {
"phonenumber": this.state.phonenumber,
"birthdate": this.state.birthdate.toISOString(),
"consent" : this.state.agreedTerms,
"type": this.state.memberType
"type": this.state.memberType,
"useruuid": "1234567"
// "eligibility": {
// "tracking_id": "1234567",
@@ -105,13 +107,26 @@ class SignUp extends React.Component {
// alert('NO benefits found for this member');
// }
}).catch(function (err) {
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();
switch(err.response.status){
case 403:
//Forbidden (not eligible)
console.log(err.response.data);
let messageArray = [
{
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 (
<form className="">
<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">
<TextField
floatingLabelText="First Name"

View File

@@ -8,6 +8,11 @@ import Dialog from 'material-ui/Dialog';
import Instance from '../../../components/Connection';
import {
loggedUser,
visitReporter,
} from 'utils/authorization';
class Login extends React.Component {
constructor(props) {
super(props);
@@ -76,9 +81,16 @@ class Login extends React.Component {
state.setCookie('token', auth.token, auth.valid_time);
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) {
state.setState(Object.assign(state.state, {
message: (err.response.data.message),

View File

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