Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
vkulinich-cl committed Dec 11, 2024
1 parent 61ea057 commit 194e0d1
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/sections/pools/modals/AddLiquidity/AddLiquidityForm.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Controller, useForm } from "react-hook-form"
import { Controller, FieldErrors, useForm } from "react-hook-form"
import BN from "bignumber.js"
import { WalletTransferAssetSelect } from "sections/wallet/transfer/WalletTransferAssetSelect"
import { SummaryRow } from "components/Summary/SummaryRow"
Expand Down Expand Up @@ -136,6 +136,15 @@ export const AddLiquidityForm = ({
}
| undefined

const onInvalidSubmit = (errors: FieldErrors<FormValues<typeof form>>) => {
if (
!isJoinFarms &&
(errors.amount as { farm?: { message: string } }).farm
) {
onSubmit(form.getValues())
}
}

const isJoinFarmDisabled = !!customErrors?.farm
const isSubmitDisabled = isJoinFarms
? !!Object.keys(formState.errors).length
Expand All @@ -154,7 +163,7 @@ export const AddLiquidityForm = ({

return (
<form
onSubmit={handleSubmit(onSubmit)}
onSubmit={handleSubmit(onSubmit, onInvalidSubmit)}
autoComplete="off"
sx={{
flex: "column",
Expand Down

0 comments on commit 194e0d1

Please sign in to comment.