Upstream sync

This commit is contained in:
Senad Uka
2018-05-29 17:02:50 +02:00
parent 3969863cbf
commit 8e52651172
24 changed files with 657 additions and 252 deletions

View File

@@ -5,10 +5,6 @@ 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) {
@@ -57,9 +53,8 @@ class MainApp extends React.Component {
<Footer />
</div>
</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>
);
}

View File

@@ -151,9 +151,7 @@ export class NEMTLocation extends React.Component {
long: 0,
name: '',
address: '',
},
searchingProvider: false,
providerList: [],
}
}
this.addCustomLabel = this.addCustomLabel.bind(this);
@@ -259,7 +257,7 @@ export class NEMTLocation extends React.Component {
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 {
@@ -345,7 +343,7 @@ export class NEMTLocation extends React.Component {
buttonText = buttonText.substring(0, self.state.textSize);
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);
}
@@ -571,7 +569,7 @@ export class NEMTLocation extends React.Component {
updateTextSearch(searchText, dtSource, params) {
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) {
let lat = 0;
let long = 0;
@@ -620,11 +618,9 @@ export class NEMTLocation extends React.Component {
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;
return p;
});
this.setState(Object.assign(this.state, { providerList: providers }));
this.setState(Object.assign(this.state, { providers: providers }));
dtSource = self.state.providers;
}
});
@@ -1335,14 +1331,14 @@ 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={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 {
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 = (
<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} />
<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} />
{autosuggest}
<List>
{this.state.currentLocation}
@@ -1356,21 +1352,8 @@ 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">

View File

@@ -405,8 +405,8 @@ class VerticalNonLinear extends React.Component {
},
return_time: new Date(),
pickupTimeHide: false,
showValidationErrors: false,
validationErrors: [],
showValidationErrors:false,
validationErrors:[]
};
}
@@ -524,8 +524,8 @@ class VerticalNonLinear extends React.Component {
if (error.response.status === 422) {
//Unprocessable Entity (validation failed)
self.setState(Object.assign(self.state, {
showValidationErrors: true,
validationErrors: error.response.data.data
showValidationErrors:true,
validationErrors:error.response.data.data
}));
}
});
@@ -896,8 +896,8 @@ 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}
linear={false}

View File

