mirror of
https://github.com/Sosokker/B2D-Ventures.git
synced 2025-12-20 14:34:05 +01:00
refactor: refresh profileBar when logout
This commit is contained in:
parent
10d03da196
commit
ca5764fb24
@ -1,15 +1,23 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { createSupabaseClient } from "@/lib/supabase/clientComponentClient";
|
import { createSupabaseClient } from "@/lib/supabase/clientComponentClient";
|
||||||
|
import { usePathname } from "next/navigation";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
|
|
||||||
export function LogoutButton() {
|
export function LogoutButton() {
|
||||||
const supabase = createSupabaseClient();
|
const supabase = createSupabaseClient();
|
||||||
|
const pathname = usePathname();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
const handleLogout = async () => {
|
const handleLogout = async () => {
|
||||||
await supabase.auth.signOut();
|
await supabase.auth.signOut();
|
||||||
router.push("/");
|
|
||||||
|
if (pathname === "/") {
|
||||||
|
window.location.reload();
|
||||||
|
} else {
|
||||||
|
await router.push("/");
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return <button onClick={handleLogout}>Logout</button>;
|
return <button onClick={handleLogout}>Logout</button>;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user