|
|
|
@ -14,11 +14,8 @@ import {ToastrService} from "ngx-toastr"; |
|
|
|
|
}) |
|
|
|
|
export class AgenceAddComponent implements OnInit { |
|
|
|
|
|
|
|
|
|
agences: Agence[] = []; |
|
|
|
|
agence = {} as Agence; |
|
|
|
|
businessUnits: Businessunit[] = []; |
|
|
|
|
businessUnit = {} as Businessunit; |
|
|
|
|
|
|
|
|
|
registerForm!: FormGroup; |
|
|
|
|
submitted = false; |
|
|
|
|
|
|
|
|
@ -36,7 +33,6 @@ export class AgenceAddComponent implements OnInit { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ngOnInit(): void { |
|
|
|
|
this.getAgences(); |
|
|
|
|
this.getBusinessUnits(); |
|
|
|
|
this.registerForm = this.formBuilder.group({ |
|
|
|
|
name: ['', Validators.required], |
|
|
|
@ -44,27 +40,11 @@ export class AgenceAddComponent implements OnInit { |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
getAgences(): void { |
|
|
|
|
this.agenceService.getAgences() |
|
|
|
|
.subscribe(agences => this.agences = agences); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
getBusinessUnits() { |
|
|
|
|
this.businessUnitService.getBusinessunits() |
|
|
|
|
.subscribe(businessunits => this.businessUnits = businessunits); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
add(agence: Agence): void { |
|
|
|
|
this.agenceService.addAgence(agence) |
|
|
|
|
.subscribe(agence => { |
|
|
|
|
this.agences.push(agence); |
|
|
|
|
this.showSuccess(); |
|
|
|
|
}, |
|
|
|
|
() => { |
|
|
|
|
this.showError() |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
onSubmit() { |
|
|
|
|
this.submitted = true; |
|
|
|
|
|
|
|
|
@ -73,7 +53,13 @@ export class AgenceAddComponent implements OnInit { |
|
|
|
|
} |
|
|
|
|
this.agence.name = this.registerForm.value.name |
|
|
|
|
this.agence.businessUnitId = this.registerForm.value.businessUnitId |
|
|
|
|
this.add(this.agence) |
|
|
|
|
this.agenceService.addAgence(this.agence) |
|
|
|
|
.subscribe(() => { |
|
|
|
|
this.showSuccess(); |
|
|
|
|
}, |
|
|
|
|
() => { |
|
|
|
|
this.showError() |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
onReset() { |
|
|
|
|