From a843f6707a4280697f6209618499af0adb723050 Mon Sep 17 00:00:00 2001 From: vinit717 Date: Thu, 8 Feb 2024 10:27:59 +0530 Subject: [PATCH 1/2] fix : signup --- app/constants/new-signup.js | 13 ------ app/controllers/new-signup.js | 80 +++++++++++------------------------ app/templates/new-signup.hbs | 24 +++-------- app/utils/check-username.js | 25 ++++++++--- app/utils/register-api.js | 18 ++------ 5 files changed, 50 insertions(+), 110 deletions(-) diff --git a/app/constants/new-signup.js b/app/constants/new-signup.js index 81fd0bc5..7779e304 100644 --- a/app/constants/new-signup.js +++ b/app/constants/new-signup.js @@ -9,7 +9,6 @@ export const NEW_SIGNUP_STEPS = [ GET_STARTED, FIRST_NAME, LAST_NAME, - USERNAME, ROLE, THANK_YOU, ]; @@ -31,18 +30,6 @@ export const CHECK_BOX_DATA = [ label: 'Developer', name: 'developer', }, - { - label: 'Designer', - name: 'designer', - }, - { - label: 'Maven', - name: 'maven', - }, - { - label: 'Product Manager', - name: 'productmanager', - }, ]; export const GET_STARTED_MAIN_HEADING = 'Thank you for connecting your GitHub!'; diff --git a/app/controllers/new-signup.js b/app/controllers/new-signup.js index 1c541ea5..03bedd7a 100644 --- a/app/controllers/new-signup.js +++ b/app/controllers/new-signup.js @@ -12,8 +12,6 @@ export default class NewSignUpController extends Controller { @service analytics; @service featureFlag; - queryParams = ['currentStep', 'dev']; - @tracked isLoading = false; @tracked isButtonDisabled = true; @tracked error = ''; @@ -22,12 +20,7 @@ export default class NewSignUpController extends Controller { SECOND_STEP = NEW_SIGNUP_STEPS[1]; THIRD_STEP = NEW_SIGNUP_STEPS[2]; FOURTH_STEP = NEW_SIGNUP_STEPS[3]; - FIFTH_STEP = NEW_SIGNUP_STEPS[4]; - LAST_STEP = NEW_SIGNUP_STEPS[5]; - - get isDevMode() { - return this.featureFlag.isDevMode; - } + LAST_STEP = NEW_SIGNUP_STEPS[4]; @tracked signupDetails = { firstName: '', @@ -66,12 +59,10 @@ export default class NewSignUpController extends Controller { } @action completeSignUp() { + console.log('click'); this.analytics.trackEvent(NEW_SIGNUP_FLOW.NEW_SIGNUP_FLOW_DONE); - if (this.isDevMode) { - window.open('https://realdevsquad.com/goto?dev=true', '_self'); - } else { - window.open(GOTO_URL, '_self'); - } + + window.open(GOTO_URL, '_self'); } @action handleInputChange(key, value) { @@ -94,7 +85,6 @@ export default class NewSignUpController extends Controller { const signupDetails = { first_name: this.signupDetails.firstName, last_name: this.signupDetails.lastName, - username: this.signupDetails.username, }; const roles = {}; Object.entries(this.signupDetails.roles).forEach(([key, value]) => { @@ -104,56 +94,34 @@ export default class NewSignUpController extends Controller { }); this.isLoading = true; - - const isUsernameAvailable = await checkUserName(signupDetails.username); - if (!isUsernameAvailable) { + const username = await checkUserName( + signupDetails.first_name, + signupDetails.last_name + ); + if (!username) { this.analytics.trackEvent(NEW_SIGNUP_FLOW.USERNAME_NOT_AVAILABLE); this.isLoading = false; this.isButtonDisabled = false; return (this.error = ERROR_MESSAGES.userName); } - - if (this.isDevMode) { - try { - const res = await newRegisterUser(signupDetails, roles); - if (res.status === 204) { - this.analytics.identifyUser(); - this.analytics.trackEvent(NEW_SIGNUP_FLOW.USER_REGISTERED); - this.currentStep = this.LAST_STEP; - } else { - this.analytics.trackEvent(NEW_SIGNUP_FLOW.UNABLE_TO_SIGNUP); - this.error = ERROR_MESSAGES.others; - this.isButtonDisabled = false; - } - } catch (error) { - this.analytics.trackEvent(NEW_SIGNUP_FLOW.UNABLE_TO_REGISTER); + signupDetails.username = username.username; + try { + const res = await newRegisterUser(signupDetail, roles); + if (res.status === 204) { + this.analytics.identifyUser(); + this.analytics.trackEvent(NEW_SIGNUP_FLOW.USER_REGISTERED); + this.currentStep = this.LAST_STEP; + } else { + this.analytics.trackEvent(NEW_SIGNUP_FLOW.UNABLE_TO_SIGNUP); this.error = ERROR_MESSAGES.others; this.isButtonDisabled = false; - } finally { - this.isLoading = false; } - } else { - //this will get removed after removing feature flag - registerUser(signupDetails) - .then((res) => { - if (res.status === 204) { - this.analytics.identifyUser(); - this.analytics.trackEvent(NEW_SIGNUP_FLOW.USER_REGISTERED); - this.currentStep = this.LAST_STEP; - } else { - this.analytics.trackEvent(NEW_SIGNUP_FLOW.UNABLE_TO_SIGNUP); - this.error = ERROR_MESSAGES.others; - this.isButtonDisabled = false; - } - }) - .catch(() => { - this.analytics.trackEvent(NEW_SIGNUP_FLOW.UNABLE_TO_REGISTER); - this.error = ERROR_MESSAGES.others; - this.isButtonDisabled = false; - }) - .finally(() => { - this.isLoading = false; - }); + } catch (error) { + this.analytics.trackEvent(NEW_SIGNUP_FLOW.UNABLE_TO_REGISTER); + this.error = ERROR_MESSAGES.others; + this.isButtonDisabled = false; + } finally { + this.isLoading = false; } } } diff --git a/app/templates/new-signup.hbs b/app/templates/new-signup.hbs index 3239b741..20c79924 100644 --- a/app/templates/new-signup.hbs +++ b/app/templates/new-signup.hbs @@ -28,30 +28,17 @@ {{/if}} {{#if (eq this.currentStep this.FOURTH_STEP)}} - {{#if this.isDevMode}} - - {{else}} - - {{/if}} {{/if}} -{{#if this.isDevMode}} - {{#if (eq this.currentStep this.FIFTH_STEP)}} + + {{!-- {{#if (eq this.currentStep this.FIFTH_STEP)}} - {{/if}} -{{/if}} +{{/if}} --}} {{#if (eq this.currentStep this.LAST_STEP)}} credentials: 'include', }); -const newRegisterUser = async (signupDetails, roles) => { - const getResponse = await fetch(`${BASE_API_URL}/users/self`, { - method: 'GET', - headers: { - 'Content-Type': 'application/json', - }, - credentials: 'include', - }); - - const userData = await getResponse.json(); - - const res = await registerUser({ - ...signupDetails, +const newRegisterUser = async (signupDetail, roles) => { + const res = await registerUser({ + ...signupDetail, roles: { - ...userData.roles, ...roles, }, }); - return res; }; From 14568bd9b5df39bdf6ede3cf1853e2f22ded4b0d Mon Sep 17 00:00:00 2001 From: vinit717 Date: Thu, 8 Feb 2024 10:28:41 +0530 Subject: [PATCH 2/2] fix : signup --- app/constants/new-signup.js | 1 - app/controllers/new-signup.js | 4 ++-- app/templates/new-signup.hbs | 11 ----------- app/utils/check-username.js | 11 ++--------- app/utils/register-api.js | 2 +- 5 files changed, 5 insertions(+), 24 deletions(-) diff --git a/app/constants/new-signup.js b/app/constants/new-signup.js index 7779e304..592df5b3 100644 --- a/app/constants/new-signup.js +++ b/app/constants/new-signup.js @@ -1,7 +1,6 @@ const GET_STARTED = 'get-started'; const FIRST_NAME = 'firstName'; const LAST_NAME = 'lastName'; -const USERNAME = 'username'; const ROLE = 'role'; const THANK_YOU = 'thank-you'; diff --git a/app/controllers/new-signup.js b/app/controllers/new-signup.js index 03bedd7a..46b91785 100644 --- a/app/controllers/new-signup.js +++ b/app/controllers/new-signup.js @@ -2,7 +2,7 @@ import Controller from '@ember/controller'; import { action, set } from '@ember/object'; import { inject as service } from '@ember/service'; import { tracked } from '@glimmer/tracking'; -import { registerUser, newRegisterUser } from '../utils/register-api'; +import { newRegisterUser } from '../utils/register-api'; import { GOTO_URL } from '../constants/url'; import { NEW_SIGNUP_FLOW } from '../constants/analytics'; import { ERROR_MESSAGES, NEW_SIGNUP_STEPS } from '../constants/new-signup'; @@ -106,7 +106,7 @@ export default class NewSignUpController extends Controller { } signupDetails.username = username.username; try { - const res = await newRegisterUser(signupDetail, roles); + const res = await newRegisterUser(signupDetails, roles); if (res.status === 204) { this.analytics.identifyUser(); this.analytics.trackEvent(NEW_SIGNUP_FLOW.USER_REGISTERED); diff --git a/app/templates/new-signup.hbs b/app/templates/new-signup.hbs index 20c79924..77fd9244 100644 --- a/app/templates/new-signup.hbs +++ b/app/templates/new-signup.hbs @@ -37,17 +37,6 @@ /> {{/if}} - - {{!-- {{#if (eq this.currentStep this.FIFTH_STEP)}} - -{{/if}} --}} - {{#if (eq this.currentStep this.LAST_STEP)}} }); const newRegisterUser = async (signupDetail, roles) => { - const res = await registerUser({ + const res = await registerUser({ ...signupDetail, roles: { ...roles,