"use client";

/**
 * The "Copy" affordance inside a read-only field.
 *
 * Was a `<span onClick>` duplicated verbatim in the volunteer and organizer
 * account sections: no keyboard access, and nothing announced it as something
 * that can be activated.
 *
 * `type="button"` is not optional here — both call sites sit inside a Formik
 * `<Form>`, and a `<button>` with no type defaults to `submit`, so a keyboard
 * user pressing Enter on it would have submitted the whole account form.
 */
export default function CopyFieldButton({
  value,
  label,
  onCopy,
  className,
}: {
  value: string;
  /** The visible text, already translated. */
  label: string;
  onCopy: (value: string) => void;
  className?: string;
}) {
  return (
    <button type="button" onClick={() => onCopy(value)} className={className}>
      {label}
    </button>
  );
}
