From ca5764fb24a94822104fe43dd1616fcf9dd197c4 Mon Sep 17 00:00:00 2001 From: sirin Date: Sun, 6 Oct 2024 14:10:13 +0700 Subject: [PATCH] refactor: refresh profileBar when logout --- src/components/auth/logoutButton.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/components/auth/logoutButton.tsx b/src/components/auth/logoutButton.tsx index d4cd348..d84b562 100644 --- a/src/components/auth/logoutButton.tsx +++ b/src/components/auth/logoutButton.tsx @@ -1,15 +1,23 @@ "use client"; import { createSupabaseClient } from "@/lib/supabase/clientComponentClient"; +import { usePathname } from "next/navigation"; import { useRouter } from "next/navigation"; export function LogoutButton() { const supabase = createSupabaseClient(); + const pathname = usePathname(); const router = useRouter(); const handleLogout = async () => { await supabase.auth.signOut(); - router.push("/"); + + if (pathname === "/") { + window.location.reload(); + } else { + await router.push("/"); + window.location.reload(); + } }; return ;