feat: use is confirm phrase from redux

This commit is contained in:
RadoslavDimchev 2023-10-08 11:59:24 +03:00
parent 8358f8593c
commit d124e64f66
3 changed files with 9 additions and 23 deletions

View File

@ -20,7 +20,6 @@ export const Default: Story = {
args: { args: {
continueHandler: () => {}, continueHandler: () => {},
activeStep: 0, activeStep: 0,
isConfirmPhraseStage: false,
subStepValidatorSetup: 0, subStepValidatorSetup: 0,
}, },
} }
@ -29,7 +28,6 @@ export const Disabled: Story = {
args: { args: {
continueHandler: () => {}, continueHandler: () => {},
activeStep: 0, activeStep: 0,
isConfirmPhraseStage: true,
subStepValidatorSetup: 0, subStepValidatorSetup: 0,
}, },
} }

View File

@ -11,19 +11,12 @@ import LinkWithArrow from '../../components/General/LinkWithArrow'
type ContinueButton = { type ContinueButton = {
continueHandler: () => void continueHandler: () => void
activeStep: number activeStep: number
isConfirmPhraseStage: boolean
subStepValidatorSetup: number subStepValidatorSetup: number
} }
const ContinueButton = ({ const ContinueButton = ({ continueHandler, activeStep, subStepValidatorSetup }: ContinueButton) => {
continueHandler, const { isCopyPastedPhrase, isRightPhrase, words, validWords, isConfirmPhraseStage } =
activeStep, useSelector((state: RootState) => state.keyGeneration)
isConfirmPhraseStage,
subStepValidatorSetup,
}: ContinueButton) => {
const { isCopyPastedPhrase, isRightPhrase, words, validWords } = useSelector(
(state: RootState) => state.keyGeneration,
)
const dispatch = useDispatch() const dispatch = useDispatch()
useEffect(() => { useEffect(() => {

View File

@ -17,6 +17,7 @@ import ValidatorSetup from './ValidatorSetup/ValidatorSetup/ValidatorSetup'
import ValidatorSetupInstall from './ValidatorSetup/ValidatorInstalling/ValidatorInstall' import ValidatorSetupInstall from './ValidatorSetup/ValidatorInstalling/ValidatorInstall'
import ContinueButton from './ContinueButton' import ContinueButton from './ContinueButton'
import { import {
setIsConfirmPhraseStage,
setIsCopyPastedPhrase, setIsCopyPastedPhrase,
setValidWords, setValidWords,
} from '../../redux/ValidatorOnboarding/KeyGeneration/slice' } from '../../redux/ValidatorOnboarding/KeyGeneration/slice'
@ -26,9 +27,10 @@ import './layoutGradient.css'
const ValidatorOnboarding = () => { const ValidatorOnboarding = () => {
const [activeStep, setActiveStep] = useState(0) const [activeStep, setActiveStep] = useState(0)
const [isConfirmPhraseStage, setIsConfirmPhraseStage] = useState(false)
const [subStepValidatorSetup, setSubStepValidatorSetup] = useState(0) const [subStepValidatorSetup, setSubStepValidatorSetup] = useState(0)
const { isCopyPastedPhrase, words } = useSelector((state: RootState) => state.keyGeneration) const { isCopyPastedPhrase, words, isConfirmPhraseStage } = useSelector(
(state: RootState) => state.keyGeneration,
)
const navigate = useNavigate() const navigate = useNavigate()
const dispatch = useDispatch() const dispatch = useDispatch()
@ -38,7 +40,7 @@ const ValidatorOnboarding = () => {
const continueHandler = () => { const continueHandler = () => {
if (activeStep === 4 && isConfirmPhraseStage === false) { if (activeStep === 4 && isConfirmPhraseStage === false) {
return setIsConfirmPhraseStage(true) return dispatch(setIsConfirmPhraseStage(true))
} else if (activeStep === 4 && isConfirmPhraseStage === true) { } else if (activeStep === 4 && isConfirmPhraseStage === true) {
const newValidWords = words.map(w => wordlist.includes(w)) const newValidWords = words.map(w => wordlist.includes(w))
dispatch(setValidWords(newValidWords)) dispatch(setValidWords(newValidWords))
@ -46,7 +48,7 @@ const ValidatorOnboarding = () => {
if (newValidWords.every(w => w === true)) { if (newValidWords.every(w => w === true)) {
setActiveStep(activeStep + 1) setActiveStep(activeStep + 1)
removeCopyPastePhraseInfoBox() removeCopyPastePhraseInfoBox()
removeConfirmPhraseStage() dispatch(setIsConfirmPhraseStage(false))
} else { } else {
return return
} }
@ -68,12 +70,6 @@ const ValidatorOnboarding = () => {
} }
} }
const removeConfirmPhraseStage = () => {
if (isConfirmPhraseStage) {
setIsConfirmPhraseStage(false)
}
}
return ( return (
<div className="gradient-wrapper"> <div className="gradient-wrapper">
<YStack <YStack
@ -128,7 +124,6 @@ const ValidatorOnboarding = () => {
<ContinueButton <ContinueButton
activeStep={activeStep} activeStep={activeStep}
continueHandler={continueHandler} continueHandler={continueHandler}
isConfirmPhraseStage={isConfirmPhraseStage}
subStepValidatorSetup={subStepValidatorSetup} subStepValidatorSetup={subStepValidatorSetup}
/> />
</YStack> </YStack>