From a7127c6957a0e4b8d09e530a22e90ca32ed0b2b1 Mon Sep 17 00:00:00 2001 From: edwin6666 Date: Sun, 21 Jan 2024 11:16:23 -0400 Subject: [PATCH 1/2] Refactor: elimination of repeated route and change of route for those not logged in --- src/App.js | 8 +++++++- src/components/Navbar/Navbar.jsx | 12 ++++++------ src/components/RequiresAuth.jsx | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/App.js b/src/App.js index 58dbc57..0823b9d 100644 --- a/src/App.js +++ b/src/App.js @@ -25,7 +25,6 @@ function App() { {/* Public routes */} } /> } /> - } /> } /> } /> } /> @@ -42,6 +41,13 @@ function App() { } /> } /> } /> + + + }> + } /> + + + }> } /> diff --git a/src/components/Navbar/Navbar.jsx b/src/components/Navbar/Navbar.jsx index b75fdb4..c5104f8 100644 --- a/src/components/Navbar/Navbar.jsx +++ b/src/components/Navbar/Navbar.jsx @@ -1,10 +1,9 @@ import React, { useState } from "react"; import { Link } from "react-router-dom"; -import { useLocation } from "react-router-dom"; import { useRouteVariables } from "./Location"; + import Dropdown from "./Dropdown"; const Navbar = () => { - const location = useLocation(); const { isLoginPage, isSignupPage, @@ -17,6 +16,7 @@ const Navbar = () => { isHomePage, isContactPage, isEmailPage, + isConfirmPage, } = useRouteVariables(); const [open, setOpen] = useState(false); @@ -24,7 +24,7 @@ const Navbar = () => { const toggleMenu = () => { setOpen(!open); }; - if (isLoginPage || isSignupPage ) { + if (isLoginPage || isSignupPage) { return null; } @@ -91,9 +91,9 @@ const Navbar = () => { {(!isHomePage || (userListPage && !isContactPage)) && !isAdminPage && !isSubscribePage && - location.pathname !== "/contact" && !isDetailPage && - !isEmailPage && ( + !isEmailPage && + !isConfirmPage && ( { Users List )} - + diff --git a/src/components/RequiresAuth.jsx b/src/components/RequiresAuth.jsx index 5a47988..d5e4b71 100644 --- a/src/components/RequiresAuth.jsx +++ b/src/components/RequiresAuth.jsx @@ -16,7 +16,7 @@ const RequiresAuth = ({ allowedRoles }) => { ) : ( - + ); }; From 547b7fb323c53dcdae950d6e1653381c7a519bad Mon Sep 17 00:00:00 2001 From: edwin6666 Date: Mon, 22 Jan 2024 00:03:51 -0400 Subject: [PATCH 2/2] Feat: icon in the app and fix routes for roles --- src/components/Login/Login.jsx | 19 +++++++++--------- src/components/Navbar/Dropdown.jsx | 16 ++++++++------- src/components/Navbar/Navbar.jsx | 32 +++++++++++++++--------------- src/hooks/useAuthentication.js | 8 +++++--- src/pages/Contact.js | 21 +++++++++++--------- src/pages/PostForm.js | 12 +++++++++++ 6 files changed, 64 insertions(+), 44 deletions(-) diff --git a/src/components/Login/Login.jsx b/src/components/Login/Login.jsx index 38db568..c53a985 100644 --- a/src/components/Login/Login.jsx +++ b/src/components/Login/Login.jsx @@ -1,7 +1,8 @@ import backgroundImage from "../../Images/logoimg.jpg"; import useLoginForm from "../../hooks/useLoginForm"; import useAuthentication from "../../hooks/useAuthentication"; - +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; +import { faLock,faEnvelope,faNewspaper, faKey } from "@fortawesome/free-solid-svg-icons"; const Signin = () => { const { data, error, handleChange, setError } = useLoginForm(); const { authenticate } = useAuthentication(); @@ -34,8 +35,8 @@ const Signin = () => {