Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Sign Up Redesign] Fix sign up allowed routes [C-3488] #6879

Merged
merged 2 commits into from
Dec 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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