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 { hashHistory } from 'react-router';
import {
loggedUser,
visitReporter,
} from 'utils/authorization';
const ImgIconButtonStyle = {
width: '60px',
height: '60px'
@@ -54,33 +48,20 @@ class NavRightList extends React.Component {
targetOrigin={{ horizontal: 'right', vertical: 'top' }}
menuStyle={{ minWidth: '150px' }}
>
{!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, `/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>}
/>
<MenuItem
onTouchTap={(e) => this.handleChange(e, `/login`)}
primaryText="Log Out"

View File

@@ -48,16 +48,14 @@ 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=>{
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;
}
})}
{this.props.errorMessages.map(errorMessage => {
return (
<div>
<a>{errorMessage.message}</a>
<br/>
</div>
);})
}
</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,18 +564,16 @@ 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(Math.round(dateNow.getTime() / roundingTime) * roundingTime),
visitTime: new Date(),
pickupLocation: null,
pickupTime: new Date(Math.round(dateNow.getTime() / roundingTime) * roundingTime),
pickupTimeReturn: new Date(Math.round(dateNow.getTime() / roundingTime) * roundingTime),
pickupTime: new Date(),
pickupTimeReturn: new Date(),
pickupTimeReturnDisplayMode: 'none',
open: false,
message: 'Adding Visit',
@@ -640,12 +638,10 @@ class VerticalNonLinear extends React.Component {
});
}
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);
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,
@@ -772,10 +768,10 @@ class VerticalNonLinear extends React.Component {
handleDate(event, date, 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 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);
let pickupTime = new Date(visitTime.getTime() - (0.5 * 60 * 60 * 1000));
let pickupTimeReturn = new Date(visitTime.getTime() - (0.5 * 60 * 60 * 1000));
self.setState(Object.assign(self.state, {
visitDate: visitDate,

View File

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

View File

@@ -8,11 +8,6 @@ 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);
@@ -81,16 +76,9 @@ class Login extends React.Component {
state.setCookie('token', auth.token, auth.valid_time);
localStorage.setItem('loggedUser', JSON.stringify(auth.user));
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';
}
Instance.setToken(auth.token);
location.href = '/#/';
}).catch(function (err) {
state.setState(Object.assign(state.state, {
message: (err.response.data.message),

View File

@@ -17,8 +17,6 @@ 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);
@@ -146,13 +144,29 @@ class SignUp extends React.Component {
});
}
handleValidationErrosDialogDismiss() {
this.setState(Object.assign(this.state, {
showValidationErrors: false
}));
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">
@@ -231,7 +245,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>
<ValidationErrorsInfoDialog open={this.state.showValidationErrors} errorMessages={this.state.validationErrors} onDismiss={this.handleValidationErrosDialogDismiss.bind(this)} />
<div className="divider" />
<div className="form-group">
{validationErrors}
</div>
</fieldset>
</form>
</div>