Skip to content

Commit

Permalink
[Sign Up Redesign] Fix sign up allowed routes [C-3488] (#6879)
Browse files Browse the repository at this point in the history
Co-authored-by: Nikki Kang <kangaroo233@gmail.com>
  • Loading branch information
nicoback2 and nicoback authored Dec 7, 2023
1 parent dc442e0 commit 7df0fda
Showing 1 changed file with 32 additions and 26 deletions.
58 changes: 32 additions & 26 deletions packages/web/src/pages/sign-up-page/utils/determineAllowedRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 7df0fda

Please sign in to comment.