"use client";

import { useRouter } from "@/i18n/navigation";
import { useTranslations } from "next-intl";

export function AdminLogoutButton() {
  const t = useTranslations("admin");
  const router = useRouter();

  return (
    <button
      type="button"
      className="rounded-md border border-border px-3 py-1.5 text-sm text-muted hover:border-gold hover:text-gold"
      onClick={async () => {
        await fetch("/api/admin/logout", { method: "POST" });
        router.push("/admin/login");
        router.refresh();
      }}
    >
      {t("signOut")}
    </button>
  );
}
