diff --git a/packages/web/src/pages/sign-up-page/utils/determineAllowedRoutes.ts b/packages/web/src/pages/sign-up-page/utils/determineAllowedRoutes.ts index fab640f0fd5..75a04813602 100644 --- a/packages/web/src/pages/sign-up-page/utils/determineAllowedRoutes.ts +++ b/packages/web/src/pages/sign-up-page/utils/determineAllowedRoutes.ts @@ -17,37 +17,43 @@ export const determineAllowedRoute = ( const attemptedPath = requestedRoute.replace('/signup/', '') // Have to type as string[] to avoid too narrow of a type for comparing against let allowedRoutes: string[] = [SignUpPath.createEmail] // create email is available by default + if (signUpState.linkedSocialOnFirstPage) { + allowedRoutes.push(SignUpPath.createLoginDetails) + allowedRoutes.push(SignUpPath.reviewHandle) + } if (signUpState.email.value) { // Already have email allowedRoutes.push(SignUpPath.createPassword) - } - if (signUpState.password.value || signUpState.useMetaMask) { - // Already have password - allowedRoutes.push(SignUpPath.pickHandle) - } - if (signUpState.handle.value) { - if (signUpState.linkedSocialOnFirstPage) { - allowedRoutes.push(SignUpPath.createLoginDetails) - } - // Already have handle or it needs review - allowedRoutes.push(SignUpPath.reviewHandle) - allowedRoutes.push(SignUpPath.finishProfile) - } - if (signUpState.name.value) { - // Already have display name - // At this point the account is fully created & logged in; now user can't back to account creation steps - allowedRoutes = [SignUpPath.selectGenres] - } - // TODO: These checks below here may need to fall under a different route umbrella separate from sign up - if (signUpState.genres) { - // Already have genres selected - allowedRoutes.push(SignUpPath.selectArtists) - } + if (signUpState.password.value || signUpState.useMetaMask) { + // Already have password + allowedRoutes.push(SignUpPath.pickHandle) + + if (signUpState.handle.value) { + // Already have handle or it needs review + allowedRoutes.push(SignUpPath.reviewHandle) + allowedRoutes.push(SignUpPath.finishProfile) + + if (signUpState.name.value) { + // Already have display name - if (signUpState.followArtists?.selectedUserIds?.length >= 3) { - // Already have 3 artists followed - allowedRoutes.push(SignUpPath.appCta) + // At this point the account is fully created & logged in; now user can't back to account creation steps + // TODO: What to do if account creation fails? + allowedRoutes = [SignUpPath.selectGenres] + + // TODO: These checks below here may need to fall under a different route umbrella separate from sign up + if (signUpState.genres) { + // Already have genres selected + allowedRoutes.push(SignUpPath.selectArtists) + + if (signUpState.followArtists?.selectedUserIds?.length >= 3) { + // Already have 3 artists followed + allowedRoutes.push(SignUpPath.appCta) + } + } + } + } + } } const isAllowedRoute = allowedRoutes.includes(attemptedPath)