disable button until all fields are filled

pull/3648/head
Aniket-Engg 2 years ago committed by Aniket
parent 055bf9cca5
commit 80e32255ce
  1. 4
      apps/etherscan/src/app/components/SubmitButton.tsx
  2. 13
      apps/etherscan/src/app/views/VerifyView.tsx

@ -4,12 +4,14 @@ interface Props {
text: string
isSubmitting?: boolean
dataId?: string
disable?: boolean
}
export const SubmitButton: React.FC<Props> = ({
text,
dataId,
isSubmitting = false,
disable = true
}) => {
return (
<button
@ -17,7 +19,7 @@ export const SubmitButton: React.FC<Props> = ({
style={{ padding: "0.25rem 0.4rem", marginRight: "0.5em" }}
type="submit"
className="btn btn-primary"
disabled={isSubmitting}
disabled={disable}
>
{!isSubmitting && text}

@ -171,7 +171,18 @@ export const VerifyView: React.FC<Props> = ({
/>
</div>
<SubmitButton dataId="verify-contract" text="Verify" isSubmitting={isSubmitting} />
<SubmitButton dataId="verify-contract" text="Verify"
isSubmitting={isSubmitting}
disable={ !contracts.length ||
!touched.contractName ||
(showConstructorArgs && !touched.contractArguments) ||
!touched.contractAddress ||
(touched.contractName && errors.contractName) ||
(showConstructorArgs && touched.contractArguments && errors.contractArguments) ||
(touched.contractAddress && errors.contractAddress)
? true
: false}
/>
<br/><br/>
<button
type="button"

Loading…
Cancel
Save