"use client";

import { useRouter } from "next/navigation";

export function LogoutButton() {
  const router = useRouter();

  async function handleLogout() {
    await fetch("/api/auth/logout", { method: "POST" });
    router.push("/admin/login");
    router.refresh();
  }

  return (
    <button
      onClick={handleLogout}
      className="w-full rounded-lg border border-rosewood/40 px-3 py-2 text-xs uppercase tracking-wide-plus text-rosewood transition hover:bg-rosewood hover:text-cream"
    >
      Log Out
    </button>
  );
}
