From a02de8e71a9b1cfd34c2e3a4b809ee8849eb9d2b Mon Sep 17 00:00:00 2001 From: shubhamsigdar1 Date: Mon, 24 Jul 2023 16:44:57 +0530 Subject: [PATCH] roles object store in signupDetails --- app/controllers/new-signup.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/app/controllers/new-signup.js b/app/controllers/new-signup.js index ab09903a..9603fed1 100644 --- a/app/controllers/new-signup.js +++ b/app/controllers/new-signup.js @@ -31,10 +31,9 @@ export default class NewSignUpController extends Controller { firstName: '', lastName: '', username: '', + roles: {}, }; - @tracked roles = {}; - @action changeStepToTwo() { this.currentStep = this.SECOND_STEP; this.analytics.trackEvent(NEW_SIGNUP_FLOW.USER_GETTING_STARTED); @@ -77,13 +76,8 @@ export default class NewSignUpController extends Controller { } @action handleCheckboxInputChange(key, value) { - this.error = ''; - if (value) { - set(this.roles, key, true); - } else { - delete this.roles[key]; - } - if (Object.keys(this.roles).length > 0) { + set(this.signupDetails.roles, key, value); + if (Object.values(this.signupDetails.roles).includes(true)) { this.isButtonDisabled = false; } else { this.isButtonDisabled = true; @@ -96,6 +90,13 @@ export default class NewSignUpController extends Controller { last_name: this.signupDetails.lastName, username: this.signupDetails.username, }; + const roles = {}; + Object.entries(this.signupDetails.roles).forEach(([key, value]) => { + if (value === true) { + roles[key] = value; + } + }); + console.log(roles); this.isLoading = true; const isUsernameAvailable = await checkUserName(signupDetails.username); @@ -120,7 +121,7 @@ export default class NewSignUpController extends Controller { ...signupDetails, roles: { ...userData.roles, - ...this.roles, + ...roles, }, }); })