fix handlers

This commit is contained in:
Hristo Nedelkov 2023-10-10 11:56:05 +03:00
parent 58cc42e185
commit 18823f7869
2 changed files with 15 additions and 15 deletions

View File

@ -6,12 +6,15 @@ import WithdrawalAddress from './WithdrawalAddress'
import LinkWithArrow from '../../../components/General/LinkWithArrow' import LinkWithArrow from '../../../components/General/LinkWithArrow'
import ValidatorsMenuWithPrice from '../../../components/General/ValidatorsMenuWithPrice' import ValidatorsMenuWithPrice from '../../../components/General/ValidatorsMenuWithPrice'
import { CLIENT_SETUP_SUBTITLE } from '../../../constants' import { CLIENT_SETUP_SUBTITLE } from '../../../constants'
import { useDispatch } from 'react-redux'
import { setIsValidatorSet } from '../../../redux/ValidatorOnboarding/ValidatorSetup/slice'
const ClientSetup = () => { const ClientSetup = () => {
const [, setIsValidatorSet] = useState(false) const dispatch = useDispatch()
const [validatorCount, setValidatorCount] = useState(0) const [validatorCount, setValidatorCount] = useState(0)
useEffect(() => { useEffect(() => {
setIsValidatorSet(validatorCount > 0) dispatch(setIsValidatorSet(validatorCount > 0))
}, [validatorCount]) }, [validatorCount])
const changeValidatorCountHandler = (value: string) => { const changeValidatorCountHandler = (value: string) => {

View File

@ -31,7 +31,10 @@ const ContinueButton = () => {
const { activeStep, subStepValidatorSetup } = useSelector( const { activeStep, subStepValidatorSetup } = useSelector(
(state: RootState) => state.validatorOnboarding, (state: RootState) => state.validatorOnboarding,
) )
const { subStepAdvisories, isValidatorSet } = useSelector((state: RootState) => state.advisories) const { isValidatorSet } = useSelector(
(state: RootState) => state.validatorSetup,
)
const { subStepAdvisories } = useSelector((state: RootState) => state.advisories)
const dispatch = useDispatch() const dispatch = useDispatch()
const navigate = useNavigate() const navigate = useNavigate()
@ -41,14 +44,14 @@ const ContinueButton = () => {
const getDisabledButton = () => { const getDisabledButton = () => {
if (activeStep === 4 && isConfirmPhraseStage) { if (activeStep === 4 && isConfirmPhraseStage) {
if (validWords.some(w => w === false)) { if (validWords.some(w => w === false)) {
return false return true
} }
} } else if (activeStep === 3 && !isValidatorSet) { return true }
return false return false
} }
setIsDisabled(getDisabledButton()) setIsDisabled(getDisabledButton())
}, [activeStep, subStepValidatorSetup, isConfirmPhraseStage, mnemonic, validWords]) }, [activeStep, subStepValidatorSetup, isConfirmPhraseStage, mnemonic, validWords, isValidatorSet])
const handleStep1 = () => { const handleStep1 = () => {
if (subStepAdvisories < 5) { if (subStepAdvisories < 5) {
@ -58,12 +61,7 @@ const ContinueButton = () => {
dispatch(setActiveStep(activeStep + 1)) dispatch(setActiveStep(activeStep + 1))
} }
} }
const handleStep3 = () => {
subStepValidatorSetup < 3
? dispatch(setSubStepValidatorSetup(subStepValidatorSetup + 1))
: dispatch(setSubStepValidatorSetup(0))
}
const handleStep4 = () => { const handleStep4 = () => {
if (!isConfirmPhraseStage && recoveryMechanism === KEYSTORE_FILES) { if (!isConfirmPhraseStage && recoveryMechanism === KEYSTORE_FILES) {
return dispatch(setActiveStep(activeStep + 1)) return dispatch(setActiveStep(activeStep + 1))
@ -90,8 +88,7 @@ const ContinueButton = () => {
const continueHandler = () => { const continueHandler = () => {
if (activeStep === 1) { if (activeStep === 1) {
handleStep1() handleStep1()
} else if (activeStep === 3) {
handleStep3()
} else if (activeStep === 4) { } else if (activeStep === 4) {
handleStep4() handleStep4()
} else { } else {
@ -133,7 +130,7 @@ const ContinueButton = () => {
<Button <Button
onPress={continueHandler} onPress={continueHandler}
size={40} size={40}
disabled={isDisabled || (isValidatorSet === false && activeStep === 3)} disabled={isDisabled}
> >
{activeStep < 5 ? 'Continue' : 'Continue to Dashboard'} {activeStep < 5 ? 'Continue' : 'Continue to Dashboard'}
</Button> </Button>