Long story short I'm junior .Net developer and I recived task to change something in our Angular app, I have no idea how it works and I'm struggling to change it. I'm stuck on one topic.
User is created based on the form, after submiting it there is a call:
submit() {
if (this.accountForm.invalid) {
return;
}
const {
email,
accountExpirationDate,
firstName,
lastName,
permissionLevel,
timezone,
language,
} = this.accountForm.value;
const accountExpirationDateMs = new Date(accountExpirationDate || null).getTime();
const result = {
email,
accountExpirationDate: accountExpirationDateMs || null,
name: firstName,
lastName,
roleExternalIds: [permissionLevel],
timezone,
languageExternalId: language,
avatar: this.avatar
};
if (!this.id) {
this.store.dispatch(fromUser.createUserAction({ result } as any));
} else {
this.isPending = true;
this.store.dispatch(fromUser.editUserAction({ result, id: this.id } as any));
setTimeout(() => {
this.store.dispatch(fromSettings.getCurrentUserInfoAction());
}, 1200);
}
}
After the this.store.dispatch(fromUser.createUserAction({ result } as any));
in the if statement I have to make two more calls which requires me to provide userId which is returned by the backend after the user creation, but I have no idea how to extract it from this call.
Create user action looks like this:
export const createUserAction = createAction('[User management] Create User', props<{result: UserRegistrationRequestModel}>());
And it's making this call I belive:
createUser$ = createEffect(() =>
this.actions$.pipe(
ofType(fromUserManagement.createUserAction),
mergeMap((action) => {
return this.identityServiceClient.create(action.result).pipe(
map(response => {
this.messageService.open('User has been created!', 'success');
this.router.navigateByUrl('/app/users/list');
return fromUserManagement.createUserActionSuccess(response)
}),
catchError(() => {
this.messageService.open('Something went wrong!', 'danger');
return fromUserManagement.createUserActionError;
})
);
})
)
)
It might be stupid question with not enough information, but I'm using angular first time in my life so honestly I have no idea how it works :D