"use client";

import { useRouter } from "next/navigation";

export function TemplateActions({ id }: { id: string }) {
  const router = useRouter();

  async function archive() {
    await fetch(`/api/email-templates/${id}`, { method: "DELETE" });
    router.push("/email-templates");
    router.refresh();
  }

  return (
    <button
      type="button"
      onClick={() => void archive()}
      className="rounded border border-red-200 px-3 py-1 text-sm text-red-700"
    >
      أرشفة
    </button>
  );
}

