Skip to content

Commit

Permalink
roles object store in signupDetails
Browse files Browse the repository at this point in the history
  • Loading branch information
shubhamsinghbundela committed Jul 24, 2023
1 parent 9b694b2 commit a02de8e
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions app/controllers/new-signup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -120,7 +121,7 @@ export default class NewSignUpController extends Controller {
...signupDetails,
roles: {
...userData.roles,
...this.roles,
...roles,
},
});
})
Expand Down

0 comments on commit a02de8e

Please sign in to comment.