mirror of
https://github.com/status-im/nimbus-gui.git
synced 2025-02-03 07:03:30 +00:00
fix handlers
This commit is contained in:
parent
58cc42e185
commit
18823f7869
@ -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) => {
|
||||||
|
@ -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>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user