Files
sorsfonalak/services/frontend/src/components/LogoutButton.tsx
T
fecoandClaude Opus 5.5 a4173f90b6
CI / test (push) Successful in 1m29s
CI / build (push) Successful in 4m51s
CI / deploy (push) Skipped
Logging out (and deleting the account) leads to the home page
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
2026-11-19 11:58:09 +00:00

28 lines
673 B
TypeScript

"use client";
import { useRouter } from "next/navigation";
import { useState } from "react";
import { api } from "@/lib/api";
export function LogoutButton() {
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 (
<button type="button" className="btn btn-sm" onClick={logout} disabled={busy}>
Kilépés
</button>
);
}