Refactor code
This commit is contained in:
@@ -26,7 +26,7 @@ export class Supplier {
|
||||
async onModalOk() {
|
||||
await this.addSupplier()
|
||||
this.createSupplier().supplierForm.reset();
|
||||
this.modal().isVisible = false;
|
||||
this.onModalCancel();
|
||||
await this.supplierTable().fetchSuppliers()
|
||||
}
|
||||
|
||||
@@ -36,24 +36,15 @@ export class Supplier {
|
||||
|
||||
async addSupplier() {
|
||||
if (this.createSupplier().supplierForm.invalid) {
|
||||
this.notificationService.error(
|
||||
'Erreur',
|
||||
'Erreur d\'écriture dans le formulaire'
|
||||
)
|
||||
this.notificationService.error('Erreur', 'Formulaire invalide')
|
||||
}
|
||||
try {
|
||||
const suppliers = this.createSupplier().supplierForm.getRawValue();
|
||||
await firstValueFrom(this.suppliersService.createSupplierEndpoint(suppliers))
|
||||
|
||||
this.notificationService.success(
|
||||
'Success',
|
||||
'Fournisseur enregistré'
|
||||
)
|
||||
} catch (e) {
|
||||
this.notificationService.error(
|
||||
'Erreur',
|
||||
'Erreur d\'enregistrement'
|
||||
)
|
||||
this.notificationService.success('Success', 'Fournisseur enregistré')
|
||||
} catch {
|
||||
this.notificationService.error('Erreur', 'Erreur d\'enregistrement')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user