From f006b2e2415ebc838e2863ebf6fafda241493ca9 Mon Sep 17 00:00:00 2001 From: Kristof Csillag Date: Fri, 6 Sep 2024 18:28:10 +0200 Subject: [PATCH] Enable token and wallet address checking in create poll form --- .../pages/CreatePollPage/useCreatePollForm.ts | 32 ++++--------------- 1 file changed, 7 insertions(+), 25 deletions(-) diff --git a/frontend/src/pages/CreatePollPage/useCreatePollForm.ts b/frontend/src/pages/CreatePollPage/useCreatePollForm.ts index ddd5654..3d9fd21 100644 --- a/frontend/src/pages/CreatePollPage/useCreatePollForm.ts +++ b/frontend/src/pages/CreatePollPage/useCreatePollForm.ts @@ -171,37 +171,19 @@ export const useCreatePollForm = () => { value=> !isValidAddress(value) ? "This doesn't seem to be a valid address." : undefined, // _value => "random", ], + validateOnChange: true, + showValidationSuccess: true, }) - const xchainTokenAddressStatus = useLabel({ - name: "xchainAddressStatus", - initialValue: "", - containerClassName: classes.addressStatus, - visible: xchainTokenAddress.visible, - }) - - useEffect( - () => { - if (!xchainTokenAddress.visible || !xchainTokenAddress.value) return - // console.log("Gonna validate") - xchainTokenAddressStatus.setValue("...") - if (!xchainTokenAddress.validate()) { - xchainTokenAddressStatus.setValue("") - return - } - // console.log("Validate OK") - xchainTokenAddressStatus.setValue("2") - }, - [xchainTokenAddress.value, xchainTokenAddress.visible] - ) - const xchainWalletAddress = useTextField({ name: "xchainWalletAddress", label: "Wallet Address", - visible: xchainTokenAddressStatus.value === "2", + visible: xchainTokenAddress.isValidated && !xchainTokenAddress.hasProblems, placeholder: "Wallet address of a token holder on chain", required: [true, "Please specify the address of a token holder!"], - // validators: value => isValidAddress(value) ? "This doesn't seem to be a valid address." : undefined, + validators: value => !isValidAddress(value) ? "This doesn't seem to be a valid address." : undefined, + validateOnChange: true, + showValidationSuccess: true, }) const voteWeighting = useOneOfField({ @@ -271,7 +253,7 @@ export const useCreatePollForm = () => { tokenAddress, addressWhitelist, chain, - [xchainTokenAddress, xchainTokenAddressStatus], + xchainTokenAddress, xchainWalletAddress, voteWeighting, gasFree,