diff --git a/package.json b/package.json index 1a72838..c46d7c2 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "@testing-library/jest-dom": "^5.11.4", "@testing-library/react": "^11.1.0", "@testing-library/user-event": "^12.1.10", + "axios": "^0.21.1", "husky": "^4.3.0", "lodash": "^4.17.20", "moment": "^2.29.1", @@ -23,6 +24,7 @@ "redux-devtools-extension": "^2.13.8", "redux-promise-middleware": "^6.1.2", "redux-thunk": "^2.3.0", + "uuid": "^8.3.2", "web-vitals": "^0.2.4", "yarn": "^1.22.10" }, diff --git a/src/App.js b/src/App.js index cfafb66..e2b9330 100644 --- a/src/App.js +++ b/src/App.js @@ -1,3 +1,4 @@ +import React, { useEffect } from "react"; import "./App.css"; import { Switch, Route } from "react-router-dom"; import FrontPage from "./components/FrontPage"; @@ -11,19 +12,35 @@ import Footer from "./components/Footer"; import ContactUs from "./components/ContactUs"; import FAQ from "./components/FAQ"; import Header from "./components/Header/Header"; -import { api } from "./store"; +import { actions, api } from "./store"; import classPage from "./components/classPage/classPage"; import ScrollToTop from "./components/ScrollToTop"; -import { connect } from "react-redux"; import Login from "./components/auth/Login"; import SignUp from "./components/auth/SignUp"; import BreadCrumb from "./components/Breadcrumbs/Breadcrumbs"; import Cat from "./components/Cat"; +import { loadUser } from "./actions/auth"; +import setAuthToken from "./utils/setAuthToken"; +import Dashboard from "./components/dashboard/Dashboard"; +import { connect } from "./lib/stateToRedux"; +import CreateProfile from "./components/Profile/CreateProfile"; + +if (localStorage.token) { + setAuthToken(localStorage.token); +} function App(props) { + api.auth.get().then((data) => + actions.auth.auth.update({ + isAuthenicated: true, + loaded: false, + user: data, + }) + ); const { books, categories } = props; api.book.read(); api.category.read(); + api.user.get(); let cats = Object.values(categories); // covert categories to array const getBookTitle = (props) => { const id = props.match.params.id; @@ -99,6 +116,11 @@ function App(props) { ); })} + + {/*When connecting these needs to be */} + + + {/**/}