{"size": 1245, "ext": "js", "max_stars_repo_path": "DeFi/gossamer/code/client/src/PrivateRoute.js", "max_stars_repo_name": "tarikbellamine/Beyond-Blockchain-Relay", "max_stars_repo_stars_event_min_datetime": "2019-06-24T17:43:14.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-27T22:11:06.000Z", "max_issues_repo_path": "DeFi/gossamer/code/client/src/PrivateRoute.js", "max_issues_repo_name": "tarikbellamine/Beyond-Blockchain-Relay", "max_issues_repo_issues_event_min_datetime": "2019-06-17T20:55:38.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-18T05:19:05.000Z", "max_forks_repo_path": "DeFi/gossamer/code/client/src/PrivateRoute.js", "max_forks_repo_name": "tarikbellamine/Beyond-Blockchain-Relay", "max_forks_repo_forks_event_min_datetime": "2019-06-20T20:14:43.000Z", "max_forks_repo_forks_event_max_datetime": "2020-03-23T15:15:25.000Z"}
{"max_stars_count": 17, "max_issues_count": 28, "max_forks_count": 36, "avg_line_length": 25.4081632653, "max_line_length": 75, "alphanum_fraction": 0.5879518072}
import React from 'react';
import { Route, Redirect } from 'react-router-dom';

const PrivateRoute = (
  {
    component: Component,
    auth,
    checkingSession,
    userData,
    getUserData,
    getTokenToUSDConversionRate,
    financialData,
    callSmartContractFunction,
    pollForUserDepositThenSupply,
    userStatus,
    amountSupplied,
    changeUserStatus,
    renderNavbar,
    ...rest
  },
) => {
  if (!checkingSession) {
    return (
      <Route
        {...rest}
        render={props => (
          auth.isAuthenticated() === true
            ? <Component {...props}
                userData={userData}
                financialData={financialData}
                getUserData={getUserData}
                getTokenToUSDConversionRate={getTokenToUSDConversionRate}
                callSmartContractFunction={callSmartContractFunction}
                pollForUserDepositThenSupply={pollForUserDepositThenSupply}
                userStatus={userStatus}
                amountSupplied={amountSupplied}
                changeUserStatus={changeUserStatus}
                renderNavbar={renderNavbar}
              />
            : <Redirect to='/' />
        )}
      />
    );
  }
  return null;
};

export default PrivateRoute;
