@@ -31,3 +29,9 @@
}
+
+
diff --git a/src/app/components/user-table/user-table.ts b/src/app/components/user-table/user-table.ts
index 92212d3..8a5c86f 100644
--- a/src/app/components/user-table/user-table.ts
+++ b/src/app/components/user-table/user-table.ts
@@ -65,4 +65,46 @@ export class UserTable implements OnInit {
await this.fetchUsers();
}
+ async edit(id: number, updateUserComponent: ProfilForm) {
+ if (updateUserComponent.profilForm.invalid) {
+ this.notificationService.error(
+ 'Erreur',
+ 'Erreur d\'écriture dans le formulaire'
+ )
+ return;
+ }
+
+ try {
+ const users = updateUserComponent.profilForm.getRawValue();
+ await firstValueFrom(this.usersService.updateUserEndpoint(id, users))
+
+ this.notificationService.success(
+ 'Success',
+ 'Utilisateur modifié'
+ )
+ } catch (e) {
+ this.notificationService.error(
+ 'Erreur',
+ 'Erreur lors de la modification'
+ )
+ }
+ }
+
+ selectedUser: GetUserDto | null = null;
+ openEditModal(user: GetUserDto) {
+ this.selectedUser = { ...user };
+ this.modal().showModal();
+ }
+
+ async onModalOk(userId: number, updateUserComponent: ProfilForm, modal: ModalNav) {
+ if (!this.selectedUser) return;
+
+ await this.edit(userId, updateUserComponent);
+ updateUserComponent.profilForm.reset();
+ modal.isVisible = false;
+ await this.fetchUsers();
+ }
+ onModalCancel(modal: ModalNav) {
+ modal.isVisible = false;
+ }
}
diff --git a/src/app/pages/user/user.html b/src/app/pages/user/user.html
index b10e9ec..c87acd1 100644
--- a/src/app/pages/user/user.html
+++ b/src/app/pages/user/user.html
@@ -5,7 +5,7 @@
(ok)="onModalOk()"
(cancel)="onModalCancel()">
-
+
diff --git a/src/app/pages/user/user.ts b/src/app/pages/user/user.ts
index b5a0722..9e09149 100644
--- a/src/app/pages/user/user.ts
+++ b/src/app/pages/user/user.ts
@@ -48,8 +48,6 @@ export class User {
const users = this.createUser().profilForm.getRawValue();
await firstValueFrom(this.usersService.createUserEndpoint(users))
- console.log(users)
-
this.notificationService.success(
'Success',
'Utilisateur crée'