Compare commits

..

2 Commits

Author SHA1 Message Date
GotPPay
4f872c0189 replace form validation messages with dialog 2018-05-28 14:06:15 +02:00
Senad Uka
372b3883a0 Upstream sync 2018-05-26 16:36:01 +02:00
11 changed files with 75 additions and 205 deletions

View File

@@ -8,10 +8,6 @@ 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(
@@ -59,15 +55,7 @@ const rootRoute = {
onChange: requireAuth,
onEnter: requireAuth,
component: require('./containers/App'),
indexRoute: {
onEnter: (nextState, replace) => {
if (loggedUser.anyOf(visitReporter)) {
replace('/app/form/visit/' + loggedUser.useruuid)
} else {
replace('/app/table/rides');
}
}
},
indexRoute: { onEnter: (nextState, replace) => replace('/app/table/rides') },
childRoutes: [
require('./routes/app'),
require('./routes/404'),

View File

@@ -4,13 +4,6 @@ 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'
@@ -35,7 +28,6 @@ class NavRightList extends React.Component {
handleChange = (event, value) => {
hashHistory.push(value);
}
componentDidMount() {
const user = JSON.parse(localStorage.getItem('loggedUser'));
if (user) {
@@ -48,8 +40,6 @@ 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>}
@@ -58,48 +48,33 @@ class NavRightList extends React.Component {
targetOrigin={{ horizontal: 'right', vertical: 'top' }}
menuStyle={{ minWidth: '150px' }}
>
{!loggedUser.anyOf(visitReporter) &&
<MenuItem
onTouchTap={(e) => this.handleChange(e, `/app/authorizedusers/${this.state.useruuid}`)}
primaryText="Profile"
style={{ fontSize: '14px', lineHeight: '48px' }}
innerDivStyle={listItemStyle}
leftIcon={<i className="material-icons">account_circle</i>}
/>
}
{loggedUser.anyOf(visitReporter) &&
<MenuItem
onTouchTap={(e) => this.handleChange(e, `/app/form/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"
innerDivStyle={listItemStyle}
style={{ fontSize: '14px', lineHeight: '48px' }}
leftIcon={<i className="material-icons">forward</i>}
/>
<MenuItem
onTouchTap={(e) => this.handleChange(e, `/app/authorizedusers/${this.state.useruuid}`)}
primaryText="Profile"
style={{ fontSize: '14px', lineHeight: '48px' }}
innerDivStyle={listItemStyle}
leftIcon={<i className="material-icons">account_circle</i>}
/>
<MenuItem
onTouchTap={(e) => this.handleChange(e, `/app/form/steppers/${this.state.useruuid}`)}
primaryText="Book Ride"
innerDivStyle={listItemStyle}
style={{ fontSize: '14px', lineHeight: '48px' }}
leftIcon={<i className="material-icons">mode_edit</i>}
/>
<MenuItem
onTouchTap={(e) => this.handleChange(e, `/login`)}
primaryText="Log Out"
innerDivStyle={listItemStyle}
style={{ fontSize: '14px', lineHeight: '48px' }}
leftIcon={<i className="material-icons">forward</i>}
/>
</IconMenu>
</li>
<li style={{ marginRight: '10px' }}><h6>{this.state.name}</h6></li>
<li style={{ marginRight: '10px' }}><h6>{this.state.name}</h6></li>
</ul>
);
}
}
module.exports = NavRightList;
);
}
}
module.exports = NavRightList;

View File

@@ -8,17 +8,11 @@ export class ValidationErrorsInfoDialog extends React.Component {
this.props = props;
this.state = {
open: this.props.open,
title: "Errors",
}
}
componentWillReceiveProps(newProps) {
let title = this.state.title;
if (newProps.errorTitle) {
title = newProps.errorTitle;
}
this.setState({ open: newProps.open, title: title });
this.setState({ open: newProps.open });
}
handleOpen = () => {
@@ -44,7 +38,7 @@ export class ValidationErrorsInfoDialog extends React.Component {
return (
<div>
<Dialog
title={this.state.title}
title="Errors"
actions={actions}
modal={this.props.modal ? this.props.modal : false}
open={this.state.open}
@@ -52,12 +46,14 @@ export class ValidationErrorsInfoDialog extends React.Component {
overlayStyle={{ backgroundColor: 'transparent' }}
>
{this.props.errorMessages.map(errorMessage => {
return (
<div>
<a>{errorMessage.message}</a>
<br />
</div>
);
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;
}
})}
</Dialog>
</div>

View File

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

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

@@ -715,42 +715,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:
@@ -884,7 +860,7 @@ class VerticalNonLinear extends React.Component {
)}
{step === 2 && (
<RaisedButton
label="Add Visit"
label="Confirm"
disableTouchRipple
disableFocusRipple
primary
@@ -1117,7 +1093,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 +1156,7 @@ class VerticalNonLinear extends React.Component {
{/* <TabsSection /> */}
{this.renderStepActions(2, this)}
{this.renderStepActions(1, this)}
</StepContent>
</Step>

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>

View File

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

View File

@@ -17,6 +17,8 @@ import Toggle from 'material-ui/Toggle';
import Snackbar from 'material-ui/Snackbar';
import Instance from '../../../components/Connection';
import ValidationErrorsInfoDialog from '../../../components/Shared/ValidationErrorsInfoDialog';
class SignUp extends React.Component {
constructor(props) {
super(props);
@@ -144,29 +146,13 @@ class SignUp extends React.Component {
});
}
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">
@@ -245,10 +231,7 @@ class SignUp extends React.Component {
<div className="form-group">
<p className="text-small">By clicking on sign up, you agree to <a href="javascript:;"><i>terms</i></a> and <a href="javascript:;"><i>privacy policy</i></a></p>
</div>
<div className="divider" />
<div className="form-group">
{validationErrors}
</div>
<ValidationErrorsInfoDialog open={this.state.showValidationErrors} errorMessages={this.state.validationErrors} onDismiss={this.handleValidationErrosDialogDismiss.bind(this)} />
</fieldset>
</form>
</div>

View File

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