mirror of
https://github.com/Sosokker/B2D-Ventures.git
synced 2025-12-18 21:44:06 +01:00
refactor: refresh profileBar when logout
This commit is contained in:
parent
10d03da196
commit
ca5764fb24
@ -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 <button onClick={handleLogout}>Logout</button>;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user