Skip to content

Commit

Permalink
logout logic bug fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
mrpthemrp committed Dec 15, 2024
1 parent 0bdddf3 commit 46d0e08
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
4 changes: 2 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand All @@ -43,7 +43,7 @@ const App = () => {
<AlertQueueProvider>
<AlertQueue>
<ScrollToTop>
{NavBar()}
<NavBar/>
<div className="min-h-screen bg-background text-foreground font-mono">
<GDPRBanner />
<PendoInitializer />
Expand Down
14 changes: 3 additions & 11 deletions src/components/navbar/burgerMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 ? (
<div className={"grid-m"}>
<motion.div
Expand Down Expand Up @@ -39,18 +37,14 @@ const BurgerMenu = (isOpen: boolean) => {
}
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 ? <ExpressiveArrow size={"size-10"} /> : <></>}
</a>
</motion.button>
Expand All @@ -62,5 +56,3 @@ const BurgerMenu = (isOpen: boolean) => {
<></>
);
};

export default BurgerMenu;
25 changes: 16 additions & 9 deletions src/components/navbar/navbar.tsx
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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) {
Expand Down Expand Up @@ -47,26 +49,29 @@ export default function NavBar() {
<menu
className={clsx(
"col-span-full grid grid-cols-subgrid overflow-hidden py-4 items-end h-fit px-[5vw] -mx-[5vw]",
)}>
<Logotype />
)}
>
<Logotype />
<BurgerOpenButton
className="-col-end-1 place-self-end pointer-events-auto"
atTop={atTop}
isOpen={mobileShouldOpenBurger}
onClick={setMobileShouldOpenBurger}
/>
</menu>
<AnimatePresence>{BurgerMenu(mobileShouldOpenBurger)}</AnimatePresence>
<AnimatePresence>
{BurgerMenu(mobileShouldOpenBurger, isAuthenticated)}
</AnimatePresence>
</>
);
};

const desktopNavBar = () => {
return (
<>
<Logotype />
<NavDocsButton />
<NavLogInButton />
<Logotype />
<NavDocsButton />
<NavLogInButton />

<NavCTAButton
className="md:col-span-2 md:-col-end-1 2xl:col-span-3 2xl:-col-end-1"
Expand Down Expand Up @@ -98,4 +103,6 @@ export default function NavBar() {
{navBasedOnWidth(width >= 768)}
</motion.nav>
);
}
};

export default NavBar;
3 changes: 2 additions & 1 deletion src/components/util/constants.tsx
Original file line number Diff line number Diff line change
@@ -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 }[] = [
Expand Down

0 comments on commit 46d0e08

Please sign in to comment.