{"size": 817, "ext": "js", "max_stars_repo_path": "src/common/connection.js", "max_stars_repo_name": "erikjchan/ballroom", "max_stars_repo_stars_event_min_datetime": "2020-02-01T14:43:12.000Z", "max_stars_repo_stars_event_max_datetime": "2021-02-01T12:58:07.000Z", "max_issues_repo_path": "src/common/connection.js", "max_issues_repo_name": "erikjchan/ballroom", "max_issues_repo_issues_event_min_datetime": "2017-04-29T18:32:56.000Z", "max_issues_repo_issues_event_max_datetime": "2017-04-29T18:32:56.000Z", "max_forks_repo_path": "src/common/connection.js", "max_forks_repo_name": "ejc233/ballroom", "max_forks_repo_forks_event_min_datetime": "2020-02-01T14:43:14.000Z", "max_forks_repo_forks_event_max_datetime": "2020-02-01T14:43:14.000Z"}
{"max_stars_count": 2, "max_issues_count": 1, "max_forks_count": 1, "avg_line_length": 27.2333333333, "max_line_length": 77, "alphanum_fraction": 0.6805385557}
import { connect } from 'react-redux'

/**
 * This connects our component to redux,
 * which is primarily used for authentication
 * with Auth0; the user profile and its roles
 * are in the Redux store.
 * It could be further extended to handle other
 * state.
 */
export default (component) => connect((state) => {
  const { auth, app, selected } = state
  if (!selected.competition && localStorage.getItem('competition')) {
    selected.competition = JSON.parse(localStorage.getItem('competition'))
  }
  const { isAuthenticated, errorMessage, isAdmin } = auth
  const profile = auth.profile || {}
  const role = (auth.profile && Object.keys(auth.profile.roles)[0]) || 'none'
  profile.role = role

  return {
    errorMessage,
    isAuthenticated,
    isAdmin,
    profile,
    app,
    selected
  }
})(component)
