diff --git a/app/constants/new-signup.js b/app/constants/new-signup.js index d975ff56..e7a374cb 100644 --- a/app/constants/new-signup.js +++ b/app/constants/new-signup.js @@ -4,6 +4,7 @@ const LAST_NAME = 'lastName'; const USERNAME = 'username'; const ROLE = 'role'; const THANK_YOU = 'thank-you'; + export const NEW_SIGNUP_STEPS = [ GET_STARTED, FIRST_NAME, @@ -12,17 +13,20 @@ export const NEW_SIGNUP_STEPS = [ ROLE, THANK_YOU, ]; + export const LABEL_TEXT = { firstName: 'What is your first name?', lastName: 'And what is your last name?', username: 'Now choose your awesome username!', role: 'Select your role', }; + export const ERROR_MESSAGES = { userName: 'username already taken!', others: 'something went wrong', usernameGeneration: 'Username cannot be generated', }; + export const CHECK_BOX_DATA = [ { label: 'Developer', diff --git a/app/controllers/new-signup.js b/app/controllers/new-signup.js index 322cd4de..88677e83 100644 --- a/app/controllers/new-signup.js +++ b/app/controllers/new-signup.js @@ -79,26 +79,31 @@ export default class NewSignUpController extends Controller { throw new Error(ERROR_MESSAGES.usernameGeneration); } } + @action changeStepToThree() { this.currentStep = this.THIRD_STEP; this.analytics.trackEvent(NEW_SIGNUP_FLOW.USER_FIRST_NAME); this.isButtonDisabled = true; } + @action changeStepToFour() { this.currentStep = this.FOURTH_STEP; this.analytics.trackEvent(NEW_SIGNUP_FLOW.USER_LAST_NAME); this.isButtonDisabled = true; } + @action changeStepToFive() { this.currentStep = this.FIFTH_STEP; this.analytics.trackEvent(NEW_SIGNUP_FLOW.USER_USERNAME); this.isButtonDisabled = true; } + @action register() { this.analytics.trackEvent(NEW_SIGNUP_FLOW.USER_ROLE); this.isButtonDisabled = true; this.signup(); } + @action completeSignUp() { this.analytics.trackEvent(NEW_SIGNUP_FLOW.NEW_SIGNUP_FLOW_DONE); if (this.isDevMode) { @@ -107,12 +112,14 @@ export default class NewSignUpController extends Controller { window.open(GOTO_URL, '_self'); } } + @action handleInputChange(key, value) { this.error = ''; set(this.signupDetails, key, value); if (this.signupDetails[key] > '') this.isButtonDisabled = false; else this.isButtonDisabled = true; } + @action handleCheckboxInputChange(key, value) { set(this.signupDetails.roles, key, value); if (Object.values(this.signupDetails.roles).includes(true)) { @@ -121,6 +128,7 @@ export default class NewSignUpController extends Controller { this.isButtonDisabled = true; } } + @action async signup() { try { let user; @@ -141,6 +149,7 @@ export default class NewSignUpController extends Controller { roles[key] = value; } }); + const isUsernameAvailable = await checkUserName(signupDetails.username); if (!isUsernameAvailable) { this.analytics.trackEvent(NEW_SIGNUP_FLOW.USERNAME_NOT_AVAILABLE); @@ -148,6 +157,7 @@ export default class NewSignUpController extends Controller { this.isButtonDisabled = false; return (this.error = ERROR_MESSAGES.userName); } + const res = this.isDevMode ? await newRegisterUser(signupDetails, roles) : await registerUser(signupDetails); diff --git a/app/templates/new-signup.hbs b/app/templates/new-signup.hbs index 462f7dcc..82ea4d96 100644 --- a/app/templates/new-signup.hbs +++ b/app/templates/new-signup.hbs @@ -6,6 +6,7 @@ @currentStep={{this.currentStep}} /> {{/if}} + {{#if (eq this.currentStep this.SECOND_STEP)}} {{/if}} + {{#if (eq this.currentStep this.THIRD_STEP)}} {{#if this.isDevMode}}