Compare commits
6 Commits
merge-28-5
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d4bd965365 | ||
|
|
bf3f372ab4 | ||
|
|
182cde9fbb | ||
|
|
04debaf3e9 | ||
|
|
8e52651172 | ||
|
|
3969863cbf |
863
package-lock.json
generated
863
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -57,18 +57,22 @@
|
||||
"react": "^15.5.4",
|
||||
"react-cookie": "^2.1.2",
|
||||
"react-data-components": "^1.1.1",
|
||||
"react-dialog": "^1.0.2",
|
||||
"react-dom": "^15.5.4",
|
||||
"react-draggable": "^3.0.5",
|
||||
"react-draggable": "^2.2.6",
|
||||
"react-geosuggest": "^2.5.0",
|
||||
"react-geosuggest-sw": "^1.4.13",
|
||||
"react-google-maps": "^7.2.0",
|
||||
"react-helmet": "^5.1.3",
|
||||
"react-hot-loader": "^3.0.0-beta.6",
|
||||
"react-imgix": "^7.1.1",
|
||||
"react-input-mask": "^2.0.1",
|
||||
"react-jquery-datatables": "^0.7.1",
|
||||
"react-materialui-notifications": "^0.5.1",
|
||||
"react-onclickoutside": "^5.10.0",
|
||||
"react-places-autocomplete": "^5.4.2",
|
||||
"react-redux": "^5.0.5",
|
||||
"react-resizable": "^1.7.1",
|
||||
"react-router": "^3.0.4",
|
||||
"react-router-redux": "^4.0.8",
|
||||
"react-tap-event-plugin": "^2.0.1",
|
||||
|
||||
@@ -8,6 +8,10 @@ import { Router, hashHistory, browserHistory } from 'react-router';
|
||||
import { syncHistoryWithStore, routerMiddleware } from 'react-router-redux';
|
||||
import reducers from './reducers';
|
||||
import Instance from './components/Connection';
|
||||
import {
|
||||
loggedUser,
|
||||
visitReporter,
|
||||
} from 'utils/authorization';
|
||||
|
||||
const middleware = routerMiddleware(hashHistory);
|
||||
const store = createStore(
|
||||
@@ -29,8 +33,8 @@ const isFunction = (functionToCheck) => {
|
||||
};
|
||||
|
||||
const requireAuth = (nextState, replace, next) => {
|
||||
if (nextState.location.pathname === '/login' || nextState.location.pathname === '/sign-up' || nextState.location.pathname === '/selfRegister' || (nextState.location.pathname.indexOf('/ride') > -1 && nextState.params.ride_uuid !== undefined && nextState.params.user_uuid !== undefined)
|
||||
|| (!isFunction(replace) && (replace.location.pathname === '/login' || replace.location.pathname === '/sign-up' || nextState.location.pathname === '/selfRegister' || (replace.location.pathname.indexOf('/ride') > -1 && replace.params.ride_uuid !== undefined && replace.params.user_uuid !== undefined)))) {
|
||||
if (nextState.location.pathname === '/login' || nextState.location.pathname === '/sign-up' || nextState.location.pathname.toLowerCase() === '/selfregister' || (nextState.location.pathname.indexOf('/ride') > -1 && nextState.params.ride_uuid !== undefined && nextState.params.user_uuid !== undefined)
|
||||
|| (!isFunction(replace) && (replace.location.pathname === '/login' || replace.location.pathname === '/sign-up' || nextState.location.pathname.toLowerCase() === '/selfRegister' || (replace.location.pathname.indexOf('/ride') > -1 && replace.params.ride_uuid !== undefined && replace.params.user_uuid !== undefined)))) {
|
||||
next();
|
||||
}
|
||||
|
||||
@@ -55,7 +59,15 @@ const rootRoute = {
|
||||
onChange: requireAuth,
|
||||
onEnter: requireAuth,
|
||||
component: require('./containers/App'),
|
||||
indexRoute: { onEnter: (nextState, replace) => replace('/app/table/rides') },
|
||||
indexRoute: {
|
||||
onEnter: (nextState, replace) => {
|
||||
if (loggedUser.anyOf(visitReporter)) {
|
||||
replace('/app/form/visit/' + loggedUser.useruuid)
|
||||
} else {
|
||||
replace('/app/table/rides');
|
||||
}
|
||||
}
|
||||
},
|
||||
childRoutes: [
|
||||
require('./routes/app'),
|
||||
require('./routes/404'),
|
||||
|
||||
@@ -6,6 +6,9 @@ const Instance = () => {
|
||||
const apiUrl = process.env.NODE_ENV === 'production'
|
||||
? 'https://portal-api.bcbsinstitute.com'
|
||||
: 'https://portal-api.dev.bcbsinstitute.com';
|
||||
|
||||
// const apiUrl = 'http://localhost:5100';
|
||||
|
||||
window.localStorage.setItem('App', '8a266a40-ed2e-4be2-bdfc-459a507bf02e');
|
||||
|
||||
let instance = axios.create({
|
||||
@@ -61,11 +64,25 @@ const Instance = () => {
|
||||
return setToken(token);
|
||||
};
|
||||
|
||||
const getAPIUrl = (url) => {
|
||||
if (!url) {
|
||||
return instance;
|
||||
} else {
|
||||
const token = getCookie('token');
|
||||
return axios.create({
|
||||
baseURL: url,
|
||||
timeout: 60000,
|
||||
headers: { App: window.localStorage.getItem('App'), Token: `Bearer ${token}`, Token: `Bearer ${token}` },
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const getRawConn = () => {
|
||||
const token = getCookie('token');
|
||||
if (token && token !== null && token !== '') {
|
||||
return instance;
|
||||
}
|
||||
|
||||
window.location.href = '/#/login';
|
||||
return null;
|
||||
};
|
||||
@@ -80,6 +97,7 @@ const Instance = () => {
|
||||
getConnection,
|
||||
setToken,
|
||||
getRawConn,
|
||||
getAPIUrl,
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -4,6 +4,13 @@ import MenuItem from 'material-ui/MenuItem';
|
||||
import IconButton from 'material-ui/IconButton/IconButton';
|
||||
import { hashHistory } from 'react-router';
|
||||
|
||||
import {
|
||||
loggedUser,
|
||||
planScheduler,
|
||||
providerScheduler,
|
||||
visitReporter,
|
||||
} from 'utils/authorization';
|
||||
|
||||
const ImgIconButtonStyle = {
|
||||
width: '60px',
|
||||
height: '60px'
|
||||
@@ -28,6 +35,7 @@ class NavRightList extends React.Component {
|
||||
handleChange = (event, value) => {
|
||||
hashHistory.push(value);
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
const user = JSON.parse(localStorage.getItem('loggedUser'));
|
||||
if (user) {
|
||||
@@ -40,6 +48,8 @@ class NavRightList extends React.Component {
|
||||
<ul className="list-unstyled float-right">
|
||||
<li>
|
||||
|
||||
|
||||
|
||||
<IconMenu
|
||||
|
||||
iconButtonElement={<IconButton style={ImgIconButtonStyle}><img src="assets/images/ic_account_circle_white_48dp_1x.png" alt="" className="rounded-circle img30_30" /></IconButton>}
|
||||
@@ -48,20 +58,35 @@ 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/visit/${this.state.useruuid}`)}
|
||||
primaryText="Create Visit"
|
||||
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/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"
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
import React, { Component } from 'react';
|
||||
import Dialog from 'material-ui/Dialog';
|
||||
import FlatButton from 'material-ui/FlatButton';
|
||||
import MaterialDialog from 'material-ui/Dialog';
|
||||
import Dialog from './draggable-dialog';
|
||||
|
||||
import './draggable-dialog/css/index.css';
|
||||
|
||||
const defaultDialogHeight = 100; //px
|
||||
const dialogHeightPerLine = 25; //px
|
||||
|
||||
export class ValidationErrorsInfoDialog extends React.Component {
|
||||
constructor(props) {
|
||||
@@ -8,11 +14,17 @@ export class ValidationErrorsInfoDialog extends React.Component {
|
||||
this.props = props;
|
||||
this.state = {
|
||||
open: this.props.open,
|
||||
title: "Errors",
|
||||
}
|
||||
}
|
||||
|
||||
componentWillReceiveProps(newProps) {
|
||||
this.setState({ open: newProps.open });
|
||||
let title = this.state.title;
|
||||
if (newProps.errorTitle) {
|
||||
title = newProps.errorTitle;
|
||||
}
|
||||
|
||||
this.setState({ open: newProps.open, title: title });
|
||||
}
|
||||
|
||||
handleOpen = () => {
|
||||
@@ -30,33 +42,56 @@ export class ValidationErrorsInfoDialog extends React.Component {
|
||||
<FlatButton
|
||||
label="Dismiss"
|
||||
primary={true}
|
||||
keyboardFocused={true}
|
||||
onClick={this.handleClose}
|
||||
/>,
|
||||
];
|
||||
|
||||
const dialogContent = (
|
||||
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;
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
const draggableDialog =
|
||||
(<Dialog
|
||||
title={this.props.title ? this.props.title : 'Error'}
|
||||
isDraggable={true}
|
||||
buttons={actions}
|
||||
hasCloseIcon={false}
|
||||
modal={this.props.modal ? this.props.modal : false}
|
||||
height={defaultDialogHeight + this.props.errorMessages.length * dialogHeightPerLine}>
|
||||
|
||||
{dialogContent}
|
||||
|
||||
</Dialog>
|
||||
)
|
||||
|
||||
const normalDialog =
|
||||
(<MaterialDialog
|
||||
open={this.state.open}
|
||||
title={this.props.title ? this.props.title : 'Error'}
|
||||
onBackdropClick={()=>{console.log("Backdrop")}}
|
||||
actions={actions}>
|
||||
|
||||
{dialogContent}
|
||||
|
||||
</MaterialDialog>
|
||||
)
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Dialog
|
||||
title="Errors"
|
||||
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 className="container">
|
||||
{this.state.open && this.props.draggable && draggableDialog }
|
||||
{this.state.open && !this.props.draggable && normalDialog}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ValidationErrorsInfoDialog;
|
||||
module.exports = ValidationErrorsInfoDialog;
|
||||
|
||||
18
src/components/Shared/draggable-dialog/DialogBody.js
Normal file
18
src/components/Shared/draggable-dialog/DialogBody.js
Normal file
@@ -0,0 +1,18 @@
|
||||
import React from "react";
|
||||
import PropTypes from "prop-types";
|
||||
|
||||
class DialogBody extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<div className="ui-dialog-content" style={{ "overflowY": "auto" }}>
|
||||
{this.props.children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
DialogBody.propTypes = {
|
||||
children: PropTypes.oneOfType([PropTypes.array, PropTypes.object])
|
||||
};
|
||||
|
||||
export default DialogBody;
|
||||
43
src/components/Shared/draggable-dialog/DialogFooter.js
Normal file
43
src/components/Shared/draggable-dialog/DialogFooter.js
Normal file
@@ -0,0 +1,43 @@
|
||||
import React from "react";
|
||||
import PropTypes from "prop-types";
|
||||
import cs from "classnames";
|
||||
|
||||
const DialogFooter = (props) => {
|
||||
const buttons = props.buttons;
|
||||
if (!buttons || buttons.length == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const dialogButtons = buttons.map(function (button, index) {
|
||||
if (React.isValidElement(button)) {
|
||||
return button;
|
||||
}
|
||||
|
||||
const { text, onClick, className } = button;
|
||||
|
||||
return (
|
||||
<button
|
||||
key={`button-${index}`}
|
||||
type="button"
|
||||
className={cs("button", className)}
|
||||
onClick={onClick}>
|
||||
{text}
|
||||
</button>
|
||||
);
|
||||
}, this);
|
||||
|
||||
return (
|
||||
<div className="ui-dialog-buttonpane">
|
||||
<div className="ui-dialog-buttonset">
|
||||
{dialogButtons}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
DialogFooter.propTypes = {
|
||||
buttons: PropTypes.array,
|
||||
onClose: PropTypes.func.isRequired
|
||||
};
|
||||
|
||||
export default DialogFooter;
|
||||
65
src/components/Shared/draggable-dialog/DialogTitle.js
Normal file
65
src/components/Shared/draggable-dialog/DialogTitle.js
Normal file
@@ -0,0 +1,65 @@
|
||||
import React from "react";
|
||||
import PropTypes from "prop-types";
|
||||
|
||||
const DialogTitle = ({ title, hasCloseIcon, onClose, allowMinimize, isMinimized, onMinimize, allowMaximize, isMaximized, onMaximize, onRestore }) => {
|
||||
let closeIcon;
|
||||
if (hasCloseIcon !== false) {
|
||||
closeIcon = (
|
||||
<i className="icon icon-close" onClick={onClose}></i>
|
||||
);
|
||||
}
|
||||
|
||||
let minimizeIcon;
|
||||
if (allowMinimize) {
|
||||
if (isMinimized) {
|
||||
minimizeIcon = (
|
||||
<i className="icon icon-restore" onClick={onRestore}></i>
|
||||
);
|
||||
} else {
|
||||
minimizeIcon = (
|
||||
<i className="icon icon-minimize" onClick={onMinimize}></i>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
let maximizeIcon;
|
||||
if (allowMaximize) {
|
||||
if (isMaximized) {
|
||||
maximizeIcon = (
|
||||
<i className="icon icon-restore" onClick={onRestore}></i>
|
||||
);
|
||||
} else {
|
||||
maximizeIcon = (
|
||||
<i className="icon icon-maximize" onClick={onMaximize}></i>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<header className="ui-dialog-titlebar">
|
||||
<div className="title">
|
||||
{title}
|
||||
</div>
|
||||
<div className="action-items">
|
||||
{minimizeIcon}
|
||||
{maximizeIcon}
|
||||
{closeIcon}
|
||||
</div>
|
||||
</header>
|
||||
);
|
||||
};
|
||||
|
||||
DialogTitle.propTypes = {
|
||||
hasCloseIcon: PropTypes.bool,
|
||||
allowMinimize: PropTypes.bool,
|
||||
allowMaximize: PropTypes.bool,
|
||||
isMinimized: PropTypes.bool,
|
||||
isMaximized: PropTypes.bool,
|
||||
title: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
|
||||
onClose: PropTypes.func.isRequired,
|
||||
onMinimize: PropTypes.func,
|
||||
onMaximize: PropTypes.func,
|
||||
onRestore: PropTypes.func
|
||||
};
|
||||
|
||||
export default DialogTitle;
|
||||
BIN
src/components/Shared/draggable-dialog/css/img/close.png
Normal file
BIN
src/components/Shared/draggable-dialog/css/img/close.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 403 B |
BIN
src/components/Shared/draggable-dialog/css/img/maximize.png
Normal file
BIN
src/components/Shared/draggable-dialog/css/img/maximize.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 310 B |
BIN
src/components/Shared/draggable-dialog/css/img/minimize.png
Normal file
BIN
src/components/Shared/draggable-dialog/css/img/minimize.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 156 B |
BIN
src/components/Shared/draggable-dialog/css/img/restore.png
Normal file
BIN
src/components/Shared/draggable-dialog/css/img/restore.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 300 B |
167
src/components/Shared/draggable-dialog/css/index.css
Normal file
167
src/components/Shared/draggable-dialog/css/index.css
Normal file
@@ -0,0 +1,167 @@
|
||||
body {
|
||||
width: 100%;
|
||||
min-height: 700px;
|
||||
}
|
||||
|
||||
a {
|
||||
cursor: pointer;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.ui-dialog-overlay {
|
||||
background: #aaaaaa;
|
||||
opacity: .3;
|
||||
filter: Alpha(Opacity=30);
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
.ui-dialog {
|
||||
position: fixed;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
outline: 0 none;
|
||||
padding: 0 !important;;
|
||||
z-index: 101;
|
||||
background-color: white;
|
||||
border: 1px solid #f6f6f6;
|
||||
}
|
||||
|
||||
.ui-dialog.maximized{
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100% !important;
|
||||
height: 100% !important;
|
||||
}
|
||||
|
||||
.ui-dialog.minimized{
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
}
|
||||
|
||||
.ui-dialog .ui-dialog-titlebar {
|
||||
position: relative;
|
||||
font-size: 1em;
|
||||
border-radius: 3px;
|
||||
padding: 0.5em;
|
||||
height: 35px;
|
||||
/*border-bottom: 1px solid #f6f6f6;*/
|
||||
}
|
||||
|
||||
.ui-dialog.react-draggable .ui-dialog-titlebar{
|
||||
cursor: move;
|
||||
}
|
||||
|
||||
.ui-dialog.react-draggable .ui-dialog-content{
|
||||
cursor: move;
|
||||
}
|
||||
|
||||
.ui-dialog.react-draggable .ui-dialog-buttonpane {
|
||||
cursor: move;
|
||||
}
|
||||
|
||||
|
||||
.ui-dialog .ui-dialog-titlebar .action-items {
|
||||
float: right;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.ui-dialog .ui-dialog-titlebar .title {
|
||||
float: left;
|
||||
margin-right: .5em;
|
||||
font-family: "Roboto", "Helvetica", "Arial", sans-serif;
|
||||
font-size: 1.3125em;
|
||||
font-weight: 500;
|
||||
line-height: 0.2em;
|
||||
padding : 24px 0px 0px 19px;
|
||||
}
|
||||
|
||||
.icon {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
display: block;
|
||||
float: left;
|
||||
margin: 5px;
|
||||
cursor: pointer;
|
||||
background-size: cover;
|
||||
}
|
||||
|
||||
.icon.icon-close {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
background-image: url("./img/close.png");
|
||||
}
|
||||
|
||||
.icon.icon-minimize {
|
||||
background-image: url("./img/minimize.png");
|
||||
}
|
||||
|
||||
.icon.icon-maximize {
|
||||
background-image: url("./img/maximize.png");
|
||||
}
|
||||
|
||||
.icon.icon-restore {
|
||||
background-image: url("./img/restore.png");
|
||||
}
|
||||
|
||||
.ui-dialog .ui-dialog-content {
|
||||
background: none repeat scroll 0 0 transparent;
|
||||
border: 0 none;
|
||||
overflow: auto;
|
||||
position: relative;
|
||||
font-size: 1rem;
|
||||
font-weight: 400;
|
||||
font-family: "Roboto", "Helvetica", "Arial", sans-serif;
|
||||
line-height: 1.5em;
|
||||
color:rgba(0, 0, 0, 0.54);
|
||||
padding : 24px 24px 24px 24px;
|
||||
}
|
||||
|
||||
.ui-dialog .ui-dialog-buttonpane {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
bottom: 0;
|
||||
text-align: right;
|
||||
border-width: 1px 0 0 0;
|
||||
/*border-top: 1px solid #f6f6f6;*/
|
||||
}
|
||||
|
||||
.ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset{
|
||||
padding: 0.5em;
|
||||
}
|
||||
|
||||
.ui-dialog .ui-dialog-buttonpane button {
|
||||
margin: 0 .5em 0 .5em;
|
||||
cursor: pointer;
|
||||
background-color: #f6f6f6;
|
||||
padding: 0.5em 1em;
|
||||
outline: none;
|
||||
border: 1px solid #CCCCCC;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.ui-dialog .ui-dialog-buttonpane button:hover{
|
||||
background-color: #CCCCCC;
|
||||
border: 1px solid #BBBBBB;
|
||||
}
|
||||
|
||||
.ui-dialog .react-resizable-handle {
|
||||
position: absolute;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
background: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA2IDYiIHN0eWxlPSJiYWNrZ3JvdW5kLWNvbG9yOiNmZmZmZmYwMCIgeD0iMHB4IiB5PSIwcHgiIHdpZHRoPSI2cHgiIGhlaWdodD0iNnB4Ij48ZyBvcGFjaXR5PSIwLjMwMiI+PHBhdGggZD0iTSA2IDYgTCAwIDYgTCAwIDQuMiBMIDQgNC4yIEwgNC4yIDQuMiBMIDQuMiAwIEwgNiAwIEwgNiA2IEwgNiA2IFoiIGZpbGw9IiMwMDAwMDAiLz48L2c+PC9zdmc+');
|
||||
background-position: bottom right;
|
||||
padding: 0 3px 3px 0;
|
||||
background-repeat: no-repeat;
|
||||
background-origin: content-box;
|
||||
box-sizing: border-box;
|
||||
cursor: se-resize;
|
||||
}
|
||||
171
src/components/Shared/draggable-dialog/index.js
Normal file
171
src/components/Shared/draggable-dialog/index.js
Normal file
@@ -0,0 +1,171 @@
|
||||
import React from "react";
|
||||
import PropTypes from "prop-types";
|
||||
import cs from "classnames";
|
||||
import Draggable from "react-draggable";
|
||||
import { Resizable } from "react-resizable";
|
||||
import DialogTitle from "./DialogTitle";
|
||||
import DialogBody from "./DialogBody";
|
||||
import DialogFooter from "./DialogFooter";
|
||||
import EventStack from "active-event-stack";
|
||||
|
||||
class Dialog extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
height: props.height,
|
||||
width: props.width,
|
||||
isMinimized: false,
|
||||
isMaximized: false
|
||||
};
|
||||
}
|
||||
|
||||
componentWillMount() {
|
||||
/**
|
||||
* This is done in the componentWillMount instead of the componentDidMount
|
||||
* because this way, a modal that is a child of another will have register
|
||||
* for events after its parent
|
||||
*/
|
||||
this.eventToken = EventStack.addListenable([
|
||||
["keydown", this.handleGlobalKeydown]
|
||||
]);
|
||||
}
|
||||
|
||||
componentWillUnmount = () => {
|
||||
EventStack.removeListenable(this.eventToken);
|
||||
}
|
||||
|
||||
handleGlobalKeydown = (e) => {
|
||||
if (this.props.closeOnEscape && e.keyCode == 27) {
|
||||
e.stopPropagation();
|
||||
this.onClose();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
onClose = () => {
|
||||
if (this.props.onClose) {
|
||||
this.props.onClose();
|
||||
}
|
||||
}
|
||||
|
||||
onMinimize = () => {
|
||||
this.setState({ isMinimized: true, isMaximized: false });
|
||||
}
|
||||
|
||||
onMaximize = () => {
|
||||
this.setState({ isMinimized: false, isMaximized: true });
|
||||
}
|
||||
|
||||
onRestore = () => {
|
||||
this.setState({ isMinimized: false, isMaximized: false });
|
||||
}
|
||||
|
||||
onResize = (event, { element, size }) => {
|
||||
this.setState({ width: size.width, height: size.height });
|
||||
}
|
||||
|
||||
getDialogTitle = () => {
|
||||
return (
|
||||
<DialogTitle
|
||||
title={this.props.title}
|
||||
hasCloseIcon={this.props.hasCloseIcon}
|
||||
allowMinimize={this.props.allowMinimize}
|
||||
allowMaximize={this.props.allowMaximize}
|
||||
isMinimized={this.state.isMinimized}
|
||||
isMaximized={this.state.isMaximized}
|
||||
onMinimize={this.onMinimize}
|
||||
onMaximize={this.onMaximize}
|
||||
onRestore={this.onRestore}
|
||||
onClose={this.onClose}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
render() {
|
||||
const { height, width, isMinimized, isMaximized } = this.state;
|
||||
const { modal, isDraggable, isResizable, buttons, children, position } = this.props;
|
||||
const { x = -width / 2, y = -height / 2 } = position;
|
||||
|
||||
let dialog = (
|
||||
<div style={{ height: height, width, transform: `translate(${x}px, ${y}px)` }} className={cs("ui-dialog", { "minimized": isMinimized, "maximized": isMaximized })}>
|
||||
{this.getDialogTitle()}
|
||||
{
|
||||
!isMinimized && <DialogBody>{children}</DialogBody>
|
||||
}
|
||||
{
|
||||
!isMinimized && <DialogFooter buttons={buttons} onClose={this.onClose}></DialogFooter>
|
||||
}
|
||||
|
||||
</div>
|
||||
);
|
||||
|
||||
if (!isMinimized && !isMaximized && isResizable) {
|
||||
dialog = (
|
||||
<Resizable className="box" height={height} width={width} onResize={this.onResize}>
|
||||
{dialog}
|
||||
</Resizable>
|
||||
);
|
||||
}
|
||||
|
||||
if (!isMinimized && !isMaximized && isDraggable !== false) {
|
||||
dialog = (
|
||||
<Draggable handle=".ui-dialog" bounds="body" defaultPosition={{ x, y }}>
|
||||
{dialog}
|
||||
</Draggable>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
className={cs("ui-dialog-container", { "": modal })}>
|
||||
{dialog}
|
||||
{modal && <div className="ui-dialog-overlay"></div>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Dialog.propTypes = {
|
||||
height: PropTypes.number,
|
||||
width: PropTypes.number,
|
||||
modal: PropTypes.bool,
|
||||
position: PropTypes.shape({
|
||||
x: PropTypes.number,
|
||||
y: PropTypes.number
|
||||
}),
|
||||
hasCloseIcon: PropTypes.bool,
|
||||
allowMinimize: PropTypes.bool,
|
||||
allowMaximize: PropTypes.bool,
|
||||
isResizable: PropTypes.bool,
|
||||
title: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
|
||||
closeOnEscape: PropTypes.bool,
|
||||
onClose: PropTypes.func,
|
||||
children: PropTypes.oneOfType([PropTypes.string, PropTypes.array, PropTypes.element]).isRequired,
|
||||
buttons: PropTypes.oneOfType([
|
||||
PropTypes.arrayOf(PropTypes.shape({
|
||||
text: PropTypes.string,
|
||||
onClick: PropTypes.func
|
||||
})),
|
||||
PropTypes.arrayOf(PropTypes.element)
|
||||
])
|
||||
};
|
||||
|
||||
Dialog.defaultProps = {
|
||||
height: 200,
|
||||
width: 600,
|
||||
modal: false,
|
||||
closeOnEscape: true,
|
||||
isDraggable: false,
|
||||
isResizable: false,
|
||||
title: '',
|
||||
hasCloseIcon: true,
|
||||
allowMinimize: false,
|
||||
allowMaximize: false,
|
||||
onClose: null,
|
||||
buttons: null,
|
||||
position: { x: -250, y: -150 }
|
||||
};
|
||||
|
||||
export default Dialog;
|
||||
@@ -102,9 +102,17 @@ class SidebarContent extends React.Component {
|
||||
return (
|
||||
<ul className="nav" ref={(c) => { this.nav = c; }}>
|
||||
{loggedUser.anyOf(visitReporter) &&
|
||||
<li><FlatButton className="prepend-icon" href={"#/app/form/visit/" + this.state.user.useruuid}><span>Create Visit</span></FlatButton></li>
|
||||
<li>
|
||||
<FlatButton href="#/app/chart"><i className="nav-icon material-icons">schedule</i><span className="nav-text">Visits</span></FlatButton>
|
||||
<ul>
|
||||
<li><FlatButton className="prepend-icon" href={"#/app/form/visit/" + this.state.user.useruuid}><span>Add Visit</span></FlatButton></li>
|
||||
</ul>
|
||||
</li>
|
||||
}
|
||||
|
||||
|
||||
{!loggedUser.anyOf(visitReporter) &&
|
||||
|
||||
<li>
|
||||
<FlatButton href="#/app/form"><i className="nav-icon material-icons cyan-text text-lighter-4">directions_car</i><span className="nav-text">Rides</span></FlatButton>
|
||||
<ul>
|
||||
@@ -158,6 +166,8 @@ class SidebarContent extends React.Component {
|
||||
}
|
||||
|
||||
<li className="nav-divider" />
|
||||
<li><FlatButton className="prepend-icon" href={"#/login"}><span>Log Out</span></FlatButton></li>
|
||||
|
||||
</ul>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,10 @@ import Footer from 'components/Footer';
|
||||
import Notifications from 'components/Notifications';
|
||||
import Notification from 'components/Shared/Notification';
|
||||
import GeolocationService from './Geolocation';
|
||||
import {
|
||||
loggedUser,
|
||||
visitReporter,
|
||||
} from 'utils/authorization';
|
||||
|
||||
class MainApp extends React.Component {
|
||||
constructor(props) {
|
||||
@@ -53,8 +57,9 @@ class MainApp extends React.Component {
|
||||
<Footer />
|
||||
</div>
|
||||
</section>
|
||||
<Notifications user={this.state.user} onRideUpdate={this.handleRide} />
|
||||
{/* <Notification user={this.state.user} onRideUpdate={this.handleRide} /> */}
|
||||
{!loggedUser.anyOf(visitReporter) &&
|
||||
<Notifications user={this.state.user} onRideUpdate={this.handleRide} />
|
||||
}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -151,7 +151,9 @@ export class NEMTLocation extends React.Component {
|
||||
long: 0,
|
||||
name: '',
|
||||
address: '',
|
||||
}
|
||||
},
|
||||
searchingProvider: false,
|
||||
providerList: [],
|
||||
}
|
||||
|
||||
this.addCustomLabel = this.addCustomLabel.bind(this);
|
||||
@@ -205,7 +207,7 @@ export class NEMTLocation extends React.Component {
|
||||
long = geo.long;
|
||||
}
|
||||
|
||||
if (lat === 0 || long === 0) {
|
||||
if ((lat === undefined || long === undefined) || (lat === 0 || long === 0)) {
|
||||
lat = 41.886406;
|
||||
long = -87.624225;
|
||||
}
|
||||
@@ -214,8 +216,8 @@ export class NEMTLocation extends React.Component {
|
||||
}
|
||||
|
||||
locateNearby = (lat, long) => {
|
||||
|
||||
if (lat === 0 || long === 0) {
|
||||
this.setState(Object.assign(this.state, { nearbyPlaces: [], providers: [], providerList: [] }));
|
||||
if ((lat === undefined || long === undefined) || (lat === 0 || long === 0)) {
|
||||
lat = 41.886406;
|
||||
long = -87.624225;
|
||||
}
|
||||
@@ -257,7 +259,7 @@ export class NEMTLocation extends React.Component {
|
||||
return p;
|
||||
});
|
||||
|
||||
this.setState(Object.assign(this.state, { nearbyPlaces: nearByPlaces, providers: providers }));
|
||||
this.setState(Object.assign(this.state, { nearbyPlaces: nearByPlaces, providers: providers, providerList: nearByPlaces }));
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@@ -336,14 +338,14 @@ export class NEMTLocation extends React.Component {
|
||||
self.props.onPlaceChanged(name);
|
||||
}
|
||||
|
||||
self.locateNearby(name.lat, name.lng);
|
||||
//self.locateNearby(name.lat, name.lng);
|
||||
|
||||
let buttonText = name.name;
|
||||
if (buttonText.length > self.state.textSize) {
|
||||
buttonText = buttonText.substring(0, self.state.textSize);
|
||||
buttonText += '...';
|
||||
}
|
||||
self.setState(Object.assign(self.state, { buttonValue: buttonText, inputValue: name.address }));
|
||||
self.setState(Object.assign(self.state, { buttonValue: buttonText, inputValue: name.name, searchingProvider: false, providerList: [] }));
|
||||
}).catch(console.error);
|
||||
}
|
||||
|
||||
@@ -402,6 +404,16 @@ export class NEMTLocation extends React.Component {
|
||||
objConf.currentSelection = objConf.address
|
||||
objConf.buttonValue = objConf.address.name
|
||||
objConf.inputValue = objConf.address.name
|
||||
|
||||
// let centerLocation = this.state.centerLocation;
|
||||
// if ((centerLocation.lat === undefined || centerLocation.long === undefined) || (centerLocation.lat === 0 || centerLocation.long === 0)) {
|
||||
// objConf.centerLocation = objConf.address
|
||||
// objConf.locationValue = objConf.address.name
|
||||
|
||||
// if (objConf.address.lat !== 0 && objConf.address.lng !== 0) {
|
||||
// this.locateNearby(objConf.address.lat, objConf.address.lng)
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
if (!objConf.buttonValue) {
|
||||
@@ -413,16 +425,6 @@ export class NEMTLocation extends React.Component {
|
||||
objConf.buttonValue += '...';
|
||||
}
|
||||
|
||||
// if (self.state.user.useruuid === '') {
|
||||
// if (objConf.data.user && objConf.data.user !== null && objConf.data.user.useruuid !== '') {
|
||||
// let url = `/v1/nemt/users/member/` + objConf.data.user.useruuid
|
||||
// instance.get(url).then(res => {
|
||||
// let user = res.data;
|
||||
// self.setState(Object.assign(self.state, { user: user }));
|
||||
// }).catch(console.error);
|
||||
// }
|
||||
// }
|
||||
|
||||
this.setState(Object.assign(this.state, objConf));
|
||||
|
||||
if (this.state.type === "flat") {
|
||||
@@ -465,13 +467,13 @@ export class NEMTLocation extends React.Component {
|
||||
objConf.buttonValue += '...';
|
||||
}
|
||||
|
||||
// if (self.state.user.useruuid === '' || self.state.user.useruuid !== objConf.data.user.useruuid) {
|
||||
// if (objConf.data.user && objConf.data.user !== null && objConf.data.user.useruuid !== '') {
|
||||
// let url = `/v1/nemt/users/member/` + objConf.data.user.useruuid
|
||||
// instance.get(url).then(res => {
|
||||
// let user = res.data;
|
||||
// self.setState(Object.assign(self.state, { user: user }));
|
||||
// }).catch(console.error);
|
||||
// if (nextProps.address) {
|
||||
// let centerLocation = this.state.centerLocation;
|
||||
// if ((centerLocation.lat === undefined || centerLocation.long === undefined) || (centerLocation.lat === 0 || centerLocation.long === 0)) {
|
||||
// objConf.centerLocation = nextProps.address
|
||||
// objConf.locationValue = nextProps.address.name
|
||||
|
||||
// this.locateNearby(nextProps.address.lat, nextProps.address.lng)
|
||||
// }
|
||||
// }
|
||||
|
||||
@@ -540,7 +542,7 @@ export class NEMTLocation extends React.Component {
|
||||
long = geo.long;
|
||||
}
|
||||
|
||||
if (lat === 0 || long === 0) {
|
||||
if ((lat === undefined || long === undefined) || (lat === 0 || long === 0)) {
|
||||
lat = 41.886406;
|
||||
long = -87.624225;
|
||||
}
|
||||
@@ -567,9 +569,15 @@ export class NEMTLocation extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
updateTextSearch(searchText, dtSource, params) {
|
||||
updateTextSearch(event) {
|
||||
const searchText = event.target.value;
|
||||
let self = this;
|
||||
self.setState(Object.assign(self.state, { inputValue: searchText }));
|
||||
self.setState(Object.assign(self.state, { inputValue: searchText, searchingProvider: true }));
|
||||
|
||||
if (searchText.length === 0) {
|
||||
self.setState(Object.assign(self.state, { searchingProvider: false }));
|
||||
}
|
||||
|
||||
if (searchText.length >= 3) {
|
||||
let lat = 0;
|
||||
let long = 0;
|
||||
@@ -582,7 +590,7 @@ export class NEMTLocation extends React.Component {
|
||||
long = geo.long;
|
||||
}
|
||||
|
||||
if (lat === 0 || long === 0) {
|
||||
if ((lat === undefined || long === undefined) || (lat === 0 || long === 0)) {
|
||||
lat = 41.886406;
|
||||
long = -87.624225;
|
||||
}
|
||||
@@ -618,10 +626,11 @@ export class NEMTLocation extends React.Component {
|
||||
clickResult.npi = p.fivePartKeyGroups[0].providerNum;
|
||||
}
|
||||
|
||||
return p;
|
||||
var listItem = (<ListItem primaryText={p.providerName} secondaryText={clickResult.address} key={p.mukId} rightIcon={<MapsLocalHospital />} onClick={(event) => this.handlePlaceChanged(clickResult)} />)
|
||||
return listItem;
|
||||
});
|
||||
this.setState(Object.assign(this.state, { providers: providers }));
|
||||
dtSource = self.state.providers;
|
||||
|
||||
this.setState(Object.assign(this.state, { providerList: providers }));
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@@ -670,7 +679,7 @@ export class NEMTLocation extends React.Component {
|
||||
long = geo.long;
|
||||
}
|
||||
|
||||
if (lat === 0 || long === 0) {
|
||||
if ((lat === undefined || long === undefined) || (lat === 0 || long === 0)) {
|
||||
lat = 41.886406;
|
||||
long = -87.624225;
|
||||
}
|
||||
@@ -1045,7 +1054,7 @@ export class NEMTLocation extends React.Component {
|
||||
long = geo.long;
|
||||
}
|
||||
|
||||
if (lat === 0 || long === 0) {
|
||||
if ((lat === undefined || long === undefined) || (lat === 0 || long === 0)) {
|
||||
lat = 41.886406;
|
||||
long = -87.624225;
|
||||
}
|
||||
@@ -1331,14 +1340,16 @@ export class NEMTLocation extends React.Component {
|
||||
{customAddresses}
|
||||
<ListItem primaryText="Add Custom Shortcut" rightIcon={<ArrowDropRight />} leftIcon={<MapsLocalHospital />} onClick={(e) => this.handleAddAddress(e, 'custom')} />
|
||||
</List>)
|
||||
autosuggest = (<AutoComplete dataSourceConfig={datasourceConfig} dataSource={this.state.providers} filter={this.filterResults} maxSearchResults={5} onUpdateInput={this.updateTextSearch} fullWidth={true} floatingLabelText="Enter the Provider's name or address" onNewRequest={this.handleAutocomplete} searchText={this.state.inputValue} />)
|
||||
autosuggest = (<TextField fullWidth={true} onChange={this.updateTextSearch} floatingLabelText={"Enter the Provider's name or address"} value={this.state.inputValue} />)
|
||||
//autosuggest = (<AutoComplete dataSourceConfig={datasourceConfig} dataSource={this.state.providers} filter={this.filterResults} maxSearchResults={50} onUpdateInput={this.updateTextSearch} fullWidth={true} floatingLabelText="Enter the Provider's name or address" onNewRequest={this.handleAutocomplete} searchText={this.state.inputValue} />)
|
||||
} else {
|
||||
autosuggest = (<AutoComplete dataSourceConfig={datasourceConfig} dataSource={this.state.providers} filter={this.filterResults} maxSearchResults={5} onUpdateInput={this.updateTextSearch} fullWidth={true} floatingLabelText="Enter the Member's address or a nearby intersection or public place" onNewRequest={this.handleAutocomplete} searchText={this.state.inputValue} />)
|
||||
autosuggest = (<TextField fullWidth={true} onChange={this.updateTextSearch} floatingLabelText={"Enter the Member's address or a nearby intersection or public place"} value={this.state.inputValue} />)
|
||||
//autosuggest = (<AutoComplete dataSourceConfig={datasourceConfig} dataSource={this.state.providers} filter={this.filterResults} maxSearchResults={50} onUpdateInput={this.updateTextSearch} fullWidth={true} floatingLabelText="Enter the Member's address or a nearby intersection or public place" onNewRequest={this.handleAutocomplete} searchText={this.state.inputValue} />)
|
||||
}
|
||||
|
||||
let listItem = (
|
||||
<div className="" id="container">
|
||||
<AutoComplete dataSourceConfig={datasourceConfig} dataSource={this.state.locations} filter={this.filterResults} maxSearchResults={5} onUpdateInput={this.updateLocationValue} fullWidth={true} floatingLabelText="Center Location" onNewRequest={this.handleAutoCompleteLocation} searchText={this.state.locationValue} />
|
||||
<AutoComplete dataSourceConfig={datasourceConfig} dataSource={this.state.locations} filter={this.filterResults} maxSearchResults={50} onUpdateInput={this.updateLocationValue} fullWidth={true} floatingLabelText="Center Location" onNewRequest={this.handleAutoCompleteLocation} searchText={this.state.locationValue} />
|
||||
{autosuggest}
|
||||
<List>
|
||||
{this.state.currentLocation}
|
||||
@@ -1352,8 +1363,21 @@ export class NEMTLocation extends React.Component {
|
||||
<List style={customListStyle}>
|
||||
{this.state.nearbyPlaces}
|
||||
</List>
|
||||
</div >
|
||||
</div>
|
||||
)
|
||||
|
||||
if (this.state.searchingProvider) {
|
||||
listItem = (
|
||||
<div className="" id="container">
|
||||
<AutoComplete dataSourceConfig={datasourceConfig} dataSource={this.state.locations} filter={this.filterResults} maxSearchResults={50} onUpdateInput={this.updateLocationValue} fullWidth={true} floatingLabelText="Center Location" onNewRequest={this.handleAutoCompleteLocation} searchText={this.state.locationValue} />
|
||||
{autosuggest}
|
||||
<List style={customListStyle}>
|
||||
{this.state.providerList}
|
||||
</List>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
if (this.state.addLocation) {
|
||||
listItem = (
|
||||
<div className="" id="container">
|
||||
|
||||
@@ -406,7 +406,7 @@ class VerticalNonLinear extends React.Component {
|
||||
return_time: new Date(),
|
||||
pickupTimeHide: false,
|
||||
showValidationErrors: false,
|
||||
validationErrors: [],
|
||||
validationErrors: []
|
||||
};
|
||||
}
|
||||
|
||||
@@ -502,6 +502,7 @@ class VerticalNonLinear extends React.Component {
|
||||
eta: 0,
|
||||
trip_type: state.state.trip_type,
|
||||
return_time: state.state.return_time,
|
||||
raw_provider: state.state.destination.raw,
|
||||
};
|
||||
|
||||
if (self.state.eta.distance_miles) requestRide.distance = self.state.eta.distance_miles;
|
||||
@@ -517,6 +518,9 @@ class VerticalNonLinear extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
console.log(JSON.stringify(requestRide));
|
||||
return false;
|
||||
|
||||
Instance.getRawConn().post('/v1/nemt/rides', requestRide).then(function (res) {
|
||||
self.handleRequestClose(self);
|
||||
window.location.href = '/#/app/page/map/' + res.data.ride_uuid;
|
||||
@@ -715,8 +719,10 @@ class VerticalNonLinear extends React.Component {
|
||||
name: res.name,
|
||||
lat: res.lat,
|
||||
lng: res.lng,
|
||||
address: res.address
|
||||
address: res.address,
|
||||
raw: res.raw,
|
||||
}
|
||||
|
||||
const name = res.name;
|
||||
|
||||
if (self.state.origin && self.state.origin.lat && self.state.origin.lng) {
|
||||
@@ -896,7 +902,7 @@ class VerticalNonLinear extends React.Component {
|
||||
<div className="box-body padding-xs">
|
||||
|
||||
<div style={{ maxWidth: 380, margin: 'auto' }}>
|
||||
<ValidationErrorsInfoDialog open={this.state.showValidationErrors} errorMessages={this.state.validationErrors} onDismiss={this.handleValidationErrosDialogDismiss.bind(this)} />
|
||||
<ValidationErrorsInfoDialog title={'Errors'} open={this.state.showValidationErrors} draggable={true} modal={false} errorMessages={this.state.validationErrors} onDismiss={this.handleValidationErrosDialogDismiss.bind(this)} />
|
||||
|
||||
<Stepper
|
||||
activeStep={this.state.stepIndex}
|
||||
|
||||
@@ -33,9 +33,10 @@ import Instance from '../../../../../../../components/Connection';
|
||||
import Checkbox from 'material-ui/Checkbox';
|
||||
import Popover from 'material-ui/Popover';
|
||||
import ValidationErrorsInfoDialog from '../../../../../../../components/Shared/ValidationErrorsInfoDialog';
|
||||
import InputMask from 'react-input-mask';
|
||||
|
||||
let DateTimeFormat;
|
||||
|
||||
const roundingTime = 1000 * 60 * 5; //5 minutes
|
||||
|
||||
DateTimeFormat = global.Intl.DateTimeFormat;
|
||||
|
||||
@@ -44,6 +45,10 @@ class SignUp extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.props = props;
|
||||
|
||||
this.state = {
|
||||
birthdate: null,
|
||||
}
|
||||
}
|
||||
|
||||
componentWillReceiveProps = (nextProps) => {
|
||||
@@ -102,6 +107,8 @@ class SignUp extends React.Component {
|
||||
handleDate = (event, date) => {
|
||||
const user = this.props.user;
|
||||
user.birthdate = date;
|
||||
|
||||
this.setState(Object.assign(this.state, { birthdate: date }));
|
||||
if (this.props.onUserChanged) {
|
||||
this.props.onUserChanged(user);
|
||||
}
|
||||
@@ -157,7 +164,7 @@ class SignUp extends React.Component {
|
||||
|
||||
handlePhone = (event) => {
|
||||
const user = this.props.user;
|
||||
user.phonenumber = event.target.value;;
|
||||
user.phonenumber = event.target.value;
|
||||
if (this.props.onUserChanged) {
|
||||
this.props.onUserChanged(user);
|
||||
}
|
||||
@@ -219,16 +226,19 @@ class SignUp extends React.Component {
|
||||
onChange={this.handleMember}
|
||||
/>
|
||||
|
||||
<DatePicker width="115" hintText="Birth Date" container="inline" style={{ width: 115 }}
|
||||
value={this.props.user.birthdate} onChange={this.handleDate} />
|
||||
<DatePicker width="115" hintText="Member Birth Date" container="inline" style={{ width: 115 }}
|
||||
value={this.state.birthdate} onChange={this.handleDate} />
|
||||
|
||||
<TextField
|
||||
style={{ maxWidth: 115 }}
|
||||
floatingLabelText="Mobile Phone"
|
||||
ref="phone"
|
||||
type="telephone"
|
||||
value={this.props.user.phonenumber}
|
||||
onChange={this.handlePhone}
|
||||
/>
|
||||
floatingLabelText="Mobile Phone"
|
||||
>
|
||||
<InputMask mask="(999) 999-9999" maskChar={null} value={this.props.user.phonenumber} />
|
||||
</TextField>
|
||||
|
||||
<Checkbox
|
||||
label="Member has consented to terms"
|
||||
@@ -564,16 +574,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',
|
||||
@@ -592,6 +604,7 @@ class VerticalNonLinear extends React.Component {
|
||||
email: "",
|
||||
phonenumber: "",
|
||||
type: "",
|
||||
agreedTerms: false,
|
||||
},
|
||||
showUserSelection: true,
|
||||
userSelectionText: '',
|
||||
@@ -613,42 +626,17 @@ class VerticalNonLinear extends React.Component {
|
||||
pickupTimeHide: false,
|
||||
validationErrors: [],
|
||||
showValidationErrors: false,
|
||||
userValidated: false,
|
||||
};
|
||||
|
||||
this.handleUser = this.handleUser.bind(this);
|
||||
this.validateUser = this.validateUser.bind(this);
|
||||
this.lastStep = this.lastStep.bind(this);
|
||||
this.handleReset = this.handleReset.bind(this);
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
const loggedUser = JSON.parse(localStorage.getItem("loggedUser"));
|
||||
let state = this;
|
||||
|
||||
let user = {
|
||||
useruuid: this.props.params.uuid
|
||||
}
|
||||
|
||||
if (user.useruuid !== loggedUser.useruuid) {
|
||||
Instance.getRawConn().get(`/v1/nemt/users/member/${user.useruuid}`)
|
||||
.then(function (res) {
|
||||
state.setState(Object.assign(state.state, { user: res.data, showUserSelection: true, userSelectionText: `${res.data.member} - ${res.data.name}` }));
|
||||
})
|
||||
.catch(err => {
|
||||
if (err.response.status !== 422) {
|
||||
console.error(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
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,
|
||||
visitTime: visitTime,
|
||||
pickupTime: pickupTime,
|
||||
pickupTimeReturn: pickupTimeReturn,
|
||||
}));
|
||||
this.handleReset()
|
||||
}
|
||||
//for snackbar
|
||||
handleTouchTap() {
|
||||
@@ -668,45 +656,67 @@ class VerticalNonLinear extends React.Component {
|
||||
let self = state;
|
||||
const { stepIndex } = self.state;
|
||||
|
||||
//console.log('Step Index: ', stepIndex)
|
||||
switch (stepIndex) {
|
||||
case 1:
|
||||
self.setState(Object.assign(self.state, {
|
||||
message: ('Verifying Member\'s Eligibility'),
|
||||
open: true,
|
||||
}));
|
||||
|
||||
const eligibility = {
|
||||
"provider": {
|
||||
"provider_npi": self.state.destination.raw.fivePartKeyGroups[0].providerNum,
|
||||
"provider_name": self.state.destination.raw.providerName
|
||||
"raw_provider": self.state.destination.raw,
|
||||
"user": {
|
||||
"name": `${self.state.user.first} ${self.state.user.last}`,
|
||||
"first": self.state.user.first,
|
||||
"last": self.state.user.last,
|
||||
"gender": self.state.user.gender,
|
||||
"member": self.state.user.member,
|
||||
"birthdate": self.state.user.birthdate,
|
||||
"type": self.state.user.type,
|
||||
"email": self.state.user.email,
|
||||
"phonenumber": self.state.user.phonenumber,
|
||||
"consent": self.state.user.agreedTerms,
|
||||
},
|
||||
"subscriber": {
|
||||
"patient_type": self.state.user.type,
|
||||
"subscriber_id": self.state.user.member,
|
||||
"name": {
|
||||
"first": self.state.user.first,
|
||||
"last": self.state.user.last
|
||||
},
|
||||
"demographic_info": {
|
||||
"date_of_birth": self.state.user.birthdate,
|
||||
"gender": self.state.user.gender
|
||||
},
|
||||
"user": self.state.user,
|
||||
}
|
||||
};
|
||||
|
||||
console.log(JSON.stringify(eligibility));
|
||||
if (self.state.user.phonenumber && self.state.user.phonenumber.length > 0) {
|
||||
eligibility.user.phonenumber = eligibility.user.phonenumber.replace('(', '').replace(')', '').replace('-', '').replace(' ', '').trim()
|
||||
}
|
||||
|
||||
Instance.getRawConn().post('/v1/nemt/eligibility', eligibility).then(function (res) {
|
||||
self.setState(Object.assign(self.state, { stepIndex: stepIndex + 1, user: res.data }));
|
||||
}).catch(err => {
|
||||
if (err.response.status === 403) {
|
||||
self.setState(Object.assign(self.state, { stepIndex: stepIndex + 1, message: '', open: false }));
|
||||
}).catch(error => {
|
||||
|
||||
self.setState(Object.assign(self.state, {
|
||||
message: '',
|
||||
open: false,
|
||||
}));
|
||||
|
||||
if (error.response.status === 422 && error.response.data.data) {
|
||||
self.setState(Object.assign(self.state, {
|
||||
showValidationErrors: true,
|
||||
validationErrors: [err.response.data],
|
||||
validationErrors: error.response.data.data,
|
||||
message: '',
|
||||
open: false
|
||||
}));
|
||||
} else {
|
||||
console.error(err);
|
||||
self.setState(Object.assign(self.state, {
|
||||
showValidationErrors: true,
|
||||
validationErrors: [error.response.data],
|
||||
message: '',
|
||||
open: false
|
||||
}));
|
||||
}
|
||||
});
|
||||
break;
|
||||
case 2:
|
||||
self.handleTouchTap();
|
||||
|
||||
self.setState(Object.assign(self.state, {
|
||||
message: 'Adding Visit',
|
||||
open: true,
|
||||
}));
|
||||
|
||||
const visit = {
|
||||
"user": {
|
||||
"name": `${self.state.user.first} ${self.state.user.last}`,
|
||||
@@ -717,17 +727,64 @@ class VerticalNonLinear extends React.Component {
|
||||
"birthdate": self.state.user.birthdate,
|
||||
"type": self.state.user.type,
|
||||
"email": self.state.user.email,
|
||||
"phonenumber": self.state.user.phonenumber
|
||||
"phonenumber": self.state.user.phonenumber,
|
||||
"consent": self.state.user.agreedTerms,
|
||||
},
|
||||
"visit_datetime": self.state.visitTime,
|
||||
"pickup_datetime": self.state.pickupTime,
|
||||
"external_id": self.state.visit_external_id,
|
||||
"provider": self.state.destination.raw
|
||||
"raw_provider": self.state.destination.raw
|
||||
};
|
||||
|
||||
if (self.state.user.phonenumber && self.state.user.phonenumber.length > 0) {
|
||||
visit.user.phonenumber = visit.user.phonenumber.replace('(', '').replace(')', '').replace('-', '').replace(' ', '').trim()
|
||||
}
|
||||
|
||||
Instance.getRawConn().post('/v1/nemt/visits/', visit).then(function (res) {
|
||||
window.location.href = '/#/app/table/visits';
|
||||
}).catch(console.error);
|
||||
self.setState(Object.assign(self.state, {
|
||||
message: '',
|
||||
open: false,
|
||||
}));
|
||||
|
||||
const returnMessage = [
|
||||
{
|
||||
message: `Member: ${visit.user.name} (${visit.user.member})`
|
||||
},
|
||||
{
|
||||
message: `Gender: ${visit.user.gender}`
|
||||
},
|
||||
{
|
||||
message: `Birth date: ${visit.user.type}`
|
||||
},
|
||||
{
|
||||
message: `Member Type: ${visit.user.birthdate}`
|
||||
},
|
||||
{
|
||||
message: `Provider: ${visit.raw_provider.providerName}`
|
||||
},
|
||||
{
|
||||
message: `Date: ${visit.visit_datetime}`
|
||||
}]
|
||||
|
||||
self.setState(Object.assign(self.state, {
|
||||
showValidationErrors: true,
|
||||
validationErrors: returnMessage,
|
||||
errorTitle: "Visit Added"
|
||||
}));
|
||||
self.handleReset();
|
||||
}).catch(error => {
|
||||
if (error.response.status === 422 && error.response.data.data) {
|
||||
self.setState(Object.assign(self.state, {
|
||||
showValidationErrors: true,
|
||||
validationErrors: error.response.data.data
|
||||
}));
|
||||
} else {
|
||||
self.setState(Object.assign(self.state, {
|
||||
showValidationErrors: true,
|
||||
validationErrors: [error.response.data]
|
||||
}));
|
||||
}
|
||||
});
|
||||
break;
|
||||
default:
|
||||
if (stepIndex < 3) {
|
||||
@@ -768,10 +825,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,
|
||||
@@ -836,19 +893,75 @@ class VerticalNonLinear extends React.Component {
|
||||
let trip_type = {
|
||||
key: value.selectField,
|
||||
}
|
||||
|
||||
// console.log(event, index, value, state);
|
||||
// console.log(trip_type);
|
||||
|
||||
|
||||
self.setState(Object.assign(self.state, { pickupTimeReturnDisplayMode: value.pickupTimeReturnDisplayMode, trip_type: trip_type, pickupTimeHide: value.pickupTimeHide }));
|
||||
}
|
||||
|
||||
handleReset() {
|
||||
const loggedUser = JSON.parse(localStorage.getItem("loggedUser"));
|
||||
let state = this;
|
||||
|
||||
let user = {
|
||||
useruuid: this.props.params.uuid
|
||||
}
|
||||
|
||||
if (user.useruuid !== loggedUser.useruuid) {
|
||||
Instance.getRawConn().get(`/v1/nemt/users/member/${user.useruuid}`)
|
||||
.then(function (res) {
|
||||
res.data.agreedTerms = false;
|
||||
state.setState(Object.assign(state.state, { user: res.data, showUserSelection: true, userSelectionText: `${res.data.member} - ${res.data.name}` }));
|
||||
})
|
||||
.catch(err => {
|
||||
if (err.response.status !== 422) {
|
||||
console.error(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
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,
|
||||
visitTime: visitTime,
|
||||
pickupTime: pickupTime,
|
||||
pickupTimeReturn: pickupTimeReturn,
|
||||
stepIndex: 0,
|
||||
providerID: '',
|
||||
providerName: '',
|
||||
visit_external_id: '',
|
||||
buttonProviderText: 'Choose Provider',
|
||||
destination: {
|
||||
id: '',
|
||||
name: '',
|
||||
lat: 0,
|
||||
lng: 0,
|
||||
address: '',
|
||||
raw: null
|
||||
},
|
||||
user: {
|
||||
name: "",
|
||||
first: "",
|
||||
last: "",
|
||||
gender: "",
|
||||
member: "",
|
||||
birthdate: new Date(),
|
||||
email: "",
|
||||
phonenumber: "",
|
||||
type: "",
|
||||
agreedTerms: false,
|
||||
},
|
||||
}));
|
||||
}
|
||||
|
||||
renderStepActions(step, state) {
|
||||
let self = state;
|
||||
return (
|
||||
<div style={{ margin: '12px 0' }}>
|
||||
{step !== 2 && (
|
||||
{step === 1 && (
|
||||
<RaisedButton
|
||||
label="Next"
|
||||
disableTouchRipple
|
||||
@@ -858,23 +971,43 @@ class VerticalNonLinear extends React.Component {
|
||||
style={{ marginRight: 12 }}
|
||||
/>
|
||||
)}
|
||||
{step === 0 && (
|
||||
<RaisedButton
|
||||
label="Next"
|
||||
disableTouchRipple
|
||||
disableFocusRipple
|
||||
primary
|
||||
onTouchTap={() => self.handleNext(self)}
|
||||
style={{ marginRight: 12 }}
|
||||
disabled={!this.state.userValidated}
|
||||
/>
|
||||
)}
|
||||
{step !== 1 && (
|
||||
<FlatButton
|
||||
label="Back"
|
||||
disableTouchRipple
|
||||
disableFocusRipple
|
||||
onTouchTap={() => self.handlePrev(self)}
|
||||
/>
|
||||
)}
|
||||
{step === 2 && (
|
||||
<RaisedButton
|
||||
label="Confirm"
|
||||
label="Add Visit"
|
||||
disableTouchRipple
|
||||
disableFocusRipple
|
||||
primary
|
||||
onTouchTap={() => self.handleNext(self)}
|
||||
style={{ marginRight: 12 }}
|
||||
href=""
|
||||
disabled={!this.state.userValidated}
|
||||
/>
|
||||
)}
|
||||
{step > 0 && (
|
||||
{step === 2 && (
|
||||
<FlatButton
|
||||
label="Back"
|
||||
label="Reset"
|
||||
disableTouchRipple
|
||||
disableFocusRipple
|
||||
onTouchTap={() => self.handlePrev(self)}
|
||||
onTouchTap={() => self.handleReset()}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
@@ -1022,6 +1155,52 @@ class VerticalNonLinear extends React.Component {
|
||||
|
||||
handleUser(user) {
|
||||
this.setState(Object.assign(this.state, { user: user }));
|
||||
this.validateUser();
|
||||
}
|
||||
|
||||
validateUser() {
|
||||
let userValidated = true;
|
||||
const genderList = ["M", "F", "U"]
|
||||
const memberTypeList = ["S", "D", "U"]
|
||||
|
||||
userValidated = !(!this.state.user.first || this.state.user.first.trim().length === 0);
|
||||
if (!userValidated) {
|
||||
this.setState(Object.assign(this.state, { userValidated: userValidated }));
|
||||
return userValidated
|
||||
}
|
||||
userValidated = !(!this.state.user.last || this.state.user.last.trim().length === 0);
|
||||
if (!userValidated) {
|
||||
this.setState(Object.assign(this.state, { userValidated: userValidated }));
|
||||
return userValidated
|
||||
}
|
||||
userValidated = !(!this.state.user.member || this.state.user.member.trim().length === 0);
|
||||
if (!userValidated) {
|
||||
this.setState(Object.assign(this.state, { userValidated: userValidated }));
|
||||
return userValidated
|
||||
}
|
||||
userValidated = !(!this.state.user.gender || genderList.indexOf(this.state.user.gender) === -1);
|
||||
if (!userValidated) {
|
||||
this.setState(Object.assign(this.state, { userValidated: userValidated }));
|
||||
return userValidated
|
||||
}
|
||||
userValidated = !(!this.state.user.type || memberTypeList.indexOf(this.state.user.type) === -1);
|
||||
if (!userValidated) {
|
||||
this.setState(Object.assign(this.state, { userValidated: userValidated }));
|
||||
return userValidated
|
||||
}
|
||||
userValidated = !(!this.state.user.birthdate || this.state.user.birthdate === null || isNaN(this.state.user.birthdate.getTime()))
|
||||
if (!userValidated) {
|
||||
this.setState(Object.assign(this.state, { userValidated: userValidated }));
|
||||
return userValidated
|
||||
}
|
||||
userValidated = !(!this.state.user.agreedTerms)
|
||||
if (!userValidated) {
|
||||
this.setState(Object.assign(this.state, { userValidated: userValidated }));
|
||||
return userValidated
|
||||
}
|
||||
|
||||
this.setState(Object.assign(this.state, { userValidated: userValidated }));
|
||||
return userValidated
|
||||
}
|
||||
|
||||
handleValidationErrosDialogDismiss() {
|
||||
@@ -1030,6 +1209,10 @@ class VerticalNonLinear extends React.Component {
|
||||
}));
|
||||
}
|
||||
|
||||
lastStep = () => {
|
||||
if (this.state.userValidated) this.setState({ stepIndex: 2 });
|
||||
}
|
||||
|
||||
render() {
|
||||
// const { stepIndex } = this.state;
|
||||
this.getLocation();
|
||||
@@ -1093,7 +1276,7 @@ class VerticalNonLinear extends React.Component {
|
||||
<div className="box-body padding-xs">
|
||||
|
||||
<div style={{ maxWidth: 380, margin: 'auto' }}>
|
||||
<ValidationErrorsInfoDialog open={this.state.showValidationErrors} errorMessages={this.state.validationErrors} onDismiss={this.handleValidationErrosDialogDismiss.bind(this)} />
|
||||
<ValidationErrorsInfoDialog open={this.state.showValidationErrors} draggable={true} errorMessages={this.state.validationErrors} onDismiss={this.handleValidationErrosDialogDismiss.bind(this)} />
|
||||
<Stepper
|
||||
activeStep={this.state.stepIndex}
|
||||
linear={false}
|
||||
@@ -1126,7 +1309,7 @@ class VerticalNonLinear extends React.Component {
|
||||
</StepContent>
|
||||
</Step>
|
||||
<Step>
|
||||
<StepButton onClick={() => this.setState({ stepIndex: 2 })}>
|
||||
<StepButton onClick={() => this.lastStep()}>
|
||||
Visit Details
|
||||
</StepButton>
|
||||
<StepContent>
|
||||
@@ -1156,7 +1339,7 @@ class VerticalNonLinear extends React.Component {
|
||||
|
||||
|
||||
{/* <TabsSection /> */}
|
||||
{this.renderStepActions(1, this)}
|
||||
{this.renderStepActions(2, this)}
|
||||
</StepContent>
|
||||
</Step>
|
||||
|
||||
@@ -1183,7 +1366,7 @@ class VerticalNonLinear extends React.Component {
|
||||
/>
|
||||
|
||||
</div>
|
||||
</article>
|
||||
</article >
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ import Instance from '../../../../../../../components/Connection';
|
||||
import ValidationErrorsInfoDialog from '../../../../../../../components/Shared/ValidationErrorsInfoDialog';
|
||||
import Checkbox from 'material-ui/Checkbox';
|
||||
import Popover from 'material-ui/Popover';
|
||||
import InputMask from 'react-input-mask';
|
||||
|
||||
let DateTimeFormat;
|
||||
const roundingTime = 1000 * 60 * 5; //5 minutes
|
||||
@@ -70,6 +71,7 @@ class SignUp extends React.Component {
|
||||
if (this.props.onUserChanged) {
|
||||
const user = this.props.user;
|
||||
user.phonenumber = event.target.value;
|
||||
user.phonenumber = user.phonenumber.replace('(','').replace(')','').replace('-','').replace(' ','').trim();
|
||||
this.props.onUserChanged(user);
|
||||
}
|
||||
};
|
||||
@@ -134,11 +136,14 @@ class SignUp extends React.Component {
|
||||
|
||||
<TextField
|
||||
style={{ maxWidth: 115 }}
|
||||
floatingLabelText="Mobile Phone"
|
||||
ref="phone"
|
||||
type="telephone"
|
||||
floatingLabelText="Mobile Phone"
|
||||
value={this.props.user.phonenumber}
|
||||
onChange={this.handlePhone}
|
||||
/>
|
||||
>
|
||||
<InputMask mask="(999) 999-9999" maskChar={null} value={this.props.user.phonenumber} />
|
||||
</TextField>
|
||||
</fieldset>
|
||||
</form>
|
||||
);
|
||||
@@ -505,6 +510,7 @@ class VerticalNonLinear extends React.Component {
|
||||
};
|
||||
|
||||
this.handleUser = this.handleUser.bind(this);
|
||||
this.handlePickupChanged = this.handlePickupChanged.bind(this);
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
@@ -518,7 +524,28 @@ class VerticalNonLinear extends React.Component {
|
||||
const visit = res.data;
|
||||
visit.user.birthdate = new Date(visit.user.birthdate);
|
||||
visit.visit_datetime = new Date(visit.visit_datetime);
|
||||
self.setState(Object.assign(self.state, { visit: visit }));
|
||||
|
||||
if(visit.user.phonenumber && visit.user.phonenumber.length > 9) {
|
||||
visit.user.phonenumber = visit.user.phonenumber.replace('+1', '').replace(' ', '').trim();
|
||||
}
|
||||
|
||||
if (visit.user.addresses) {
|
||||
visit.user.addresses.forEach(a => {
|
||||
if (a.address_type === 'home') {
|
||||
const origin = {
|
||||
id: a.address_uuid,
|
||||
name: a.address_type_name,
|
||||
lat: a.lat,
|
||||
lng: a.lng,
|
||||
address: a.address
|
||||
};
|
||||
|
||||
self.setState(Object.assign(self.state, { origin: origin, buttonPickupText: a.address_type_name }));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
self.setState(Object.assign(self.state, { visit: visit, user: visit.user }));
|
||||
})
|
||||
.catch(err => {
|
||||
if (err.response.status !== 422) {
|
||||
@@ -555,6 +582,8 @@ class VerticalNonLinear extends React.Component {
|
||||
pickup_time: self.state.pickupTime,
|
||||
return_time: self.state.return_time,
|
||||
notes: self.state.notes,
|
||||
origin: self.state.origin,
|
||||
user: self.state.visit.user,
|
||||
};
|
||||
|
||||
if (self.diffMinutes(self.state.pickupTime, new Date()) > 10) {
|
||||
@@ -713,8 +742,22 @@ class VerticalNonLinear extends React.Component {
|
||||
const visit = this.state.visit;
|
||||
visit.user = user;
|
||||
this.setState(Object.assign(this.state, { visit: visit }));
|
||||
}
|
||||
|
||||
console.log(user);
|
||||
handlePickupChanged = (res) => {
|
||||
let origin = {
|
||||
id: res.address_uuid ? res.address_uuid : res.id,
|
||||
name: res.name,
|
||||
lat: res.lat,
|
||||
lng: res.lng,
|
||||
address: res.address
|
||||
}
|
||||
|
||||
const name = res.name;
|
||||
this.setState(Object.assign(this.state, {
|
||||
buttonPickupText: name,
|
||||
origin: origin
|
||||
}));
|
||||
}
|
||||
|
||||
render() {
|
||||
@@ -787,7 +830,7 @@ class VerticalNonLinear extends React.Component {
|
||||
<div className="box-body padding-xs">
|
||||
|
||||
<div style={{ maxWidth: 380, margin: 'auto' }}>
|
||||
<ValidationErrorsInfoDialog open={this.state.showValidationErrors} errorMessages={this.state.validationErrors} onDismiss={this.handleValidationErrosDialogDismiss.bind(this)} />
|
||||
<ValidationErrorsInfoDialog open={this.state.showValidationErrors} draggable={true} errorMessages={this.state.validationErrors} onDismiss={this.handleValidationErrosDialogDismiss.bind(this)} />
|
||||
|
||||
<Stepper
|
||||
activeStep={this.state.stepIndex}
|
||||
@@ -801,6 +844,8 @@ class VerticalNonLinear extends React.Component {
|
||||
<StepContent>
|
||||
<form role="form">
|
||||
<SignUp user={this.state.visit.user} onUserChanged={this.handleUser} />
|
||||
<div className="divider" />
|
||||
<NEMTLocation type="flat" floatingLabelText='Choose Member Location' hintText="Choose Member Location" data={this.state} title={"Member Address"} value={""} buttonvalue={this.state.buttonPickupText} onPlaceChanged={(provider) => this.handlePickupChanged(provider, this)} fontSize={12} loadSuggestion={true} address={this.state.origin} />
|
||||
</form>
|
||||
{this.renderStepActions(0, this)}
|
||||
</StepContent>
|
||||
|
||||
@@ -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} 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"
|
||||
|
||||
@@ -50,7 +50,6 @@ import FloatingActionButton from 'material-ui/FloatingActionButton';
|
||||
import ContentAdd from 'material-ui/svg-icons/content/add';
|
||||
import moment from 'moment';
|
||||
import { Card, CardActions, CardHeader, CardMedia, CardTitle, CardText } from 'material-ui/Card';
|
||||
import Draggable, { DraggableCore } from 'react-draggable'; // Both at the same time
|
||||
import Imgix from 'react-imgix'
|
||||
import Paper from 'material-ui/Paper';
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -108,7 +108,8 @@ class DatatableComponent extends React.Component {
|
||||
},
|
||||
columnDefs: [
|
||||
{ targets: [-1, -3], className: 'dt-body-right mdl-data-table__cell--non-numeric' }
|
||||
]
|
||||
],
|
||||
order: [[0, 'desc']]
|
||||
});
|
||||
state.decorateButtons();
|
||||
state.decorateSelect();
|
||||
|
||||
@@ -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);
|
||||
@@ -74,11 +79,15 @@ class Login extends React.Component {
|
||||
}).then(function (res) {
|
||||
let auth = res.data;
|
||||
state.setCookie('token', auth.token, auth.valid_time);
|
||||
localStorage.setItem('loggedUser', JSON.stringify(auth.user));
|
||||
|
||||
Instance.setToken(auth.token);
|
||||
localStorage.setItem('loggedUser', JSON.stringify(auth.user));
|
||||
loggedUser.update();
|
||||
|
||||
location.href = '/#/';
|
||||
if (loggedUser.anyOf(visitReporter)) {
|
||||
location.href = '/#/app/form/visit/' + auth.user.useruuid;
|
||||
} else {
|
||||
location.href = '/#/app/table/rides';
|
||||
}
|
||||
}).catch(function (err) {
|
||||
state.setState(Object.assign(state.state, {
|
||||
message: (err.response.data.message),
|
||||
|
||||
@@ -17,6 +17,10 @@ import Toggle from 'material-ui/Toggle';
|
||||
import Snackbar from 'material-ui/Snackbar';
|
||||
import Instance from '../../../components/Connection';
|
||||
|
||||
import Checkbox from 'material-ui/Checkbox';
|
||||
|
||||
import ValidationErrorsInfoDialog from '../../../components/Shared/ValidationErrorsInfoDialog';
|
||||
|
||||
class SignUp extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
@@ -39,7 +43,8 @@ class SignUp extends React.Component {
|
||||
"passConfirmation": "",
|
||||
"organizationType": { name: "", key: "provider", desc: "" },
|
||||
showValidationErrors: false,
|
||||
validationErrors: []
|
||||
validationErrors: [],
|
||||
agreedTerms:false,
|
||||
}
|
||||
|
||||
this.buttonValidated = this.buttonValidated.bind(this);
|
||||
@@ -56,16 +61,29 @@ class SignUp extends React.Component {
|
||||
|
||||
componentDidMount = () => { }
|
||||
|
||||
getFormattedPhoneNumber(){
|
||||
if(this.state.phone_number && this.state.phone_number.length > 0) {
|
||||
return this.state.phone_number.replace('+1','').replace('(','').replace(')','').replace('-','').replace(' ','').trim()
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
isPhoneNumberFormatValid() {
|
||||
let formattedNumber = this.getFormattedPhoneNumber();
|
||||
return !isNaN(formattedNumber) && (formattedNumber.toString().length === 10);
|
||||
}
|
||||
|
||||
buttonValidated = () => {
|
||||
let validated = true;
|
||||
if (!this.state.provider_name || this.state.provider_name === null || this.state.provider_name === "") validated = false;
|
||||
if (!this.state.provider_npi || this.state.provider_npi === null || this.state.provider_npi === "") validated = false;
|
||||
if (!this.state.email || this.state.email === null || this.state.email === "") validated = false;
|
||||
if (!this.state.phone_number || this.state.phone_number === null || this.state.phone_number === "") validated = false;
|
||||
if (!this.state.phone_number || this.state.phone_number === null || this.state.phone_number === "" || !this.isPhoneNumberFormatValid()) validated = false;
|
||||
if (!this.state.first || this.state.first === null || this.state.first === "") validated = false;
|
||||
if (!this.state.last || this.state.last === null || this.state.last === "") validated = false;
|
||||
if (!this.state.password_validated || !this.state.pass || this.state.pass === null || this.state.pass === "") validated = false;
|
||||
|
||||
if (!this.state.pass || this.state.pass === null || this.state.pass === "") validated = false;
|
||||
if (!this.state.passConfirmation || this.state.passConfirmation === null || this.state.passConfirmation === "") validated = false;
|
||||
if (!this.state.agreedTerms) validated = false;
|
||||
this.setState(Object.assign(this.state, { validated: validated }));
|
||||
}
|
||||
|
||||
@@ -101,16 +119,30 @@ class SignUp extends React.Component {
|
||||
|
||||
handlePass = (event) => {
|
||||
this.setState(Object.assign(this.state, { pass: btoa(event.target.value) }));
|
||||
this.setState(Object.assign(this.state, { password_validated: this.state.pass === this.state.passConfirmation }));
|
||||
};
|
||||
|
||||
handleConfirmationPass = (event) => {
|
||||
this.setState(Object.assign(this.state, { passConfirmation: btoa(event.target.value) }));
|
||||
this.setState(Object.assign(this.state, { password_validated: this.state.pass === this.state.passConfirmation }));
|
||||
};
|
||||
|
||||
handleChecked = (event, checked) => {
|
||||
this.setState(Object.assign(this.state, { agreedTerms: checked }));
|
||||
this.buttonValidated();
|
||||
};
|
||||
|
||||
clickEvent = (event) => {
|
||||
event.preventDefault();
|
||||
|
||||
if (this.state.passConfirmation !== this.state.pass){
|
||||
this.setState(Object.assign(this.state, {
|
||||
showValidationErrors: true,
|
||||
validationErrors: [{message:'Confirmed password does not match password'}]
|
||||
}));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const state = this;
|
||||
|
||||
let user = {
|
||||
@@ -131,42 +163,30 @@ class SignUp extends React.Component {
|
||||
localStorage.removeItem('loggedUser');
|
||||
location.href = '/#/login';
|
||||
}).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 {
|
||||
alert('Error to log in: ' + err.message);
|
||||
switch(err.response.status){
|
||||
case 422:
|
||||
//Unprocessable Entity (validation failed)
|
||||
state.setState(Object.assign(state.state, {
|
||||
showValidationErrors: true,
|
||||
validationErrors: err.response.data.data
|
||||
}));
|
||||
break;
|
||||
default:
|
||||
state.setState(Object.assign(state.state, {
|
||||
showValidationErrors: true,
|
||||
validationErrors: [{message:"Error processing your request"}]
|
||||
}));
|
||||
}
|
||||
console.error(err);
|
||||
});
|
||||
}
|
||||
|
||||
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">
|
||||
|
||||
@@ -243,17 +263,21 @@ class SignUp extends React.Component {
|
||||
</div>
|
||||
<div className="divider" />
|
||||
<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>
|
||||
<Checkbox
|
||||
label="Member has consented to terms of use"
|
||||
checked={this.state.agreedTerms}
|
||||
onCheck={this.handleChecked}
|
||||
/>
|
||||
</div>
|
||||
<div className="divider" />
|
||||
<div className="form-group">
|
||||
{validationErrors}
|
||||
<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)} />
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
<div className="card-action no-border text-right">
|
||||
<a href="#/login" className="color-gray-light">Login</a>
|
||||
<RaisedButton
|
||||
label="Sign up"
|
||||
primary={true}
|
||||
|
||||
@@ -3,11 +3,11 @@ import { contains } from 'ramda';
|
||||
|
||||
import normalizeRoles from './normalizeRoles';
|
||||
|
||||
const loggedUser = JSON.parse(window.localStorage.getItem('loggedUser'));
|
||||
const loggedUser = () => {
|
||||
let user = JSON.parse(window.localStorage.getItem('loggedUser'));
|
||||
|
||||
if (loggedUser) {
|
||||
loggedUser.anyOf = (...profiles) => {
|
||||
const userRole = loggedUser.profiles[0];
|
||||
const anyOf = (...profiles) => {
|
||||
const userRole = user.profiles[0];
|
||||
const userOrgType = userRole.organization.type.key;
|
||||
const roles = normalizeRoles(profiles);
|
||||
|
||||
@@ -22,7 +22,18 @@ if (loggedUser) {
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
const update = () => {
|
||||
user = JSON.parse(window.localStorage.getItem('loggedUser'));
|
||||
return user;
|
||||
}
|
||||
|
||||
return {
|
||||
user,
|
||||
anyOf: anyOf,
|
||||
update: update,
|
||||
}
|
||||
}
|
||||
|
||||
export default loggedUser;
|
||||
export default loggedUser();
|
||||
|
||||
Reference in New Issue
Block a user