Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
vkulinich-cl committed Dec 12, 2024
1 parent d9e074b commit 7561743
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/sections/pools/modals/AddLiquidity/AddLiquidityFormXYK.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 { BN_0, BN_1 } from "utils/constants"
import { WalletTransferAssetSelect } from "sections/wallet/transfer/WalletTransferAssetSelect"
Expand Down Expand Up @@ -168,6 +168,15 @@ export const AddLiquidityFormXYK = ({ pool, onClose, onSuccess }: Props) => {
)
}

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

const handleChange = useCallback(
(value: string, name: "assetA" | "assetB") => {
const assetDecimals = assetValues[name].meta.decimals
Expand Down Expand Up @@ -245,7 +254,7 @@ export const AddLiquidityFormXYK = ({ pool, onClose, onSuccess }: Props) => {

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

0 comments on commit 7561743

Please sign in to comment.