Upstream sync

This commit is contained in:
Senad Uka
2018-05-30 08:52:10 +02:00
parent 8e52651172
commit 04debaf3e9
14 changed files with 540 additions and 233 deletions

View File

@@ -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,
};
};

View File

@@ -6,10 +6,11 @@ import { hashHistory } from 'react-router';
import {
loggedUser,
planScheduler,
providerScheduler,
visitReporter,
} from 'utils/authorization';
const ImgIconButtonStyle = {
width: '60px',
height: '60px'
@@ -34,6 +35,7 @@ class NavRightList extends React.Component {
handleChange = (event, value) => {
hashHistory.push(value);
}
componentDidMount() {
const user = JSON.parse(localStorage.getItem('loggedUser'));
if (user) {
@@ -46,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>}
@@ -63,15 +67,6 @@ class NavRightList extends React.Component {
leftIcon={<i className="material-icons">account_circle</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>}
/>
}
{loggedUser.anyOf(visitReporter) &&
<MenuItem
onTouchTap={(e) => this.handleChange(e, `/app/form/visit/${this.state.useruuid}`)}
@@ -81,6 +76,17 @@ class NavRightList extends React.Component {
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"

View File

@@ -8,61 +8,70 @@ const defaultDialogHeight = 100; //px
const dialogHeightPerLine = 25; //px
export class ValidationErrorsInfoDialog extends React.Component {
state = {
constructor(props) {
super(props)
this.props = props;
this.state = {
open: this.props.open,
}
componentWillReceiveProps(newProps){
this.setState({open: newProps.open});
}
handleOpen = () => {
this.setState({ open: true });
};
handleClose = () => {
this.setState({ open: false });
this.props.onDismiss();
};
render() {
const actions = [
<FlatButton
label="Dismiss"
primary={true}
onClick={this.handleClose}
/>,
];
return (
<div className="container">
{
this.state.open &&
<Dialog
title={this.props.title ? this.props.title : 'Error'}
isDraggable={this.props.draggable ? this.props.draggable : false}
buttons={actions}
hasCloseIcon={false}
modal={this.props.modal ? this.props.modal : false}
height={defaultDialogHeight + this.props.errorMessages.length * dialogHeightPerLine}
>
{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;
}
})}
</Dialog>
}
</div>
);
title: "Errors",
}
}
module.exports = ValidationErrorsInfoDialog;
componentWillReceiveProps(newProps) {
let title = this.state.title;
if (newProps.errorTitle) {
title = newProps.errorTitle;
}
this.setState({ open: newProps.open, title: title });
}
handleOpen = () => {
this.setState({ open: true });
};
handleClose = () => {
this.setState({ open: false });
this.props.onDismiss();
};
render() {
const actions = [
<FlatButton
label="Dismiss"
primary={true}
onClick={this.handleClose}
/>,
];
return (
<div className="container">
{
this.state.open &&
<Dialog
title={this.props.title ? this.props.title : 'Error'}
isDraggable={this.props.draggable ? this.props.draggable : false}
buttons={actions}
hasCloseIcon={false}
modal={this.props.modal ? this.props.modal : false}
height={defaultDialogHeight + this.props.errorMessages.length * dialogHeightPerLine}
>
{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;
}
})}
</Dialog>
}
</div>
);
}
}
module.exports = ValidationErrorsInfoDialog;

View File

@@ -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>
);
}