From 93bbc88059acefa978b4fd6d997031926e1a9b86 Mon Sep 17 00:00:00 2001 From: sarL3y Date: Fri, 17 Jan 2020 01:11:41 -0800 Subject: [PATCH 1/7] Add dashboard, add auth, add login --- client/src/App.js | 23 ++- client/src/components/DashboardUsers.js | 54 ++++++ client/src/components/Navbar.js | 13 +- client/src/context/authContext.js | 93 ++++++++++ client/src/hooks/useAuth.js | 9 + client/src/hooks/useIsLoggedIn.js | 31 ++++ client/src/index.css | 4 +- client/src/pages/AdminDashboard.js | 231 +++++++++++++++++++++--- client/src/pages/AdminLogin.js | 88 ++++++--- client/src/pages/Home.js | 4 - client/src/sass/AdminLogin.scss | 17 ++ client/src/sass/Dashboard.scss | 105 ++++++++++- client/src/sass/DashboardUsers.scss | 5 + client/src/sass/Home.scss | 10 +- routers/users.router.js | 36 +++- 15 files changed, 646 insertions(+), 77 deletions(-) create mode 100644 client/src/components/DashboardUsers.js create mode 100644 client/src/context/authContext.js create mode 100644 client/src/hooks/useAuth.js create mode 100644 client/src/hooks/useIsLoggedIn.js create mode 100644 client/src/sass/AdminLogin.scss create mode 100644 client/src/sass/DashboardUsers.scss diff --git a/client/src/App.js b/client/src/App.js index 8d58bb31..20f2d463 100644 --- a/client/src/App.js +++ b/client/src/App.js @@ -1,4 +1,5 @@ import React from 'react'; +import { ProvideAuth } from './context/authContext'; import { Route } from 'react-router-dom'; import Home from './pages/Home'; @@ -29,17 +30,19 @@ const routes = [ function App(props) { return ( -
-
- -
- {routes.map(({ path, Component }) => ( - - ))} -
-
+ +
+
+ +
+ {routes.map(({ path, Component }) => ( + + ))} +
+
+
-
+ ); } diff --git a/client/src/components/DashboardUsers.js b/client/src/components/DashboardUsers.js new file mode 100644 index 00000000..6565ded8 --- /dev/null +++ b/client/src/components/DashboardUsers.js @@ -0,0 +1,54 @@ +import React, { useState, useEffect } from 'react'; +import { Link } from 'react-router-dom'; + +import '../sass/DashboardUsers.scss'; +// import '../sass/EventsContainer-media-queries.scss'; + +const DashboardUsers = (props) => { + // const [isLoading, setIsLoading] = useState(false); + const [users, setUsers] = useState([]); + // const [isError, setIsError] = useState(false); + + async function fetchData() { + try { + const res = await fetch("/api/users"); + const resJson = await res.json(); + + setUsers(resJson); + } catch(error) { + alert(error); + } + } + + useEffect(() => { + fetchData(); + + }, []); + + return ( +
+
+
    + {users.map((user, index) => { + return ( +
  • +
    +
    +
    {user.name.firstName} {user.name.lastName}
    +
    +
    +

    Current Role: {user.currentRole}

    +

    Desired Role: {user.desiredRole}

    +
    +
    +
  • + ) + })} +
+
+
+ ) +}; + +export default DashboardUsers; + \ No newline at end of file diff --git a/client/src/components/Navbar.js b/client/src/components/Navbar.js index 65a33c66..b532fd92 100644 --- a/client/src/components/Navbar.js +++ b/client/src/components/Navbar.js @@ -4,16 +4,21 @@ import { Link , withRouter } from 'react-router-dom'; import '../sass/Navbar.scss'; const Navbar = (props) => { - console.log(props); return (