Skip to content

Commit

Permalink
chore: remove extra spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
vinit717 committed Aug 24, 2024
1 parent f36a93c commit bba28c3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/constants/new-signup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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',
Expand Down
10 changes: 10 additions & 0 deletions app/controllers/new-signup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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)) {
Expand All @@ -121,6 +128,7 @@ export default class NewSignUpController extends Controller {
this.isButtonDisabled = true;
}
}

@action async signup() {
try {
let user;
Expand All @@ -141,13 +149,15 @@ 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);
this.isLoading = false;
this.isButtonDisabled = false;
return (this.error = ERROR_MESSAGES.userName);
}

const res = this.isDevMode
? await newRegisterUser(signupDetails, roles)
: await registerUser(signupDetails);
Expand Down
2 changes: 2 additions & 0 deletions app/templates/new-signup.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
@currentStep={{this.currentStep}}
/>
{{/if}}

{{#if (eq this.currentStep this.SECOND_STEP)}}
<NewSignup::Input
@onClick={{this.changeStepToThree}}
Expand All @@ -15,6 +16,7 @@
@isLoading={{this.isLoading}}
/>
{{/if}}

{{#if (eq this.currentStep this.THIRD_STEP)}}
{{#if this.isDevMode}}
<NewSignup::Input
Expand Down

0 comments on commit bba28c3

Please sign in to comment.