From 81ee4c7d8a3e9b2d552385c28b733422e47e88a0 Mon Sep 17 00:00:00 2001 From: jveebs <83558932+jveebs@users.noreply.github.com> Date: Tue, 11 Apr 2023 17:53:11 -0400 Subject: [PATCH] Signup and Login working --- src/Main.js | 24 +++++++++------ src/components/NavBar.js | 11 +++---- src/index.js | 6 ++-- src/pages/Login.jsx | 42 ++++++++++++++++++++++++-- src/pages/Signup.jsx | 65 +++++++++++++++++++++++++++++++++++++--- src/pages/Welcome.jsx | 4 +-- 6 files changed, 125 insertions(+), 27 deletions(-) diff --git a/src/Main.js b/src/Main.js index 0878f96..31b932a 100644 --- a/src/Main.js +++ b/src/Main.js @@ -20,17 +20,23 @@ export default function Main() { let Layout switch (window.location.pathname) { case "/": + if (checkLogin()) { + Layout = Dashboard; + } else { + Layout = Welcome; + } + break; case "/dashboard": - Layout = Dashboard + Layout = Dashboard; break; case "/about-us": - Layout = AboutUs + Layout = AboutUs; break; case "/privacy": - Layout = Privacy + Layout = Privacy; break; case "/settings": - Layout = Settings + Layout = Settings; break; /* case "/support": @@ -38,23 +44,23 @@ export default function Main() { break; */ case "/contact-us": - Layout = ContactUs + Layout = ContactUs; break; case "/welcome": - Layout = Welcome + Layout = Welcome; break; case "/login": - Layout = Login + Layout = Login; break; case "/signup": - Layout = Signup + Layout = Signup; break; default: - Layout = Error + Layout = Error; break; } diff --git a/src/components/NavBar.js b/src/components/NavBar.js index a07ff9d..06b0b8f 100644 --- a/src/components/NavBar.js +++ b/src/components/NavBar.js @@ -7,25 +7,22 @@ import "./NavBar.css" import checkLogin from "../utils/utils"; export default function NavBar() { - const [auth, setAuth] = React.useState(true); const [anchorEl, setAnchorEl] = React.useState(null); const handleLogin = () => { - setAuth(true); handleClose(); window.location.href='/login'; } const handleSignup = () => { - setAuth(true); handleClose(); - window.location.href='/signup' + window.location.href='/signup'; } const handleLogout= () => { - setAuth(false); handleClose(); - window.location.href='/welcome' + document.cookie.split(";").forEach(function(c) { document.cookie = c.replace(/^ +/, "").replace(/=.*/, "=;expires=" + new Date().toUTCString() + ";path=/"); }); + window.location.href='/welcome'; } const handleMenu = (event) => { @@ -47,7 +44,7 @@ export default function NavBar() {