From 0020f6b79aec280257cc06ed955a92c9cdf19366 Mon Sep 17 00:00:00 2001 From: wkim10 Date: Wed, 11 Dec 2024 01:40:37 -0500 Subject: [PATCH 1/2] add logout flow --- src/components/SideNavBar.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/components/SideNavBar.tsx b/src/components/SideNavBar.tsx index a3d27bb..b8e333d 100644 --- a/src/components/SideNavBar.tsx +++ b/src/components/SideNavBar.tsx @@ -5,6 +5,7 @@ import Image from "next/image"; import Logo from "../app/icons/br-logo.png"; import Divider from "../app/icons/divider"; import { usePathname } from "next/navigation"; +import { signOut } from "next-auth/react"; interface SideNavBarProps { role: string; @@ -28,14 +29,14 @@ const SideNavBar = ({ role }: SideNavBarProps) => { href: "/private/communication", }, { name: "Profile", icon: "charm:person", href: "/private/profile" }, - { name: "Logout", icon: "tabler:logout", href: "/private/logout" }, // @TODO + { name: "Logout", icon: "tabler:logout", href: "" }, ]; const volunteerTabs = [ { name: "Home", icon: "tabler:home", href: "/private" }, { name: "Events", icon: "uil:calender", href: "/private/events" }, { name: "Profile", icon: "charm:person", href: "/private/profile" }, - { name: "Logout", icon: "tabler:logout", href: "/private/logout" }, // @TODO + { name: "Logout", icon: "tabler:logout", href: "" }, ]; const tabs = role === "admin" ? adminTabs : volunteerTabs; @@ -62,7 +63,11 @@ const SideNavBar = ({ role }: SideNavBarProps) => { className={`nav-button flex gap-3 items-center h-11 w-full text-[18px] font-medium focus:text-darkrose focus:bg-rose rounded-md pt-px pb-px px-3 ${ pathname === tab.href ? "text-darkrose bg-rose" : "" }`} - onClick={() => router.replace(tab.href)} + onClick={() => + tab.name === "Logout" + ? signOut({ callbackUrl: "/public/signIn" }) + : router.replace(tab.href) + } > {tab.name} From 32de71975ddcf958b1fe1a9d1c146f4f9d2da2ff Mon Sep 17 00:00:00 2001 From: Johnny Tan Date: Wed, 11 Dec 2024 01:51:43 -0500 Subject: [PATCH 2/2] Lowercase signin --- src/components/SideNavBar.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/SideNavBar.tsx b/src/components/SideNavBar.tsx index b8e333d..3996208 100644 --- a/src/components/SideNavBar.tsx +++ b/src/components/SideNavBar.tsx @@ -65,7 +65,7 @@ const SideNavBar = ({ role }: SideNavBarProps) => { }`} onClick={() => tab.name === "Logout" - ? signOut({ callbackUrl: "/public/signIn" }) + ? signOut({ callbackUrl: "/public/signin" }) : router.replace(tab.href) } >