Compare commits
1 Commits
master
...
eligibilit
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
21e6759a70 |
59
src/components/Shared/ValidationErrorsInfoDialog.js
Normal file
59
src/components/Shared/ValidationErrorsInfoDialog.js
Normal 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;
|
||||||
@@ -30,6 +30,7 @@ import Close from 'material-ui/svg-icons/navigation/close'
|
|||||||
import CommunicationCall from 'material-ui/svg-icons/communication/call'
|
import CommunicationCall from 'material-ui/svg-icons/communication/call'
|
||||||
import Message from 'material-ui/svg-icons/communication/message'
|
import Message from 'material-ui/svg-icons/communication/message'
|
||||||
import Instance from '../../../../../../../components/Connection';
|
import Instance from '../../../../../../../components/Connection';
|
||||||
|
import ValidationErrorsInfoDialog from '../../../../../../../components/Shared/ValidationErrorsInfoDialog';
|
||||||
import Checkbox from 'material-ui/Checkbox';
|
import Checkbox from 'material-ui/Checkbox';
|
||||||
import Popover from 'material-ui/Popover';
|
import Popover from 'material-ui/Popover';
|
||||||
|
|
||||||
@@ -41,60 +42,6 @@ const roundingTime = 1000 * 60 * 5; //5 minutes
|
|||||||
|
|
||||||
DateTimeFormat = global.Intl.DateTimeFormat;
|
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 {
|
export class DialogExampleSimple extends React.Component {
|
||||||
state = {
|
state = {
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import RaisedButton from 'material-ui/RaisedButton';
|
|||||||
import SelectField from 'material-ui/SelectField';
|
import SelectField from 'material-ui/SelectField';
|
||||||
import Checkbox from 'material-ui/Checkbox';
|
import Checkbox from 'material-ui/Checkbox';
|
||||||
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) {
|
||||||
@@ -34,7 +35,9 @@ class SignUp extends React.Component {
|
|||||||
gender: null,
|
gender: null,
|
||||||
agreedTerms: false,
|
agreedTerms: false,
|
||||||
validated: false,
|
validated: false,
|
||||||
memberType:"S"
|
memberType:"S",
|
||||||
|
showValidationErrors: false,
|
||||||
|
validationErrors:[]
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount = () => {
|
componentDidMount = () => {
|
||||||
@@ -58,7 +61,10 @@ class SignUp extends React.Component {
|
|||||||
"member": this.state.member,
|
"member": this.state.member,
|
||||||
"email": this.state.email,
|
"email": this.state.email,
|
||||||
"phonenumber": this.state.phonenumber,
|
"phonenumber": this.state.phonenumber,
|
||||||
"birthdate": this.state.birthdate.toISOString()
|
"birthdate": this.state.birthdate.toISOString(),
|
||||||
|
"consent" : this.state.agreedTerms,
|
||||||
|
"type": this.state.memberType
|
||||||
|
|
||||||
// "eligibility": {
|
// "eligibility": {
|
||||||
// "tracking_id": "1234567",
|
// "tracking_id": "1234567",
|
||||||
// "payer": {
|
// "payer": {
|
||||||
@@ -99,9 +105,14 @@ 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) {
|
||||||
console.log('Error to get eligibility: ', err);
|
if (err.response.status === 422){
|
||||||
alert('NO benefits found for this member');
|
//Unprocessable Entity (validation failed)
|
||||||
this.handleRequestClose();
|
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 }));
|
this.setState(Object.assign(this.state, { validated: validated }));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleValidationErrosDialogDismiss(){
|
||||||
|
this.setState(Object.assign(this.state, {showValidationErrors:false}));
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<form className="">
|
<form className="">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
|
<ValidationErrorsInfoDialog open = {this.state.showValidationErrors} errorMessages = {this.state.validationErrors} modal={true} onDismiss={this.handleValidationErrosDialogDismiss.bind(this)}/>
|
||||||
<div className="form-group">
|
<div className="form-group">
|
||||||
<TextField
|
<TextField
|
||||||
floatingLabelText="First Name"
|
floatingLabelText="First Name"
|
||||||
|
|||||||
Reference in New Issue
Block a user