From 46d0e08dfb2378aeea255621f45d3c16efc84d6b Mon Sep 17 00:00:00 2001 From: Deborah Wang Date: Sun, 15 Dec 2024 01:39:42 -0800 Subject: [PATCH] logout logic bug fixed --- src/App.tsx | 4 ++-- src/components/navbar/burgerMenu.tsx | 14 +++----------- src/components/navbar/navbar.tsx | 25 ++++++++++++++++--------- src/components/util/constants.tsx | 3 ++- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index d466e09..2da996e 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -32,7 +32,7 @@ import Signup from "@/components/pages/Signup"; import Terminal from "@/components/pages/Terminal"; import TermsOfService from "@/components/pages/TermsOfService"; import { AlertQueue, AlertQueueProvider } from "@/hooks/useAlertQueue"; -import { AuthenticationProvider } from "@/hooks/useAuth"; +import {AuthenticationProvider} from "@/hooks/useAuth"; import ROUTES from "@/lib/types/routes"; const App = () => { @@ -43,7 +43,7 @@ const App = () => { - {NavBar()} +
diff --git a/src/components/navbar/burgerMenu.tsx b/src/components/navbar/burgerMenu.tsx index b2a9dc8..47042f9 100644 --- a/src/components/navbar/burgerMenu.tsx +++ b/src/components/navbar/burgerMenu.tsx @@ -4,11 +4,9 @@ import { navItemsMobile, transitionEaseLinearDuration300, } from "@/components/util/constants"; -import { useAuthentication } from "@/hooks/useAuth"; import { motion } from "motion/react"; -const BurgerMenu = (isOpen: boolean) => { - const { isAuthenticated } = useAuthentication(); +export const BurgerMenu = (isOpen: boolean, isAuth: boolean) => { return isOpen ? (
{ } href={ index === 1 - ? isAuthenticated + ? isAuth ? "/logout" : navItemLinksMobile[index].link : navItemLinksMobile[index].link } target={navItemLinksMobile[index].target} > - {index === 1 - ? isAuthenticated - ? "Log out" - : navItem - : navItem} + {index === 1 ? (isAuth ? "Log out" : navItem) : navItem} {index !== 1 ? : <>} @@ -62,5 +56,3 @@ const BurgerMenu = (isOpen: boolean) => { <> ); }; - -export default BurgerMenu; diff --git a/src/components/navbar/navbar.tsx b/src/components/navbar/navbar.tsx index 806448b..5a5fc61 100644 --- a/src/components/navbar/navbar.tsx +++ b/src/components/navbar/navbar.tsx @@ -1,12 +1,13 @@ import React, { useEffect, useState } from "react"; import Logotype from "@/components/logotypes/logotype"; -import BurgerMenu from "@/components/navbar/burgerMenu"; +import { BurgerMenu } from "@/components/navbar/burgerMenu"; import BurgerOpenButton from "@/components/navbar/burgerOpenButton"; import { NavDocsButton, NavLogInButton } from "@/components/navbar/navButtons"; import { NavCTAButton } from "@/components/ui/CTAButtons"; import { FillMode } from "@/components/util/constants"; import { useWindowSize } from "@/components/util/functions"; +import { useAuthentication } from "@/hooks/useAuth"; import clsx from "clsx"; import { AnimatePresence, @@ -15,11 +16,12 @@ import { useScroll, } from "motion/react"; -export default function NavBar() { +const NavBar = () => { const { scrollY } = useScroll(); const [, setDesktopNavHidden] = useState(false); const [desktopPreviousScroll, setPrevScroll] = useState(scrollY.get()); const [mobileShouldOpenBurger, setMobileShouldOpenBurger] = useState(false); + const { isAuthenticated } = useAuthentication(); function update(current: number, previous: number): void { if (current < previous) { @@ -47,8 +49,9 @@ export default function NavBar() { - + )} + > + - {BurgerMenu(mobileShouldOpenBurger)} + + {BurgerMenu(mobileShouldOpenBurger, isAuthenticated)} + ); }; @@ -64,9 +69,9 @@ export default function NavBar() { const desktopNavBar = () => { return ( <> - - - + + + = 768)} ); -} +}; + +export default NavBar; diff --git a/src/components/util/constants.tsx b/src/components/util/constants.tsx index f9fdde0..287901b 100644 --- a/src/components/util/constants.tsx +++ b/src/components/util/constants.tsx @@ -1,4 +1,5 @@ -export const transitionEaseLinearDuration300: string = " transition ease-linear duration-300 "; +export const transitionEaseLinearDuration300: string = + " transition ease-linear duration-300 "; export const navItems: string[] = ["Docs", "Log In", "Buy K-Bot"]; export const navItemLinks: { link: string; target: string }[] = [