@@ -35,7 +35,7 @@ import Popover from 'material-ui/Popover';
import ValidationErrorsInfoDialog from '../../../../../../../components/Shared/ValidationErrorsInfoDialog';
let DateTimeFormat;
const roundingTime = 1000 * 60 * 5; //5 minutes
DateTimeFormat = global.Intl.DateTimeFormat;
@@ -564,16 +564,18 @@ class VerticalNonLinear extends React.Component {
constructor(props) {
super(props);
let dateNow = new Date();
this.state = {
stepIndex: 0,
rideTypeValue: 0,
providerID: 0,
providerName: '',
visitDate: new Date(),
visitTime: new Date(),
visitTime: new Date(Math.round(dateNow.getTime() / roundingTime) * roundingTime),
pickupLocation: null,
pickupTime: new Date(),
pickupTimeReturn: new Date(),
pickupTime: new Date(Math.round(dateNow.getTime() / roundingTime) * roundingTime),
pickupTimeReturn: new Date(Math.round(dateNow.getTime() / roundingTime) * roundingTime),
pickupTimeReturnDisplayMode: 'none',
open: false,
message: 'Adding Visit',
@@ -638,10 +640,12 @@ class VerticalNonLinear extends React.Component {
});
}
let visitTime = new Date(new Date().getTime() + (1 * 60 * 60 * 1000));
let visitDate = visitTime;
let pickupTime = new Date(visitTime.getTime() - (0.5 * 60 * 60 * 1000));
let pickupTimeReturn = new Date(visitTime.getTime() - (0.5 * 60 * 60 * 1000));
let date = new Date();
let visitTime = new Date(Math.round((date.getTime() + (1 * 60 * 60 * 1000)) / roundingTime) * roundingTime);
let visitDate = date;
let pickupTime = new Date(Math.round((visitTime.getTime() - (0.5 * 60 * 60 * 1000)) / roundingTime) * roundingTime);
let pickupTimeReturn = new Date(Math.round((visitTime.getTime() - (0.5 * 60 * 60 * 1000)) / roundingTime) * roundingTime);
this.setState(Object.assign(this.state, {
visitDate: visitDate,
@@ -715,42 +719,18 @@ class VerticalNonLinear extends React.Component {
"gender": self.state.user.gender,
"member": self.state.user.member,
"birthdate": self.state.user.birthdate,
"type": "S",
"type": self.state.user.type,
"email": self.state.user.email,
"phonenumber": self.state.user.phonenumber
},
"visit_datetime": self.state.visitTime,
"pickup_datetime": self.state.pickupTime,
"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) {
const returnMessage = [
{
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"
}));
window.location.href = '/#/app/table/visits';
}).catch(console.error);
break;
default:
@@ -792,10 +772,10 @@ class VerticalNonLinear extends React.Component {
handleDate(event, date, state) {
let self = state
let visitTime = new Date(date.getTime() + (1 * 60 * 60 * 1000));
let visitTime = new Date(Math.round((date.getTime() + (1 * 60 * 60 * 1000)) / roundingTime) * roundingTime);
let visitDate = date;
let pickupTime = new Date(visitTime.getTime() - (0.5 * 60 * 60 * 1000));
let pickupTimeReturn = new Date(visitTime.getTime() - (0.5 * 60 * 60 * 1000));
let pickupTime = new Date(Math.round((visitTime.getTime() - (0.5 * 60 * 60 * 1000)) / roundingTime) * roundingTime);
let pickupTimeReturn = new Date(Math.round((visitTime.getTime() - (0.5 * 60 * 60 * 1000)) / roundingTime) * roundingTime);
self.setState(Object.assign(self.state, {
visitDate: visitDate,
@@ -884,7 +864,7 @@ class VerticalNonLinear extends React.Component {
)}
{step === 2 && (
<RaisedButton
label="Add Visit"
label="Confirm"
disableTouchRipple
disableFocusRipple
primary
@@ -1117,7 +1097,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)} errorTitle={this.state.errorTitle} />
<ValidationErrorsInfoDialog open={this.state.showValidationErrors} errorMessages={this.state.validationErrors} onDismiss={this.handleValidationErrosDialogDismiss.bind(this)} />
<Stepper
activeStep={this.state.stepIndex}
linear={false}
@@ -1180,7 +1160,7 @@ class VerticalNonLinear extends React.Component {
{/* <TabsSection /> */}
{this.renderStepActions(2, this)}
{this.renderStepActions(1, this)}
</StepContent>
</Step>

View File

@@ -37,7 +37,8 @@ class SignUp extends React.Component {
validated: false,
memberType:"S",
showValidationErrors: false,
validationErrors:[]
validationErrors:[],
draggableDialog:false
}
componentDidMount = () => {
@@ -63,7 +64,8 @@ class SignUp extends React.Component {
"phonenumber": this.state.phonenumber,
"birthdate": this.state.birthdate.toISOString(),
"consent" : this.state.agreedTerms,
"type": this.state.memberType
"type": this.state.memberType,
"useruuid": "1234567"
// "eligibility": {
// "tracking_id": "1234567",
@@ -105,13 +107,26 @@ class SignUp extends React.Component {
// alert('NO benefits found for this member');
// }
}).catch(function (err) {
if (err.response.status === 422){
//Unprocessable Entity (validation failed)
state.setState(Object.assign(state.state, {showValidationErrors:true, validationErrors:err.response.data.data}))
}else{
console.log('Error to get eligibility: ', err);
alert('NO benefits found for this member');
this.handleRequestClose();
switch(err.response.status){
case 403:
//Forbidden (not eligible)
console.log(err.response.data);
let messageArray = [
{
message:err.response.data.message
}
]
state.setState(Object.assign(state.state, {showValidationErrors:true, validationErrors:messageArray, draggableDialog:false}))
break;
case 422:
//Unprocessable Entity (validation failed)
state.setState(Object.assign(state.state, {showValidationErrors:true, validationErrors:err.response.data.data, draggableDialog:true}))
break;
default:
console.log('Error to get eligibility: ', err);
alert('NO benefits found for this member');
this.handleRequestClose();
}
});
}
@@ -192,7 +207,7 @@ class SignUp extends React.Component {
return (
<form className="">
<fieldset>
<ValidationErrorsInfoDialog open = {this.state.showValidationErrors} errorMessages = {this.state.validationErrors} modal={true} onDismiss={this.handleValidationErrosDialogDismiss.bind(this)}/>
<ValidationErrorsInfoDialog open = {this.state.showValidationErrors} errorMessages = {this.state.validationErrors} draggable={this.state.draggableDialog} onDismiss={this.handleValidationErrosDialogDismiss.bind(this)}/>
<div className="form-group">
<TextField
floatingLabelText="First Name"

View File

@@ -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';

View File

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