import { isApiSuccess } from "@/lib/api/errors";
/**
 * Interests are required by the approved client forms. A rejected choice ID is
 * a validation failure, never permission to retry a write without its tags.
 * The false flag preserves the existing multi-step submission result contract.
 */
export async function submitRequiredInterests<T>(
  formData: FormData,
  submit: (payload: FormData) => Promise<T>
): Promise<{ result: T; interestsDropped: false }> {
  const result = await submit(formData);
  if (result && typeof result === "object" && "key" in result && !isApiSuccess(result)) throw result;
  return { result, interestsDropped: false };
}
