From e3d916fe6142a30ad95c8199fa9f690c9e0319be Mon Sep 17 00:00:00 2001 From: KY Lau Date: Wed, 9 Jun 2021 18:39:50 +0800 Subject: [PATCH] Attempt fix issue --- .../molecules/FormFields/Credential/index.tsx | 18 ++++++++++++------ .../AssetActions/Edit/EditAdvanceSettings.tsx | 2 +- .../AssetActions/Edit/FormAdvanceSettings.tsx | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/components/molecules/FormFields/Credential/index.tsx b/src/components/molecules/FormFields/Credential/index.tsx index 8906e1b19..c8cbb791e 100644 --- a/src/components/molecules/FormFields/Credential/index.tsx +++ b/src/components/molecules/FormFields/Credential/index.tsx @@ -27,18 +27,24 @@ export default function Credential(props: InputProps) { helpers.setValue(newInput) } - function handleAddValue(e: FormEvent) { - e.preventDefault() + function isCredentialValid(): boolean { if (!isAddress(value)) { toast.error('Wallet address is invalid') - return + return false } if (arrayInput.includes(value)) { toast.error('Wallet address already added into list') - return + return false + } + return true + } + + function handleAddValue(e: FormEvent) { + e.preventDefault() + if (isCredentialValid()) { + setArrayInput((arrayInput) => [...arrayInput, value]) + setValue('') } - setArrayInput((arrayInput) => [...arrayInput, value]) - setValue('') } return ( diff --git a/src/components/organisms/AssetActions/Edit/EditAdvanceSettings.tsx b/src/components/organisms/AssetActions/Edit/EditAdvanceSettings.tsx index 00fd691a0..a3e4ad52b 100644 --- a/src/components/organisms/AssetActions/Edit/EditAdvanceSettings.tsx +++ b/src/components/organisms/AssetActions/Edit/EditAdvanceSettings.tsx @@ -123,7 +123,7 @@ export default function EditAdvanceSettings({ {({ isSubmitting, values, initialValues }) => isSubmitting || hasFeedback ? (