fix continue button to work with sub-urls

This commit is contained in:
Hristo Nedelkov 2024-01-29 13:08:47 +02:00
parent 3b32c83347
commit 6be043bad0
1 changed files with 29 additions and 14 deletions

View File

@ -29,6 +29,20 @@ 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,
) )
@ -97,21 +111,22 @@ const ContinueButton = () => {
} }
const continueHandler = () => { const continueHandler = () => {
if (activeStep === 1) { let nextPath: string
handleStep1()
} else if (activeStep === 2) {
handleStep2()
} else if (activeStep === 4) {
handleStep4()
} else {
if (activeStep < 6) {
dispatch(setActiveStep(activeStep + 1))
} else {
navigate('/dashboard')
}
}
}
if (activeStep === 2) {
const paths = stepToPathMap[activeStep]
if (Array.isArray(paths)) {
nextPath = paths[subStepValidatorSetup + 1] || '/dashboard'
} else {
nextPath = '/dashboard'
}
} else {
const path = stepToPathMap[activeStep + 1]
nextPath = typeof path === 'string' ? path : '/dashboard'
}
navigate(nextPath)
}
return ( return (
<XStack <XStack
style={{ style={{