feat: remove is right phrase state and reducer

This commit is contained in:
RadoslavDimchev 2023-10-08 16:33:33 +03:00
parent ed254afdbf
commit 522717cb1c
2 changed files with 5 additions and 17 deletions

View File

@ -1,11 +1,9 @@
import { Stack, YStack } from 'tamagui' import { Stack, YStack } from 'tamagui'
import { Button, InformationBox } from '@status-im/components' import { Button, InformationBox } from '@status-im/components'
import { CloseCircleIcon } from '@status-im/icons' import { CloseCircleIcon } from '@status-im/icons'
import { useDispatch, useSelector } from 'react-redux' import { useSelector } from 'react-redux'
import { useEffect } from 'react'
import { RootState } from '../../redux/store' import { RootState } from '../../redux/store'
import { setIsRightPhrase } from '../../redux/ValidatorOnboarding/KeyGeneration/slice'
import LinkWithArrow from '../../components/General/LinkWithArrow' import LinkWithArrow from '../../components/General/LinkWithArrow'
type ContinueButton = { type ContinueButton = {
@ -15,17 +13,13 @@ type ContinueButton = {
} }
const ContinueButton = ({ continueHandler, activeStep, subStepValidatorSetup }: ContinueButton) => { const ContinueButton = ({ continueHandler, activeStep, subStepValidatorSetup }: ContinueButton) => {
const { isCopyPastedPhrase, isRightPhrase, mnemonic, validWords, isConfirmPhraseStage } = const { isCopyPastedPhrase, mnemonic, validWords, isConfirmPhraseStage } = useSelector(
useSelector((state: RootState) => state.keyGeneration) (state: RootState) => state.keyGeneration,
const dispatch = useDispatch() )
useEffect(() => {
dispatch(setIsRightPhrase(mnemonic.every(word => word !== '')))
}, [mnemonic])
const isDisabled = () => { const isDisabled = () => {
if ( if (
(isConfirmPhraseStage && !isRightPhrase) || (isConfirmPhraseStage && mnemonic.some(word => word === '')) ||
(isConfirmPhraseStage && validWords.some(w => w === false)) (isConfirmPhraseStage && validWords.some(w => w === false))
) { ) {
return true return true

View File

@ -3,7 +3,6 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit'
type KeyGenerationState = { type KeyGenerationState = {
mnemonic: string[] mnemonic: string[]
isCopyPastedPhrase: boolean isCopyPastedPhrase: boolean
isRightPhrase: boolean
validWords: boolean[] validWords: boolean[]
generatedMnemonic: string[] generatedMnemonic: string[]
isConfirmPhraseStage: boolean isConfirmPhraseStage: boolean
@ -17,7 +16,6 @@ type wordProps = {
const initialState: KeyGenerationState = { const initialState: KeyGenerationState = {
mnemonic: Array(24).fill(''), mnemonic: Array(24).fill(''),
isCopyPastedPhrase: false, isCopyPastedPhrase: false,
isRightPhrase: false,
validWords: Array(24).fill(true), validWords: Array(24).fill(true),
generatedMnemonic: Array(24).fill(''), generatedMnemonic: Array(24).fill(''),
isConfirmPhraseStage: false, isConfirmPhraseStage: false,
@ -38,9 +36,6 @@ const keyGenerationSlice = createSlice({
setIsCopyPastedPhrase: (state, action: PayloadAction<boolean>) => { setIsCopyPastedPhrase: (state, action: PayloadAction<boolean>) => {
state.isCopyPastedPhrase = action.payload state.isCopyPastedPhrase = action.payload
}, },
setIsRightPhrase: (state, action: PayloadAction<boolean>) => {
state.isRightPhrase = action.payload
},
setValidWords: (state, action: PayloadAction<boolean[]>) => { setValidWords: (state, action: PayloadAction<boolean[]>) => {
state.validWords = action.payload state.validWords = action.payload
}, },
@ -57,7 +52,6 @@ export const {
setWord, setWord,
setMnemonic, setMnemonic,
setIsCopyPastedPhrase, setIsCopyPastedPhrase,
setIsRightPhrase,
setValidWords, setValidWords,
setGeneratedMnemonic, setGeneratedMnemonic,
setIsConfirmPhraseStage, setIsConfirmPhraseStage,