From 2ef89cd2360bfa387035a1bedb608b5781c81d60 Mon Sep 17 00:00:00 2001 From: shubhamsigdar1 Date: Sat, 15 Jul 2023 00:23:16 +0530 Subject: [PATCH] added feature flag in signup flow --- app/components/new-signup/input.hbs | 27 +++++--- app/controllers/new-signup.js | 101 +++++++++++++++++----------- app/templates/new-signup.hbs | 45 ++++++++----- 3 files changed, 111 insertions(+), 62 deletions(-) diff --git a/app/components/new-signup/input.hbs b/app/components/new-signup/input.hbs index 92989abb..5bd6ba2a 100644 --- a/app/components/new-signup/input.hbs +++ b/app/components/new-signup/input.hbs @@ -16,13 +16,24 @@
- + {{#if this.dev}} + + {{else}} + + {{/if}}
\ No newline at end of file diff --git a/app/controllers/new-signup.js b/app/controllers/new-signup.js index 79248e81..4d32ec84 100644 --- a/app/controllers/new-signup.js +++ b/app/controllers/new-signup.js @@ -14,7 +14,7 @@ const { BASE_API_URL } = ENV; export default class NewSignUpController extends Controller { @service analytics; - queryParams = ['currentStep']; + queryParams = ['currentStep', 'dev']; @tracked isLoading = false; @tracked isButtonDisabled = true; @@ -93,10 +93,12 @@ export default class NewSignUpController extends Controller { @action async signup() { let roles; - if (this.developer) { - roles = { developer: this.developer }; - } else { - roles = { designer: this.designer }; + if (this.dev) { + if (this.developer) { + roles = { developer: this.developer }; + } else { + roles = { designer: this.designer }; + } } const signupDetails = { first_name: this.signupDetails.firstName, @@ -113,41 +115,64 @@ export default class NewSignUpController extends Controller { return (this.error = ERROR_MESSAGES.userName); } - fetch(`${BASE_API_URL}/users/self`, { - method: 'GET', - headers: { - 'Content-Type': 'application/json', - }, - credentials: 'include', - }) - .then((getResponse) => getResponse.json()) - .then((userData) => { - return registerUser({ - ...signupDetails, - roles: { - ...userData.roles, - ...roles, - }, - }); + if (this.dev) { + fetch(`${BASE_API_URL}/users/self`, { + method: 'GET', + headers: { + 'Content-Type': 'application/json', + }, + credentials: 'include', }) - .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); + .then((getResponse) => getResponse.json()) + .then((userData) => { + return registerUser({ + ...signupDetails, + roles: { + ...userData.roles, + ...roles, + }, + }); + }) + .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; - } - }) - .catch(() => { - this.analytics.trackEvent(NEW_SIGNUP_FLOW.UNABLE_TO_REGISTER); - this.error = ERROR_MESSAGES.others; - this.isButtonDisabled = false; - }) - .finally(() => { - this.isLoading = false; - }); + }) + .finally(() => { + this.isLoading = false; + }); + } else { + 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; + }); + } } } diff --git a/app/templates/new-signup.hbs b/app/templates/new-signup.hbs index 07e67200..50931a66 100644 --- a/app/templates/new-signup.hbs +++ b/app/templates/new-signup.hbs @@ -28,24 +28,37 @@ {{/if}} {{#if (eq this.currentStep this.FOURTH_STEP)}} - + {{#if this.dev}} + + {{else}} + + {{/if}} {{/if}} -{{#if (eq this.currentStep this.FIFTH_STEP)}} - +{{#if this.dev}} + {{#if (eq this.currentStep this.FIFTH_STEP)}} + + {{/if}} {{/if}} {{#if (eq this.currentStep this.LAST_STEP)}}