{"size": 1728, "ext": "js", "max_stars_repo_path": "src/App.js", "max_stars_repo_name": "Zack-Ballenger/front-end", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/App.js", "max_issues_repo_name": "Zack-Ballenger/front-end", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/App.js", "max_forks_repo_name": "Zack-Ballenger/front-end", "max_forks_repo_forks_event_min_datetime": "2020-03-05T09:07:18.000Z", "max_forks_repo_forks_event_max_datetime": "2020-03-05T09:07:18.000Z"}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": 1, "avg_line_length": 31.4181818182, "max_line_length": 75, "alphanum_fraction": 0.6435185185}
import React, { useEffect } from "react";
import "./App.css";
import { Route, Switch, Redirect } from "react-router-dom";
import PrivateRoute from "./components/PrivateRoute/PrivateRoute";
import NavBar from "./components/NavBar/NavBar";
import UserForm from "./components/Registration/UserForm";
import LogIn from "./components/Login/LogIn";
import Dashboard from "./components/Dashboard/Dashboard";
import { useDispatch, useSelector } from "react-redux";
import { updateApp, register, getUser } from "./store/actions/userActions";
import PlantView from "./components/PlantView/PlantView";
import PlantProfile from "./components/PlantProfile/PlantProfile";
import SettingsView from "./components/SettingsView/SettingsView";

function App() {
  const dispatch = useDispatch();
  const user = useSelector(state => state.userReducer.user);
  console.log("CURRENT REDUX USER: ", user);
  useEffect(() => {
    dispatch(updateApp());
    dispatch(
      register({ username: "new", password: "test", isPlantParent: 1 })
    );
  }, [dispatch]);

  return (
    <div className="App">
      <NavBar />
      <Switch>
        <Route exact path="/">
          <Redirect to="/login" />
        </Route>

        <Route exact path="/login" component={LogIn} />
        <Route exact path="/register" component={UserForm} />

        <PrivateRoute path="/dashboard">
          <Dashboard />
        </PrivateRoute>
        <PrivateRoute path="/profile">
          <PlantProfile />
        </PrivateRoute>
        <PrivateRoute path="/plant/:id">
          <PlantView />
        </PrivateRoute>
        <PrivateRoute path="/settings">
          <SettingsView />
        </PrivateRoute>
      </Switch>
    </div>
  );
}

export default App;
