@@ -10,6 +10,7 @@ import { MatSort, MatSortable } from '@angular/material/sort';
1010import { MatTableDataSource } from '@angular/material/table' ;
1111import { User , UserService , RoleService } from '../../../generated/player-api' ;
1212import { RolesService } from '../../../services/roles/roles.service' ;
13+ import { DialogService } from '../../../services/dialog/dialog.service' ;
1314
1415export interface Action {
1516 Value : string ;
@@ -23,7 +24,7 @@ export interface Action {
2324 standalone : false
2425} )
2526export class AdminUserSearchComponent implements OnInit , AfterViewInit {
26- public displayedColumns : string [ ] = [ 'name' , 'roleName' ] ;
27+ public displayedColumns : string [ ] = [ 'name' , 'roleName' , 'actions' ] ;
2728 public filterString : string ;
2829
2930 public editUserText = 'Edit User' ;
@@ -42,7 +43,8 @@ export class AdminUserSearchComponent implements OnInit, AfterViewInit {
4243
4344 constructor (
4445 private userService : UserService ,
45- private rolesService : RolesService
46+ private rolesService : RolesService ,
47+ private dialogService : DialogService
4648 ) { }
4749
4850 /**
@@ -110,4 +112,28 @@ export class AdminUserSearchComponent implements OnInit, AfterViewInit {
110112 this . isLoading = false ;
111113 } ) ;
112114 }
115+
116+ /**
117+ * Deletes a user after confirmation
118+ * @param user The user to delete
119+ */
120+ deleteUser ( user : User ) {
121+ this . dialogService
122+ . confirm (
123+ 'Delete User?' ,
124+ `Are you sure you want to delete ${ user . name || user . id } ?` ,
125+ {
126+ buttonTrueText : 'Delete' ,
127+ buttonFalseText : 'Cancel' ,
128+ }
129+ )
130+ . subscribe ( ( result ) => {
131+ if ( result . confirm ) {
132+ this . userService . deleteUser ( user . id ) . subscribe ( ( ) => {
133+ // Refresh the users list after successful deletion
134+ this . refreshUsers ( ) ;
135+ } ) ;
136+ }
137+ } ) ;
138+ }
113139}
0 commit comments