Refactor code
This commit is contained in:
@@ -26,7 +26,7 @@ export class User {
|
||||
async onModalOk() {
|
||||
await this.addUser()
|
||||
this.createUser().profilForm.reset();
|
||||
this.modal().isVisible = false;
|
||||
this.onModalCancel();
|
||||
await this.usersTable().fetchUsers()
|
||||
}
|
||||
|
||||
@@ -36,24 +36,15 @@ export class User {
|
||||
|
||||
async addUser() {
|
||||
if (this.createUser().profilForm.invalid) {
|
||||
this.notificationService.error(
|
||||
'Erreur',
|
||||
'Erreur d\'écriture dans le formulaire'
|
||||
)
|
||||
this.notificationService.error('Erreur', 'Formulaire invalide')
|
||||
}
|
||||
try {
|
||||
const users = this.createUser().profilForm.getRawValue();
|
||||
await firstValueFrom(this.usersService.createUserEndpoint(users))
|
||||
|
||||
this.notificationService.success(
|
||||
'Success',
|
||||
'Utilisateur crée'
|
||||
)
|
||||
} catch (e) {
|
||||
this.notificationService.error(
|
||||
'Erreur',
|
||||
'Erreur d\'enregistrement'
|
||||
)
|
||||
this.notificationService.success('Success', 'Utilisateur crée')
|
||||
} catch {
|
||||
this.notificationService.error('Erreur', 'Erreur d\'enregistrement')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user