{"size": 1054, "ext": "js", "max_stars_repo_path": "client/routes.js", "max_stars_repo_name": "jasonxhang/TTP-FS", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "client/routes.js", "max_issues_repo_name": "jasonxhang/TTP-FS", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "client/routes.js", "max_forks_repo_name": "jasonxhang/TTP-FS", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 25.7073170732, "max_line_length": 103, "alphanum_fraction": 0.6451612903}
import React from 'react'
import {Route, Switch} from 'react-router-dom'
import {
  NotFound,
  Home,
  Login,
  Signup,
  StockPage,
  Transactions,
  Portfolio
} from './components'
import {connect} from 'react-redux'

const Routes = props => (
  <Switch>
    <Route path="/login" component={Login} />
    <Route path="/signup" component={Signup} />
    <Route exact path="/" component={Home} />
    <Route path="/stock/:ticker" component={StockPage} />

    {!!props.isLoggedIn && (
      <Switch>
        <Route path="/transactions" component={Transactions} />
        <Route path="/portfolio" component={Portfolio} />
      </Switch>
    )}

    {/* Finally, catch all unmatched routes */}
    <Route component={NotFound} />
  </Switch>
)

const mapState = state => {
  return {
    // Being 'logged in' for our purposes will be defined has having a state.user that has a truthy id.
    // Otherwise, state.user will be an empty object, and state.user.id will be falsey
    isLoggedIn: !!state.user.id
  }
}
export default connect(mapState)(Routes)
