fleet/frontend/components/AuthenticatedAdminRoutes/AuthenticatedAdminRoutes.jsx
Mike Stone ee3d96eb53 Update eslint (#337)
* Updates eslint packages

* Expected parentheses around arrow function argument having a body with curly braces

* Prop type `object` is forbidden

* Visible, non-interactive elements should not have mouse or keyboard event listeners

* Prop type is defined but not used

* Unexpected use of file extension "jsx"

* Expected 'this' to be used by class method

* HTML entities must be escaped

* Prevent default behavior on more options button click
2016-10-21 19:13:41 -04:00

47 lines
917 B
JavaScript

import React, { Component, PropTypes } from 'react';
import { connect } from 'react-redux';
import { push } from 'react-router-redux';
import paths from '../../router/paths';
import userInterface from '../../interfaces/user';
export class AuthenticatedAdminRoutes extends Component {
static propTypes = {
children: PropTypes.node,
dispatch: PropTypes.func,
user: userInterface,
};
componentWillMount () {
const { dispatch, user: { admin } } = this.props;
const { HOME } = paths;
if (!admin) {
dispatch(push(HOME));
}
return false;
}
render () {
const { children, user } = this.props;
if (!user) {
return false;
}
return (
<div>
{children}
</div>
);
}
}
const mapStateToProps = (state) => {
const { user } = state.auth;
return { user };
};
export default connect(mapStateToProps)(AuthenticatedAdminRoutes);