From 522717cb1cb1e27d8000474074047a896838e9f3 Mon Sep 17 00:00:00 2001 From: RadoslavDimchev Date: Sun, 8 Oct 2023 16:33:33 +0300 Subject: [PATCH] feat: remove is right phrase state and reducer --- src/pages/ValidatorOnboarding/ContinueButton.tsx | 16 +++++----------- .../ValidatorOnboarding/KeyGeneration/slice.ts | 6 ------ 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/src/pages/ValidatorOnboarding/ContinueButton.tsx b/src/pages/ValidatorOnboarding/ContinueButton.tsx index b5dcddc3..5b1b0d2b 100644 --- a/src/pages/ValidatorOnboarding/ContinueButton.tsx +++ b/src/pages/ValidatorOnboarding/ContinueButton.tsx @@ -1,11 +1,9 @@ import { Stack, YStack } from 'tamagui' import { Button, InformationBox } from '@status-im/components' import { CloseCircleIcon } from '@status-im/icons' -import { useDispatch, useSelector } from 'react-redux' -import { useEffect } from 'react' +import { useSelector } from 'react-redux' import { RootState } from '../../redux/store' -import { setIsRightPhrase } from '../../redux/ValidatorOnboarding/KeyGeneration/slice' import LinkWithArrow from '../../components/General/LinkWithArrow' type ContinueButton = { @@ -15,17 +13,13 @@ type ContinueButton = { } const ContinueButton = ({ continueHandler, activeStep, subStepValidatorSetup }: ContinueButton) => { - const { isCopyPastedPhrase, isRightPhrase, mnemonic, validWords, isConfirmPhraseStage } = - useSelector((state: RootState) => state.keyGeneration) - const dispatch = useDispatch() - - useEffect(() => { - dispatch(setIsRightPhrase(mnemonic.every(word => word !== ''))) - }, [mnemonic]) + const { isCopyPastedPhrase, mnemonic, validWords, isConfirmPhraseStage } = useSelector( + (state: RootState) => state.keyGeneration, + ) const isDisabled = () => { if ( - (isConfirmPhraseStage && !isRightPhrase) || + (isConfirmPhraseStage && mnemonic.some(word => word === '')) || (isConfirmPhraseStage && validWords.some(w => w === false)) ) { return true diff --git a/src/redux/ValidatorOnboarding/KeyGeneration/slice.ts b/src/redux/ValidatorOnboarding/KeyGeneration/slice.ts index e453ed6b..895025b2 100644 --- a/src/redux/ValidatorOnboarding/KeyGeneration/slice.ts +++ b/src/redux/ValidatorOnboarding/KeyGeneration/slice.ts @@ -3,7 +3,6 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit' type KeyGenerationState = { mnemonic: string[] isCopyPastedPhrase: boolean - isRightPhrase: boolean validWords: boolean[] generatedMnemonic: string[] isConfirmPhraseStage: boolean @@ -17,7 +16,6 @@ type wordProps = { const initialState: KeyGenerationState = { mnemonic: Array(24).fill(''), isCopyPastedPhrase: false, - isRightPhrase: false, validWords: Array(24).fill(true), generatedMnemonic: Array(24).fill(''), isConfirmPhraseStage: false, @@ -38,9 +36,6 @@ const keyGenerationSlice = createSlice({ setIsCopyPastedPhrase: (state, action: PayloadAction) => { state.isCopyPastedPhrase = action.payload }, - setIsRightPhrase: (state, action: PayloadAction) => { - state.isRightPhrase = action.payload - }, setValidWords: (state, action: PayloadAction) => { state.validWords = action.payload }, @@ -57,7 +52,6 @@ export const { setWord, setMnemonic, setIsCopyPastedPhrase, - setIsRightPhrase, setValidWords, setGeneratedMnemonic, setIsConfirmPhraseStage,