"use client";

import { useFormStatus } from "react-dom";

/**
 * Disables the quote inputs while the Server Action is in flight.
 *
 * Split out only so `useFormStatus` has a form to read from — it works nowhere
 * else. The children are still server-rendered and passed straight through, so
 * this adds the in-flight affordance without pulling the form's markup into the
 * client bundle.
 */
export default function QuoteFieldset({
  locked,
  children,
}: {
  locked: boolean;
  children: React.ReactNode;
}) {
  const { pending } = useFormStatus();

  return (
    <fieldset disabled={locked || pending} className="space-y-3">
      {children}
    </fieldset>
  );
}
