"use client"; import { useRouter } from "next/navigation"; import { useState } from "react"; import { api } from "@/lib/api"; export function LogoutButton({ className = "btn btn-sm", role }: { className?: string; role?: "menuitem" }) { const router = useRouter(); const [busy, setBusy] = useState(false); async function logout() { setBusy(true); try { await api("/auth/logout", { method: "POST" }); } catch { // The session may already be gone; go to the home page either way. } window.google?.accounts.id.disableAutoSelect(); router.replace("/"); router.refresh(); } return ( ); }