25 lines
587 B
TypeScript
25 lines
587 B
TypeScript
'use client';
|
|
|
|
/** Logout-Button: beendet die Session per API und laedt neu. */
|
|
import { useRouter } from 'next/navigation';
|
|
import { Button } from '@/components/ui/ui';
|
|
|
|
export function LogoutButton() {
|
|
const router = useRouter();
|
|
|
|
async function logout() {
|
|
await fetch('/api/auth/logout', { method: 'POST' });
|
|
router.push('/login');
|
|
router.refresh();
|
|
}
|
|
|
|
return (
|
|
<button
|
|
type="button"
|
|
onClick={logout}
|
|
className="rounded-md bg-slate-200 px-4 py-2 text-sm font-medium text-slate-900 hover:bg-slate-300"
|
|
>
|
|
Abmelden
|
|
</button>
|
|
);
|
|
} |