23 lines
621 B
TypeScript
23 lines
621 B
TypeScript
"use client";
|
|
|
|
import { useRouter } from "next/navigation";
|
|
import { t, type Locale } from "@/lib/i18n";
|
|
|
|
export default function LogoutButton({ locale }: { locale: Locale }) {
|
|
const router = useRouter();
|
|
|
|
async function handleLogout() {
|
|
await fetch("/api/auth/logout", { method: "POST" });
|
|
router.push("/login");
|
|
}
|
|
|
|
return (
|
|
<button
|
|
type="button"
|
|
onClick={handleLogout}
|
|
className="inline-flex h-10 items-center rounded-lg bg-white/10 px-4 text-sm font-semibold text-white ring-1 ring-white/30 transition hover:bg-white/20"
|
|
>
|
|
{t(locale, "auth.logout")}
|
|
</button>
|
|
);
|
|
} |