"use client";

import { useFormStatus } from "react-dom";

/**
 * Submit button for the quote form.
 *
 * The surrounding `<form action={respondToEnquiry}>` posts without any of this
 * JS, so quoting still works if the bundle fails to load; `useFormStatus` only
 * layers the pending label on top — and it must live in a child of the form to
 * see it at all.
 */
export default function SubmitQuoteButton({ label }: { label: string }) {
  const { pending } = useFormStatus();

  return (
    <button
      type="submit"
      disabled={pending}
      className="w-full rounded-lg bg-[#CC1414] px-4 py-2 text-sm font-medium text-white hover:bg-[#a30f0f] disabled:opacity-60"
    >
      {pending ? "Submitting…" : label}
    </button>
  );
}
