{"size": 750, "ext": "js", "max_stars_repo_path": "client/src/containers/privateRoute.js", "max_stars_repo_name": "OpenChemistry/experimentaldataplatform", "max_stars_repo_stars_event_min_datetime": "2018-10-10T20:38:14.000Z", "max_stars_repo_stars_event_max_datetime": "2020-07-01T13:14:59.000Z", "max_issues_repo_path": "client/src/containers/privateRoute.js", "max_issues_repo_name": "OpenChemistry/experimentaldataplatform", "max_issues_repo_issues_event_min_datetime": "2018-09-06T22:31:53.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-24T13:22:04.000Z", "max_forks_repo_path": "client/src/containers/privateRoute.js", "max_forks_repo_name": "OpenChemistry/edp", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 2, "max_issues_count": 23, "max_forks_count": null, "avg_line_length": 20.2702702703, "max_line_length": 54, "alphanum_fraction": 0.5733333333}
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { auth } from '@openchemistry/girder-redux';
import { Route } from 'react-router-dom';

import HomePage from '../components/home';


class PrivateRoute extends Component {
  render() {
    const {component, me, ...rest} = this.props;
    let RenderComponent = component;
    if (me) {
      return (
        <Route
          {...rest}
          render={(props) => {
            return <RenderComponent {...props}/>;
          }}
        />
      );
    } else {
      return (
        <HomePage/>
      );
    }
  }
}

function mapStateToProps(state) {
  return {
    me: auth.selectors.getMe(state)
  }
}

export default connect(mapStateToProps)(PrivateRoute);
