fix continue button to work with all
This commit is contained in:
parent
18cfc83342
commit
9ab31b1a57
|
@ -29,39 +29,40 @@ const ContinueButton = () => {
|
||||||
generatedMnemonic,
|
generatedMnemonic,
|
||||||
} = useSelector((state: RootState) => state.keyGeneration)
|
} = useSelector((state: RootState) => state.keyGeneration)
|
||||||
|
|
||||||
const stepToPathMap: (string | string[])[] = [
|
|
||||||
'/validator-onboarding/overview',
|
|
||||||
'/validator-onboarding/advisories',
|
|
||||||
[
|
|
||||||
'/validator-onboarding/validator-setup',
|
|
||||||
'/validator-onboarding/validator-setup-install',
|
|
||||||
'/validator-onboarding/consensus-selection',
|
|
||||||
'/validator-onboarding/activation-validator-setup',
|
|
||||||
],
|
|
||||||
'/validator-onboarding/client-setup',
|
|
||||||
'/validator-onboarding/key-generation',
|
|
||||||
'/validator-onboarding/deposit',
|
|
||||||
'/dashboard',
|
|
||||||
]
|
|
||||||
const { activeStep, subStepValidatorSetup } = useSelector(
|
const { activeStep, subStepValidatorSetup } = useSelector(
|
||||||
(state: RootState) => state.validatorOnboarding,
|
(state: RootState) => state.validatorOnboarding,
|
||||||
)
|
)
|
||||||
|
const dispatch = useDispatch()
|
||||||
|
|
||||||
|
const pathToStepMap = {
|
||||||
|
'/validator-onboarding/': 0,
|
||||||
|
'/validator-onboarding/advisories': 1,
|
||||||
|
'/validator-onboarding/validator-setup': 2,
|
||||||
|
'/validator-onboarding/validator-setup-install': 3,
|
||||||
|
'/validator-onboarding/consensus-selection': 4,
|
||||||
|
'/validator-onboarding/activation-validator-setup': 5,
|
||||||
|
'/validator-onboarding/client-setup': 6,
|
||||||
|
'/validator-onboarding/key-generation': 7,
|
||||||
|
'/validator-onboarding/deposit': 8,
|
||||||
|
'/validator-onboarding/activation': 9,
|
||||||
|
}
|
||||||
|
dispatch(setActiveStep(pathToStepMap[location.pathname as keyof typeof pathToStepMap] || 0))
|
||||||
|
|
||||||
const { isValidatorSet } = useSelector((state: RootState) => state.validatorSetup)
|
const { isValidatorSet } = useSelector((state: RootState) => state.validatorSetup)
|
||||||
|
|
||||||
const dispatch = useDispatch()
|
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
const isActivationValScreen = activeStep === 3 && subStepValidatorSetup === 3
|
const isActivationValScreen = activeStep === 3 && subStepValidatorSetup === 3
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const getDisabledButton = () => {
|
const getDisabledButton = () => {
|
||||||
if (activeStep === 4 && isConfirmPhraseStage) {
|
if (activeStep === 7 && isConfirmPhraseStage) {
|
||||||
if (
|
if (
|
||||||
validWords.some(w => w === false) ||
|
validWords.some(w => w === false) ||
|
||||||
generatedMnemonic.some((w, i) => w !== mnemonic[i])
|
generatedMnemonic.some((w, i) => w !== mnemonic[i])
|
||||||
) {
|
) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
} else if (activeStep === 3 && !isValidatorSet) {
|
} else if (activeStep === 6 && !isValidatorSet) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
@ -111,22 +112,22 @@ const ContinueButton = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const continueHandler = () => {
|
const continueHandler = () => {
|
||||||
let nextPath: string
|
let nextPath
|
||||||
|
if (activeStep === 0) nextPath = '/validator-onboarding/advisories'
|
||||||
if (activeStep === 2) {
|
else if (activeStep === 1) nextPath = '/validator-onboarding/validator-setup'
|
||||||
const paths = stepToPathMap[activeStep]
|
else if (activeStep === 2) nextPath = '/validator-onboarding/validator-setup-install'
|
||||||
if (Array.isArray(paths)) {
|
else if (activeStep === 3) nextPath = '/validator-onboarding/consensus-selection'
|
||||||
nextPath = paths[subStepValidatorSetup + 1] || '/dashboard'
|
else if (activeStep === 4) nextPath = '/validator-onboarding/activation-validator-setup'
|
||||||
} else {
|
else if (activeStep === 5) nextPath = '/validator-onboarding/client-setup'
|
||||||
nextPath = '/dashboard'
|
else if (activeStep === 6) nextPath = '/validator-onboarding/key-generation'
|
||||||
}
|
else if (activeStep === 7) nextPath = '/validator-onboarding/deposit'
|
||||||
} else {
|
else if (activeStep === 8) nextPath = '/validator-onboarding/activation'
|
||||||
const path = stepToPathMap[activeStep + 1]
|
else if (activeStep === 9) nextPath = '/dashboard'
|
||||||
nextPath = typeof path === 'string' ? path : '/dashboard'
|
else nextPath = '/validator-onboarding/'
|
||||||
}
|
|
||||||
|
|
||||||
navigate(nextPath)
|
navigate(nextPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<XStack
|
<XStack
|
||||||
style={{
|
style={{
|
||||||
|
|
Loading…
Reference in New Issue