diff --git a/web/src/components/navigation/app-navbar/index.tsx b/web/src/components/navigation/app-navbar/index.tsx index 4f283d12..9616f5cb 100644 --- a/web/src/components/navigation/app-navbar/index.tsx +++ b/web/src/components/navigation/app-navbar/index.tsx @@ -1,10 +1,13 @@ "use client"; +import { LogOut } from "lucide-react"; import type { Route } from "next"; import Image from "next/image"; import Link from "next/link"; -import { usePathname } from "next/navigation"; +import { usePathname, useRouter } from "next/navigation"; +import { useState } from "react"; import { icons } from "@/components/icons"; import { Protected } from "@/components/rbac/Protected"; +import { authClient } from "@/lib/auth-client"; import { cn } from "@/lib/utils"; type NavItem = { @@ -56,7 +59,7 @@ const AppNavBarItem = ({ : "bg-primary-dark hover:bg-accent" } group-hover:-translate-y-2`} > - + { const isBroadcastsActive = pathname.startsWith("/broadcasts"); const isCreateBroadcastActive = pathname.startsWith("/broadcasts/new"); + const router = useRouter(); + const [isSigningOut, setIsSigningOut] = useState(false); + + const handleSignOut = async () => { + setIsSigningOut(true); + const res = await authClient.signOut(); + if (res.error) { + setIsSigningOut(false); + return; + } + router.replace("/login"); + }; + const circleButtonClasses = - "group relative flex h-12 w-12 shrink-0 items-center justify-center rounded-full border-2 transition-colors duration-200 overflow-visible"; + "group relative flex h-11 w-11 shrink-0 items-center justify-center rounded-full border-2 transition-colors duration-200 overflow-visible"; return (