fix: refresh admin self profile state

This commit is contained in:
Bastian Wagner
2026-08-01 11:45:03 +02:00
parent 431eba86e7
commit 945369796e
2 changed files with 56 additions and 4 deletions

View File

@@ -125,11 +125,15 @@ export class Users {
}
protected statusName(statusId?: number): string {
return statusId === 2 ? 'Inaktiv' : 'Aktiv';
if (statusId === 1) return 'Aktiv';
if (statusId === 2) return 'Inaktiv';
return 'Unbekannt';
}
protected roleName(roleId?: number): string {
return roleId === 1 ? 'Administrator' : 'Benutzer';
if (roleId === 1) return 'Administrator';
if (roleId === 2) return 'Benutzer';
return 'Unbekannt';
}
protected teamRoleName(name?: string): string {
@@ -170,7 +174,17 @@ export class Users {
let profileSaved = false;
profileRequest
.pipe(
tap(() => (profileSaved = true)),
tap((updatedUser) => {
profileSaved = true;
const currentUser = this.currentUser();
if (currentUser?.id === updatedUser.id) {
this.authStore.updateUser({
...currentUser,
firstName: updatedUser.firstName,
lastName: updatedUser.lastName,
});
}
}),
switchMap(() =>
roleId === value.role ? of(user) : this.adminUsersApi.updateRole(user.id, { role: value.role }),
),