19 lines
363 B
TypeScript
19 lines
363 B
TypeScript
"use client";
|
|
|
|
import { apiFetch } from "@/lib/client-api";
|
|
|
|
export function LogoutButton() {
|
|
async function logout() {
|
|
try {
|
|
await apiFetch("/auth/logout", { method: "POST" });
|
|
} finally {
|
|
window.location.href = "/login";
|
|
}
|
|
}
|
|
return (
|
|
<button type="button" className="btn link" onClick={logout}>
|
|
Sair
|
|
</button>
|
|
);
|
|
}
|