Files
sorsfonalak/services/frontend/src/components/LogoutButton.tsx
T
fecoandClaude Opus 5.5 09fc1e62c7
CI / build (push) Successful in 5m56s
CI / deploy (push) Skipped
CI / test (push) Successful in 1m30s
Header: an account menu under the user's name
Profile, invoices, redeeming a code and logging out moved from the
crowded top right and the main menu into a menu that opens from the
name; on phones the name shows too (shortened), so the profile stays
reachable.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
2026-11-20 17:15:37 +00:00

28 lines
761 B
TypeScript

"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 (
<button type="button" className={className} role={role} onClick={logout} disabled={busy}>
Kilépés
</button>
);
}