Compare commits

..

1 Commits

Author SHA1 Message Date
GotPPay
4b86c36e8a hide profile from top menu and substitute book ride for visit 2018-05-25 17:23:27 +02:00
11 changed files with 181 additions and 474 deletions

View File

@@ -8,10 +8,6 @@ import { Router, hashHistory, browserHistory } from 'react-router';
import { syncHistoryWithStore, routerMiddleware } from 'react-router-redux'; import { syncHistoryWithStore, routerMiddleware } from 'react-router-redux';
import reducers from './reducers'; import reducers from './reducers';
import Instance from './components/Connection'; import Instance from './components/Connection';
import {
loggedUser,
visitReporter,
} from 'utils/authorization';
const middleware = routerMiddleware(hashHistory); const middleware = routerMiddleware(hashHistory);
const store = createStore( const store = createStore(
@@ -33,8 +29,8 @@ const isFunction = (functionToCheck) => {
}; };
const requireAuth = (nextState, replace, next) => { 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) if (nextState.location.pathname === '/login' || nextState.location.pathname === '/sign-up' || (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)))) { || (!isFunction(replace) && (replace.location.pathname === '/login' || replace.location.pathname === '/sign-up' || (replace.location.pathname.indexOf('/ride') > -1 && replace.params.ride_uuid !== undefined && replace.params.user_uuid !== undefined)))) {
next(); next();
} }
@@ -59,15 +55,7 @@ const rootRoute = {
onChange: requireAuth, onChange: requireAuth,
onEnter: requireAuth, onEnter: requireAuth,
component: require('./containers/App'), component: require('./containers/App'),
indexRoute: { indexRoute: { onEnter: (nextState, replace) => replace('/app/table/rides') },
onEnter: (nextState, replace) => {
if (loggedUser.anyOf(visitReporter)) {
replace('/app/form/visit/' + loggedUser.useruuid)
} else {
replace('/app/table/rides');
}
}
},
childRoutes: [ childRoutes: [
require('./routes/app'), require('./routes/app'),
require('./routes/404'), require('./routes/404'),

View File

@@ -6,11 +6,10 @@ import { hashHistory } from 'react-router';
import { import {
loggedUser, loggedUser,
planScheduler,
providerScheduler,
visitReporter, visitReporter,
} from 'utils/authorization'; } from 'utils/authorization';
const ImgIconButtonStyle = { const ImgIconButtonStyle = {
width: '60px', width: '60px',
height: '60px' height: '60px'
@@ -35,7 +34,6 @@ class NavRightList extends React.Component {
handleChange = (event, value) => { handleChange = (event, value) => {
hashHistory.push(value); hashHistory.push(value);
} }
componentDidMount() { componentDidMount() {
const user = JSON.parse(localStorage.getItem('loggedUser')); const user = JSON.parse(localStorage.getItem('loggedUser'));
if (user) { if (user) {
@@ -48,8 +46,6 @@ class NavRightList extends React.Component {
<ul className="list-unstyled float-right"> <ul className="list-unstyled float-right">
<li> <li>
<IconMenu <IconMenu
iconButtonElement={<IconButton style={ImgIconButtonStyle}><img src="assets/images/ic_account_circle_white_48dp_1x.png" alt="" className="rounded-circle img30_30" /></IconButton>} iconButtonElement={<IconButton style={ImgIconButtonStyle}><img src="assets/images/ic_account_circle_white_48dp_1x.png" alt="" className="rounded-circle img30_30" /></IconButton>}
@@ -67,16 +63,6 @@ class NavRightList extends React.Component {
leftIcon={<i className="material-icons">account_circle</i>} 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) && {!loggedUser.anyOf(visitReporter) &&
<MenuItem <MenuItem
onTouchTap={(e) => this.handleChange(e, `/app/form/steppers/${this.state.useruuid}`)} onTouchTap={(e) => this.handleChange(e, `/app/form/steppers/${this.state.useruuid}`)}
@@ -86,7 +72,15 @@ class NavRightList extends React.Component {
leftIcon={<i className="material-icons">mode_edit</i>} leftIcon={<i className="material-icons">mode_edit</i>}
/> />
} }
{loggedUser.anyOf(visitReporter) &&
<MenuItem
onTouchTap={(e) => this.handleChange(e, `/app/form/visit/${this.state.useruuid}`)}
primaryText="Create Visit"
innerDivStyle={listItemStyle}
style={{ fontSize: '14px', lineHeight: '48px' }}
leftIcon={<i className="material-icons">mode_edit</i>}
/>
}
<MenuItem <MenuItem
onTouchTap={(e) => this.handleChange(e, `/login`)} onTouchTap={(e) => this.handleChange(e, `/login`)}
primaryText="Log Out" primaryText="Log Out"
@@ -100,6 +94,6 @@ class NavRightList extends React.Component {
</ul> </ul>
); );
} }
} }
module.exports = NavRightList; module.exports = NavRightList;

View File

@@ -8,17 +8,11 @@ export class ValidationErrorsInfoDialog extends React.Component {
this.props = props; this.props = props;
this.state = { this.state = {
open: this.props.open, open: this.props.open,
title: "Errors",
} }
} }
componentWillReceiveProps(newProps) { componentWillReceiveProps(newProps) {
let title = this.state.title; this.setState({ open: newProps.open });
if (newProps.errorTitle) {
title = newProps.errorTitle;
}
this.setState({ open: newProps.open, title: title });
} }
handleOpen = () => { handleOpen = () => {
@@ -44,7 +38,7 @@ export class ValidationErrorsInfoDialog extends React.Component {
return ( return (
<div> <div>
<Dialog <Dialog
title={this.state.title} title="Errors"
actions={actions} actions={actions}
modal={this.props.modal ? this.props.modal : false} modal={this.props.modal ? this.props.modal : false}
open={this.state.open} open={this.state.open}

View File

@@ -102,17 +102,9 @@ class SidebarContent extends React.Component {
return ( return (
<ul className="nav" ref={(c) => { this.nav = c; }}> <ul className="nav" ref={(c) => { this.nav = c; }}>
{loggedUser.anyOf(visitReporter) && {loggedUser.anyOf(visitReporter) &&
<li> <li><FlatButton className="prepend-icon" href={"#/app/form/visit/" + this.state.user.useruuid}><span>Create Visit</span></FlatButton></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) && {!loggedUser.anyOf(visitReporter) &&
<li> <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> <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> <ul>
@@ -166,8 +158,6 @@ class SidebarContent extends React.Component {
} }
<li className="nav-divider" /> <li className="nav-divider" />
<li><FlatButton className="prepend-icon" href={"#/login"}><span>Log Out</span></FlatButton></li>
</ul> </ul>
); );
} }

View File

@@ -5,10 +5,6 @@ import Footer from 'components/Footer';
import Notifications from 'components/Notifications'; import Notifications from 'components/Notifications';
import Notification from 'components/Shared/Notification'; import Notification from 'components/Shared/Notification';
import GeolocationService from './Geolocation'; import GeolocationService from './Geolocation';
import {
loggedUser,
visitReporter,
} from 'utils/authorization';
class MainApp extends React.Component { class MainApp extends React.Component {
constructor(props) { constructor(props) {
@@ -57,9 +53,8 @@ class MainApp extends React.Component {
<Footer /> <Footer />
</div> </div>
</section> </section>
{!loggedUser.anyOf(visitReporter) &&
<Notifications user={this.state.user} onRideUpdate={this.handleRide} /> <Notifications user={this.state.user} onRideUpdate={this.handleRide} />
} {/* <Notification user={this.state.user} onRideUpdate={this.handleRide} /> */}
</div> </div>
); );
} }

View File

@@ -115,7 +115,6 @@ export class NEMTLocation extends React.Component {
long: 0 long: 0
}, },
providers: [], providers: [],
locations: [],
currentSelection: { currentSelection: {
id: 0, id: 0,
name: "", name: "",
@@ -126,7 +125,6 @@ export class NEMTLocation extends React.Component {
saved: false, saved: false,
}, },
inputValue: "", inputValue: "",
locationValue: "",
addLocation: false, addLocation: false,
searchAddresses: [], searchAddresses: [],
addLocationText: '', addLocationText: '',
@@ -145,15 +143,7 @@ export class NEMTLocation extends React.Component {
id: '', id: '',
name: '', name: '',
address: '', address: '',
}, }
centerLocation: {
lat: 0,
long: 0,
name: '',
address: '',
},
searchingProvider: false,
providerList: [],
} }
this.addCustomLabel = this.addCustomLabel.bind(this); this.addCustomLabel = this.addCustomLabel.bind(this);
@@ -174,8 +164,6 @@ export class NEMTLocation extends React.Component {
this.updateLocation = this.updateLocation.bind(this); this.updateLocation = this.updateLocation.bind(this);
this.handleGetClosestPlace = this.handleGetClosestPlace.bind(this); this.handleGetClosestPlace = this.handleGetClosestPlace.bind(this);
this.updateLocationValue = this.updateLocationValue.bind(this);
this.handleAutoCompleteLocation = this.handleAutoCompleteLocation.bind(this);
// this.updateLocation().then(console.log); // this.updateLocation().then(console.log);
@@ -196,71 +184,52 @@ export class NEMTLocation extends React.Component {
} }
geoSuccess = (position) => { geoSuccess = (position) => {
let lat = 0;
let long = 0;
if (this.state.centerLocation.lat !== 0 && this.state.centerLocation.long !== 0) {
lat = this.state.centerLocation.lat;
long = this.state.centerLocation.long;
} else {
const geo = GeolocationService.GetCoordinates();
lat = geo.lat;
long = geo.long;
}
if (lat === 0 || long === 0) { const geo = GeolocationService.GetCoordinates();
lat = 41.886406; // self.updateLocation().then(p => {
long = -87.624225; let lat = geo.lat;
} let long = geo.long;
this.locateNearby(lat, long) this.locateNearby(lat, long)
} }
locateNearby = (lat, long) => { locateNearby = (lat, long) => {
if (lat === 0 || long === 0) { if (lat === 0 || long === 0) {
lat = 41.886406; lat = 41.886406;
long = -87.624225; long = -87.624225;
} }
if (this.state.locationType === 'provider') { if (this.state.locationType === 'provider') {
let url = `/v1/nemt/provider?lat=${lat}&long=${long}&limit=50&sortby=distance` Instance.getRawConn().get(`/v1/nemt/provider/participating?sort=distance&lat=${lat}&long=${long}`).then(res => {
Instance.getRawConn().get(url).then(res => {
let nearByPlaces = []; let nearByPlaces = [];
if (res.data.resultStatus === 'SUCCESS') { let providers = res.data.map(p => {
let providers = res.data.providers.map(p => { if (p.address.street_address_1) {
const streetNumber = p.streetName_1.split(' ')[0] const streetNumber = p.address.street_address_1.split(' ')[0]
let clickResult = { let clickResult = {
id: p.mukId, id: p.muk_id,
muk_id: p.mukId, address: `${p.address.street_address_1}, ${p.address.city}, ${p.address.state} (${p.address.zipcode})`,
address: `${p.streetName_1}, ${p.cityName}, ${p.state} (${p.zipCode.substr(0, 5)})`, lat: p.address.lat,
lat: parseFloat(p.latitude), lng: p.address.long,
lng: parseFloat(p.longitude), name: p.name,
name: p.providerName, type: "provider",
type: 'provider',
raw: p, raw: p,
street_number: streetNumber, street_number: streetNumber,
street: p.streetName_1.replace(streetNumber, '').trim(), street: p.address.street_address_1.replace(streetNumber, '').trim(),
city: p.cityName, city: p.address.city,
state: p.state, state: p.address.state,
zipcode: p.zipCode.substr(0, 5), zipcode: p.address.zipcode.substring(0, 5),
country: p.country, country: p.address.country,
saved: false, saved: false,
} }
clickResult.address = `${clickResult.street_number} ${clickResult.street}, ${clickResult.city}`
if (p.fivePartKeyGroups.length > 0) { var listItem = (<ListItem primaryText={p.name} secondaryText={clickResult.address} key={p.muk_id} rightIcon={<MapsLocalHospital />} onClick={(event) => this.handlePlaceChanged(clickResult)} />)
clickResult.npi = p.fivePartKeyGroups[0].providerNum;
}
var listItem = (<ListItem primaryText={p.providerName} secondaryText={clickResult.address} key={p.mukId} rightIcon={<MapsLocalHospital />} onClick={(event) => this.handlePlaceChanged(clickResult)} />)
nearByPlaces.push(listItem); nearByPlaces.push(listItem);
p.providerText = `${p.providerName} - ${p.streetName_1}, ${p.cityName}, ${p.state} (${p.zipCode.substr(0, 5)}) (${p.phoneNumber})` p.providerText = `${p.name} - ${p.address.street_address_1}, ${p.address.city}, ${p.address.state} (${p.address.zipcode}) (${p.address.phone_number})`
p.muk_id = p.mukId }
return p; return p;
}); });
this.setState(Object.assign(this.state, { nearbyPlaces: nearByPlaces, providers: providers, providerList: nearByPlaces })); this.setState(Object.assign(this.state, { nearbyPlaces: nearByPlaces, providers: providers }));
}
}); });
} else { } else {
var pyrmont = new google.maps.LatLng(lat, long); var pyrmont = new google.maps.LatLng(lat, long);
@@ -345,7 +314,7 @@ export class NEMTLocation extends React.Component {
buttonText = buttonText.substring(0, self.state.textSize); buttonText = buttonText.substring(0, self.state.textSize);
buttonText += '...'; buttonText += '...';
} }
self.setState(Object.assign(self.state, { buttonValue: buttonText, inputValue: name.address, searchingProvider: false, providerList: [] })); self.setState(Object.assign(self.state, { buttonValue: buttonText, inputValue: name.address }));
}).catch(console.error); }).catch(console.error);
} }
@@ -526,105 +495,28 @@ export class NEMTLocation extends React.Component {
this.locateNearby(41.886406, -87.624225); this.locateNearby(41.886406, -87.624225);
} }
updateLocationValue(searchText, dtSource, params) {
let self = this;
self.setState(Object.assign(self.state, { locationValue: searchText }));
if (searchText.length >= 3) {
let lat = 0;
let long = 0;
if (this.state.centerLocation.lat !== 0 && this.state.centerLocation.long !== 0) {
lat = this.state.centerLocation.lat;
long = this.state.centerLocation.long;
} else {
const geo = GeolocationService.GetCoordinates();
lat = geo.lat;
long = geo.long;
}
if (lat === 0 || long === 0) {
lat = 41.886406;
long = -87.624225;
}
var location = new google.maps.LatLng(lat, long);
var request = {
location: location,
radius: '500',
input: searchText,
componentRestrictions: { country: 'us' },
};
const callback = (results, status) => {
if (status == google.maps.places.PlacesServiceStatus.OK) {
var googlePlaces = results.map(place => {
place.providerText = place.description;
place.muk_id = place.id;
place.saved = false;
return place;
});
self.setState(Object.assign(self.state, { locations: googlePlaces }));
}
}
service.getPlacePredictions(request, callback);
}
}
updateTextSearch(searchText, dtSource, params) { updateTextSearch(searchText, dtSource, params) {
let self = this; let self = this;
self.setState(Object.assign(self.state, { inputValue: searchText, searchingProvider: true })); self.setState(Object.assign(self.state, { inputValue: searchText }));
if (searchText.length >= 3) { if (searchText.length >= 3) {
let lat = 0; let lat = self.state.geolocation.lat;
let long = 0; let long = self.state.geolocation.long;
if (this.state.centerLocation.lat !== 0 && this.state.centerLocation.long !== 0) {
lat = this.state.centerLocation.lat;
long = this.state.centerLocation.long;
} else {
const geo = GeolocationService.GetCoordinates();
lat = geo.lat;
long = geo.long;
}
if (lat === 0 || long === 0) { if (lat === 0 || long === 0) {
lat = 41.886406; lat = 41.886406;
long = -87.624225; long = -87.624225;
} }
if (self.state.locationType === 'provider') { if (self.state.locationType === 'provider') {
let url = `/v1/nemt/provider?lat=${lat}&long=${long}&limit=50&name=${searchText}&sortby=distance` //let url = `/v1/nemt/provider?lat=${lat}&long=${long}&limit=20&name=${searchText}&sortby=distance`
let url = `/v1/nemt/provider/participating?lat=${lat}&long=${long}&query=${searchText}&sortby=distance`
Instance.getRawConn().get(encodeURI(url)).then(res => { Instance.getRawConn().get(encodeURI(url)).then(res => {
if (res.data.resultStatus === 'SUCCESS') { if (res.data.length > 0) {
let providers = res.data.providers.map(p => { let places = res.data.map(p => {
const streetNumber = p.streetName_1.split(' ')[0] p.providerText = `${p.name} - ${p.address.street_address_1}, ${p.address.city}, ${p.address.state} (${p.address.zipcode}) (${p.address.phone_number})`
p.providerText = `${p.providerName} - ${p.streetName_1}, ${p.cityName}, ${p.state} (${p.zipCode.substr(0, 5)}) (${p.phoneNumber})` p.saved = false
p.muk_id = p.mukId return p;
})
let clickResult = { self.setState(Object.assign(self.state, { providers: places }));
id: p.mukId,
muk_id: p.mukId,
address: `${p.streetName_1}, ${p.cityName}, ${p.state} (${p.zipCode.substr(0, 5)})`,
lat: parseFloat(p.latitude),
lng: parseFloat(p.longitude),
name: p.providerName,
type: 'provider',
raw: p,
street_number: streetNumber,
street: p.streetName_1.replace(streetNumber, '').trim(),
city: p.cityName,
state: p.state,
zipcode: p.zipCode.substr(0, 5),
country: p.country,
saved: false,
}
if (p.fivePartKeyGroups.length > 0) {
clickResult.npi = p.fivePartKeyGroups[0].providerNum;
}
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, { providerList: providers }));
dtSource = self.state.providers; dtSource = self.state.providers;
} }
}); });
@@ -662,59 +554,42 @@ export class NEMTLocation extends React.Component {
this.setState(Object.assign(this.state, { addLocationTextValue: providerSearch })); this.setState(Object.assign(this.state, { addLocationTextValue: providerSearch }));
if (providerSearch.length >= 3) { if (providerSearch.length >= 3) {
let lat = 0;
let long = 0;
if (this.state.centerLocation.lat !== 0 && this.state.centerLocation.long !== 0) {
lat = this.state.centerLocation.lat;
long = this.state.centerLocation.long;
} else {
const geo = GeolocationService.GetCoordinates(); const geo = GeolocationService.GetCoordinates();
lat = geo.lat; let lat = geo.lat;
long = geo.long; let long = geo.long;
}
if (lat === 0 || long === 0) { if (lat === 0 || long === 0) {
lat = 41.886406; lat = 41.886406;
long = -87.624225; long = -87.624225;
} }
if (this.state.locationType === 'provider') { if (this.state.locationType === 'provider') {
let url = `/v1/nemt/provider?lat=${lat}&long=${long}&limit=50&name=${providerSearch}&sortby=distance` let url = `/v1/nemt/provider/participating?lat=${lat}&long=${long}&query=${providerSearch}&sortby=distance`
Instance.getRawConn().get(encodeURI(url)).then(res => { Instance.getRawConn().get(encodeURI(url)).then(res => {
if (res.data.resultStatus === 'SUCCESS') { let places = res.data.map(p => {
let providers = res.data.providers.map(p => { const streetNumber = p.address.street_address_1.split(' ')[0]
const streetNumber = p.streetName_1.split(' ')[0] p.providerText = `${p.name} - ${p.address.street_address_1}, ${p.address.city}, ${p.address.state} (${p.address.zipcode}) (${p.address.phone_number})`
p.providerText = `${p.providerName} - ${p.streetName_1}, ${p.cityName}, ${p.state} (${p.zipCode.substr(0, 5)}) (${p.phoneNumber})`
p.muk_id = p.mukId
let clickResult = { let clickResult = {
id: p.mukId, id: p.muk_id,
muk_id: p.mukId, address: `${p.address.street_address_1}, ${p.address.city}, ${p.address.state} (${p.address.zipcode})`,
address: `${p.streetName_1}, ${p.cityName}, ${p.state} (${p.zipCode.substr(0, 5)})`, lat: p.address.lat,
lat: parseFloat(p.latitude), lng: p.address.long,
lng: parseFloat(p.longitude), name: p.name,
name: p.providerName, type: "provider",
type: 'provider',
raw: p, raw: p,
street_number: streetNumber, street_number: streetNumber,
street: p.streetName_1.replace(streetNumber, '').trim(), street: p.address.street_address_1.replace(streetNumber, '').trim(),
city: p.cityName, city: p.address.city,
state: p.state, state: p.address.state,
zipcode: p.zipCode.substr(0, 5), zipcode: p.address.zipcode.substring(0, 5),
country: p.country, country: p.address.country,
saved: false, saved: false,
} }
clickResult.address = `${clickResult.street_number} ${clickResult.street}, ${clickResult.city}`
if (p.fivePartKeyGroups.length > 0) { var listItem = (<ListItem value={p.muk_id} primaryText={p.name} secondaryText={clickResult.address} key={p.muk_id} rightIcon={<MapsLocalHospital />} onClick={(event) => this.handleSaveAddress(clickResult, this)} />)
clickResult.npi = p.fivePartKeyGroups[0].providerNum;
}
var listItem = (<ListItem primaryText={p.providerName} secondaryText={clickResult.address} key={p.mukId} value={p.mukId} rightIcon={<MapsLocalHospital />} onClick={(event) => this.handleSaveAddress(clickResult)} />)
return listItem; return listItem;
}); });
this.setState(Object.assign(this.state, { searchAddresses: providers }));
} this.setState(Object.assign(this.state, { searchAddresses: places }));
}); });
} else { } else {
var location = new google.maps.LatLng(lat, long); var location = new google.maps.LatLng(lat, long);
@@ -841,68 +716,6 @@ export class NEMTLocation extends React.Component {
} }
} }
handleAutoCompleteLocation = (location) => {
const self = this;
placeService.getDetails(location, (result, status) => {
if (status == google.maps.places.PlacesServiceStatus.OK) {
let clickResult = {
id: result.place_id,
placeId: result.place_id,
address: result.formatted_address ? result.formatted_address : result.vicinity,
lat: result.geometry.location.lat(),
lng: result.geometry.location.lng(),
name: result.name,
type: "google",
raw: result,
street_number: '',
street: '',
city: '',
state: '',
zipcode: '',
country: '',
saved: false,
}
result.address_components.forEach(a => {
a.types.forEach(c => {
switch (c) {
case "street_number":
clickResult.street_number = a.short_name;
break;
case "route":
clickResult.street = a.short_name;
break;
case "locality":
clickResult.city = a.short_name;
break;
case "administrative_area_level_1":
clickResult.state = a.short_name;
break;
case "country":
clickResult.country = a.short_name;
break;
case "postal_code":
clickResult.zipcode = a.short_name;
break;
}
}, this)
}, this);
clickResult.address = `${clickResult.street_number} ${clickResult.street}, ${clickResult.city}`
const centerLocation = {
lat: clickResult.lat,
long: clickResult.lng,
name: clickResult.name,
address: clickResult.address
}
self.setState(Object.assign(self.state, { centerLocation: centerLocation }));
self.locateNearby(clickResult.lat, clickResult.lng);
}
});
}
handleAutocomplete = (provider) => { handleAutocomplete = (provider) => {
const sendInfo = (clickResult) => { const sendInfo = (clickResult) => {
this.setState(Object.assign(this.state, { currentSelection: clickResult })); this.setState(Object.assign(this.state, { currentSelection: clickResult }));
@@ -922,32 +735,24 @@ export class NEMTLocation extends React.Component {
} }
if (this.state.locationType === "provider") { if (this.state.locationType === "provider") {
const p = provider; const streetNumber = provider.address.street_address_1.split(' ')[0]
const streetNumber = p.streetName_1.split(' ')[0]
p.providerText = `${p.providerName} - ${p.streetName_1}, ${p.cityName}, ${p.state} (${p.zipCode.substr(0, 5)}) (${p.phoneNumber})`
p.muk_id = p.mukId
let clickResult = { let clickResult = {
id: p.mukId, id: provider.muk_id,
muk_id: p.mukId, address: `${provider.address.street_address_1}, ${provider.address.city}, ${provider.address.state} (${provider.address.zipcode})`,
address: `${p.streetName_1}, ${p.cityName}, ${p.state} (${p.zipCode.substr(0, 5)})`, lat: provider.address.lat,
lat: parseFloat(p.latitude), lng: provider.address.long,
lng: parseFloat(p.longitude), name: provider.name,
name: p.providerName, type: "provider",
type: 'provider', raw: provider,
raw: p,
street_number: streetNumber, street_number: streetNumber,
street: p.streetName_1.replace(streetNumber, '').trim(), street: provider.address.street_address_1.replace(streetNumber, '').trim(),
city: p.cityName, city: provider.address.city,
state: p.state, state: provider.address.state,
zipcode: p.zipCode.substr(0, 5), zipcode: provider.address.zipcode.substring(0, 5),
country: p.country, country: provider.address.country,
saved: false, saved: false,
} }
clickResult.address = `${clickResult.street_number} ${clickResult.street}, ${clickResult.city}`
if (p.fivePartKeyGroups.length > 0) {
clickResult.npi = p.fivePartKeyGroups[0].providerNum;
}
sendInfo(clickResult); sendInfo(clickResult);
} else { } else {
@@ -1037,51 +842,42 @@ export class NEMTLocation extends React.Component {
handleCurrentLocation(e) { handleCurrentLocation(e) {
const self = this; const self = this;
let lat = 0;
let long = 0;
if (this.state.centerLocation.lat !== 0 && this.state.centerLocation.long !== 0) {
lat = this.state.centerLocation.lat;
long = this.state.centerLocation.long;
} else {
const geo = GeolocationService.GetCoordinates(); const geo = GeolocationService.GetCoordinates();
lat = geo.lat; // self.updateLocation().then(p => {
long = geo.long; let lat = geo.lat;
} let long = geo.long;
if (lat === 0 || long === 0) { if (lat === 0 || long === 0) {
lat = 41.886406; lat = 41.886406;
long = -87.624225; long = -87.624225;
} }
if (self.state.locationType === 'provider') { if (self.state.locationType === 'provider') {
let url = `/v1/nemt/provider?lat=${lat}&long=${long}&limit=50&sortby=distance` Instance.getRawConn().get(`/v1/nemt/provider/participating?sort=distance&lat=${lat}&long=${long}`).then(res => {
Instance.getRawConn().get(url).then(res => {
let listItem = (<ListItem primaryText="No location found" key="-1" leftIcon={<MapsNearMe />} onClick={self.handleCurrentLocation} />) let listItem = (<ListItem primaryText="No location found" key="-1" leftIcon={<MapsNearMe />} onClick={self.handleCurrentLocation} />)
if (res.data.resultStatus === 'SUCCESS') { if (res.data.length > 0) {
const p = res.data.providers[0]; const result = res.data[0];
const streetNumber = p.streetName_1.split(' ')[0] const streetNumber = result.address.street_address_1.split(' ')[0]
let clickResult = { let clickResult = {
id: p.mukId, id: result.muk_id,
address: `${p.streetName_1}, ${p.cityName}, ${p.state} (${p.zipCode.substr(0, 5)})`, address: `${result.address.street_address_1}, ${result.address.city}, ${result.address.state} (${result.address.zipcode})`,
lat: parseFloat(p.latitude), lat: result.address.lat,
lng: parseFloat(p.longitude), lng: result.address.long,
name: p.providerName, name: result.name,
type: 'provider', type: "provider",
raw: p, raw: result,
street_number: streetNumber, street_number: streetNumber,
street: p.streetName_1.replace(streetNumber, '').trim(), street: result.address.street_address_1.replace(streetNumber, '').trim(),
city: p.cityName, city: result.address.city,
state: p.state, state: result.address.state,
zipcode: p.zipCode.substr(0, 5), zipcode: result.address.zipcode.substring(0, 5),
country: p.country, country: result.address.country,
saved: false, saved: false,
} }
if (p.fivePartKeyGroups.length > 0) { clickResult.address = `${clickResult.street_number} ${clickResult.street}, ${clickResult.city}`
clickResult.npi = p.fivePartKeyGroups[0].providerNum;
}
self.handlePlaceChanged(clickResult) self.handlePlaceChanged(clickResult)
//listItem = (<ListItem primaryText={clickResult.name} secondaryText={clickResult.address} key={clickResult.muk_id} leftIcon={<MapsNearMe />} onClick={(event) => self.handlePlaceChanged(clickResult)} />)
} }
//self.setState(Object.assign(self.state, { currentLocation: listItem }));
}).catch(console.error); }).catch(console.error);
} else { } else {
var location = new google.maps.LatLng(lat, long); var location = new google.maps.LatLng(lat, long);
@@ -1335,14 +1131,13 @@ export class NEMTLocation extends React.Component {
{customAddresses} {customAddresses}
<ListItem primaryText="Add Custom Shortcut" rightIcon={<ArrowDropRight />} leftIcon={<MapsLocalHospital />} onClick={(e) => this.handleAddAddress(e, 'custom')} /> <ListItem primaryText="Add Custom Shortcut" rightIcon={<ArrowDropRight />} leftIcon={<MapsLocalHospital />} onClick={(e) => this.handleAddAddress(e, 'custom')} />
</List>) </List>)
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} />) 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} />)
} else { } else {
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} />) 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} />)
} }
let listItem = ( let listItem = (
<div className="" id="container"> <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} {autosuggest}
<List> <List>
{this.state.currentLocation} {this.state.currentLocation}
@@ -1356,21 +1151,8 @@ export class NEMTLocation extends React.Component {
<List style={customListStyle}> <List style={customListStyle}>
{this.state.nearbyPlaces} {this.state.nearbyPlaces}
</List> </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) { if (this.state.addLocation) {
listItem = ( listItem = (
<div className="" id="container"> <div className="" id="container">

View File

@@ -156,8 +156,14 @@ class SignUp extends React.Component {
}; };
handlePhone = (event) => { handlePhone = (event) => {
let phone = event.target.value;
if (phone.indexOf("+1") < 0 && phone.length == 10) {
phone = "+1" + phone;
phone = phone.substring(0, 12);
}
const user = this.props.user; const user = this.props.user;
user.phonenumber = event.target.value;; user.phonenumber = phone;
if (this.props.onUserChanged) { if (this.props.onUserChanged) {
this.props.onUserChanged(user); this.props.onUserChanged(user);
} }
@@ -668,14 +674,10 @@ class VerticalNonLinear extends React.Component {
let self = state; let self = state;
const { stepIndex } = self.state; const { stepIndex } = self.state;
//console.log('Step Index: ', stepIndex) console.log('Step Index: ', stepIndex)
switch (stepIndex) { switch (stepIndex) {
case 1: case 0:
const eligibility = { const eligibility = {
"provider": {
"provider_npi": self.state.destination.raw.fivePartKeyGroups[0].providerNum,
"provider_name": self.state.destination.raw.providerName
},
"subscriber": { "subscriber": {
"patient_type": self.state.user.type, "patient_type": self.state.user.type,
"subscriber_id": self.state.user.member, "subscriber_id": self.state.user.member,
@@ -686,12 +688,10 @@ class VerticalNonLinear extends React.Component {
"demographic_info": { "demographic_info": {
"date_of_birth": self.state.user.birthdate, "date_of_birth": self.state.user.birthdate,
"gender": self.state.user.gender "gender": self.state.user.gender
}, }
"user": self.state.user,
} }
}; };
console.log(JSON.stringify(eligibility));
Instance.getRawConn().post('/v1/nemt/eligibility', eligibility).then(function (res) { Instance.getRawConn().post('/v1/nemt/eligibility', eligibility).then(function (res) {
self.setState(Object.assign(self.state, { stepIndex: stepIndex + 1, user: res.data })); self.setState(Object.assign(self.state, { stepIndex: stepIndex + 1, user: res.data }));
}).catch(err => { }).catch(err => {
@@ -715,42 +715,18 @@ class VerticalNonLinear extends React.Component {
"gender": self.state.user.gender, "gender": self.state.user.gender,
"member": self.state.user.member, "member": self.state.user.member,
"birthdate": self.state.user.birthdate, "birthdate": self.state.user.birthdate,
"type": "S", "type": self.state.user.type,
"email": self.state.user.email, "email": self.state.user.email,
"phonenumber": self.state.user.phonenumber "phonenumber": self.state.user.phonenumber
}, },
"visit_datetime": self.state.visitTime, "visit_datetime": self.state.visitTime,
"pickup_datetime": self.state.pickupTime, "pickup_datetime": self.state.pickupTime,
"external_id": self.state.visit_external_id, "external_id": self.state.visit_external_id,
"raw_provider": self.state.destination.raw "provider": self.state.destination.raw
}; };
Instance.getRawConn().post('/v1/nemt/visits/', visit).then(function (res) { Instance.getRawConn().post('/v1/nemt/visits/', visit).then(function (res) {
const returnMessage = [ window.location.href = '/#/app/table/visits';
{
message: `Member: ${res.data.user.name} (${res.data.user.member}`
},
{
message: `Gender: ${res.data.user.gender}`
},
{
message: `Birth date: ${visit.user.type}`
},
{
message: `Member Type: ${res.data.user.birthdate}`
},
{
message: `Provider: ${res.data.provider.name}`
},
{
message: `Date: ${res.data.visit_datetime}`
}]
self.setState(Object.assign(self.state, {
showValidationErrors: true,
validationErrors: returnMessage,
errorTitle: "Visit Added"
}));
}).catch(console.error); }).catch(console.error);
break; break;
default: default:
@@ -884,7 +860,7 @@ class VerticalNonLinear extends React.Component {
)} )}
{step === 2 && ( {step === 2 && (
<RaisedButton <RaisedButton
label="Add Visit" label="Confirm"
disableTouchRipple disableTouchRipple
disableFocusRipple disableFocusRipple
primary primary
@@ -1117,7 +1093,7 @@ class VerticalNonLinear extends React.Component {
<div className="box-body padding-xs"> <div className="box-body padding-xs">
<div style={{ maxWidth: 380, margin: 'auto' }}> <div style={{ maxWidth: 380, margin: 'auto' }}>
<ValidationErrorsInfoDialog open={this.state.showValidationErrors} errorMessages={this.state.validationErrors} onDismiss={this.handleValidationErrosDialogDismiss.bind(this)} errorTitle={this.state.errorTitle} /> <ValidationErrorsInfoDialog open={this.state.showValidationErrors} errorMessages={this.state.validationErrors} onDismiss={this.handleValidationErrosDialogDismiss.bind(this)} />
<Stepper <Stepper
activeStep={this.state.stepIndex} activeStep={this.state.stepIndex}
linear={false} linear={false}
@@ -1125,18 +1101,6 @@ class VerticalNonLinear extends React.Component {
> >
<Step> <Step>
<StepButton onClick={() => this.setState({ stepIndex: 0 })}> <StepButton onClick={() => this.setState({ stepIndex: 0 })}>
Provider
</StepButton>
<StepContent>
<form role="form">
<NEMTLocation type="flat" data={this.state} title={"Provider"} value={""} buttonvalue={this.state.buttonProviderText} onPlaceChanged={(provider) => this.handleProviderChanged(provider, this)} fontSize={12} locationType="provider" loadSuggestion={true} address={this.state.destination} />
{/* <div className="divider" /> */}
</form>
{this.renderStepActions(1, this)}
</StepContent>
</Step>
<Step>
<StepButton onClick={() => this.setState({ stepIndex: 1 })}>
Member Member
</StepButton> </StepButton>
<StepContent> <StepContent>
@@ -1149,6 +1113,21 @@ class VerticalNonLinear extends React.Component {
{this.renderStepActions(0, this)} {this.renderStepActions(0, this)}
</StepContent> </StepContent>
</Step> </Step>
<Step>
<StepButton onClick={() => this.setState({ stepIndex: 1 })}>
Provider
</StepButton>
<StepContent>
<form role="form">
<NEMTLocation type="flat" data={this.state} title={"Provider"} value={""} buttonvalue={this.state.buttonProviderText} onPlaceChanged={(provider) => this.handleProviderChanged(provider, this)} fontSize={12} locationType="provider" loadSuggestion={true} address={this.state.destination} />
{/* <div className="divider" /> */}
</form>
{this.renderStepActions(1, this)}
</StepContent>
</Step>
<Step> <Step>
<StepButton onClick={() => this.setState({ stepIndex: 2 })}> <StepButton onClick={() => this.setState({ stepIndex: 2 })}>
Visit Details Visit Details
@@ -1180,7 +1159,7 @@ class VerticalNonLinear extends React.Component {
{/* <TabsSection /> */} {/* <TabsSection /> */}
{this.renderStepActions(2, this)} {this.renderStepActions(1, this)}
</StepContent> </StepContent>
</Step> </Step>

View File

@@ -40,7 +40,7 @@ const getDTList = function (member) {
member.forEach((r, i) => { member.forEach((r, i) => {
let bookRide = ''; let bookRide = '';
if (r.trip_type.key === 'no_trip') { if (r.trip_type.key === 'no_trip') {
bookRide = (<a href={`/#/app/form/visitride/${r.visit_uuid}`}>Book Ride </a>) bookRide = (<a href={`/#/app/form/visitride/${r.visit_uuid}`}>Book Ride</a>)
} }
list.push( list.push(
@@ -48,8 +48,8 @@ const getDTList = function (member) {
<td>{moment(r.visit_datetime).format('MM/DD/YYYY - h:mm a')}</td> <td>{moment(r.visit_datetime).format('MM/DD/YYYY - h:mm a')}</td>
<td><a href={""}>{r.provider.name}</a></td> <td><a href={""}>{r.provider.name}</a></td>
<td><a href={"/#/app/member/" + r.user.useruuid}>{r.user.name}</a></td> <td><a href={"/#/app/member/" + r.user.useruuid}>{r.user.name}</a></td>
<td>{bookRide}</td>
<td> <RoadTripLink rides={r.rides} isOpened={false} currentRide={null} visit={r} onRideClick={handleRide} /> {bookRide} </td> <td><RoadTripLink rides={r.rides} isOpened={false} currentRide={null} visit={r} onRideClick={handleRide} /></td>
<td><a href={"/#/app/member/" + r.user.useruuid}>{r.user.member}</a></td> <td><a href={"/#/app/member/" + r.user.useruuid}>{r.user.member}</a></td>
<td>{r.provider.provider_uuid}</td> <td>{r.provider.provider_uuid}</td>
<td>{r.visit_uuid}</td> <td>{r.visit_uuid}</td>
@@ -236,7 +236,7 @@ class DatatableComponent extends React.Component {
<th>Visit Time</th> <th>Visit Time</th>
<th>Provider</th> <th>Provider</th>
<th>Member </th> <th>Member </th>
{/* <th>Ride</th> */} <th>Ride</th>
<th>Rides </th> <th>Rides </th>
<th>Subscriber ID</th> <th>Subscriber ID</th>
<th>Provider ID</th> <th>Provider ID</th>

View File

@@ -8,10 +8,6 @@ import Dialog from 'material-ui/Dialog';
import Instance from '../../../components/Connection'; import Instance from '../../../components/Connection';
import {
loggedUser
} from 'utils/authorization';
class Login extends React.Component { class Login extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
@@ -79,9 +75,8 @@ class Login extends React.Component {
let auth = res.data; let auth = res.data;
state.setCookie('token', auth.token, auth.valid_time); state.setCookie('token', auth.token, auth.valid_time);
localStorage.setItem('loggedUser', JSON.stringify(auth.user)); localStorage.setItem('loggedUser', JSON.stringify(auth.user));
Instance.setToken(auth.token);
loggedUser.update(); Instance.setToken(auth.token);
location.href = '/#/'; location.href = '/#/';
}).catch(function (err) { }).catch(function (err) {

View File

@@ -54,7 +54,8 @@ class SignUp extends React.Component {
this.clickEvent = this.clickEvent.bind(this); this.clickEvent = this.clickEvent.bind(this);
} }
componentDidMount = () => { } componentDidMount = () => {
}
buttonValidated = () => { buttonValidated = () => {
let validated = true; let validated = true;
@@ -127,7 +128,7 @@ class SignUp extends React.Component {
"pass": this.state.pass, "pass": this.state.pass,
}; };
Instance.setToken(null).post('/v1/selfregister/', user).then(function (res) { Instance.getRawConn().post('/v1/selfregister/', user).then(function (res) {
localStorage.removeItem('loggedUser'); localStorage.removeItem('loggedUser');
location.href = '/#/login'; location.href = '/#/login';
}).catch(function (err) { }).catch(function (err) {

View File

@@ -3,11 +3,11 @@ import { contains } from 'ramda';
import normalizeRoles from './normalizeRoles'; import normalizeRoles from './normalizeRoles';
const loggedUser = () => { const loggedUser = JSON.parse(window.localStorage.getItem('loggedUser'));
let user = JSON.parse(window.localStorage.getItem('loggedUser'));
const anyOf = (...profiles) => { if (loggedUser) {
const userRole = user.profiles[0]; loggedUser.anyOf = (...profiles) => {
const userRole = loggedUser.profiles[0];
const userOrgType = userRole.organization.type.key; const userOrgType = userRole.organization.type.key;
const roles = normalizeRoles(profiles); const roles = normalizeRoles(profiles);
@@ -22,18 +22,7 @@ const loggedUser = () => {
} }
return false; 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;