From 74c8312589938877643d1affaa3e8951678504b1 Mon Sep 17 00:00:00 2001 From: RadoslavDimchev Date: Sun, 8 Oct 2023 18:29:38 +0300 Subject: [PATCH] feat: add error for not matching passwords --- .../KeyGeneration/KeystoreFiles.tsx | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/pages/ValidatorOnboarding/KeyGeneration/KeystoreFiles.tsx b/src/pages/ValidatorOnboarding/KeyGeneration/KeystoreFiles.tsx index e86eec36..7548d7b7 100644 --- a/src/pages/ValidatorOnboarding/KeyGeneration/KeystoreFiles.tsx +++ b/src/pages/ValidatorOnboarding/KeyGeneration/KeystoreFiles.tsx @@ -6,8 +6,23 @@ import { useState } from 'react' const KeystoreFiles = () => { const [encryptedPassword, setEncryptedPassword] = useState('') const [confirmEncryptedPassword, setConfirmEncryptedPassword] = useState('') + const [encryptedPasswordError, setEncryptedPasswordError] = useState(false) + const [confirmEncryptedPasswordError, setConfirmEncryptedPasswordError] = useState(false) - const generateKeystoreFilesHandler = () => {} + const generateKeystoreFilesHandler = () => { + if ( + encryptedPassword !== confirmEncryptedPassword || + encryptedPassword === '' || + confirmEncryptedPassword === '' + ) { + setEncryptedPasswordError(true) + setConfirmEncryptedPasswordError(true) + return + } + + setEncryptedPasswordError(false) + setConfirmEncryptedPasswordError(false) + } const changeEncryptedPasswordHandler = (e: any) => { setEncryptedPassword(e.target.value) @@ -52,6 +67,7 @@ const KeystoreFiles = () => { onClick={clearEncryptedPasswordHandler} /> } + error={encryptedPasswordError} value={encryptedPassword} onChange={changeEncryptedPasswordHandler} /> @@ -70,6 +86,7 @@ const KeystoreFiles = () => { onClick={clearConfirmEncryptedPasswordHandler} /> } + error={confirmEncryptedPasswordError} value={confirmEncryptedPassword} onChange={changeConfirmEncryptedPasswordHandler} />