|
|
|
@ -8,6 +8,7 @@ import {FormBuilder, FormGroup, Validators} from "@angular/forms"; |
|
|
|
|
import {Businessunit} from "../../../interfaces/businessunit"; |
|
|
|
|
import {Observable} from "rxjs"; |
|
|
|
|
import {take, tap} from "rxjs/operators"; |
|
|
|
|
import {ToastrService} from "ngx-toastr"; |
|
|
|
|
|
|
|
|
|
@Component({ |
|
|
|
|
selector: 'app-collaborateur-edit', |
|
|
|
@ -36,7 +37,8 @@ export class CollaborateurEditComponent implements OnInit { |
|
|
|
|
private collaborateurService: CollaborateurService, |
|
|
|
|
private businessunitService: BusinessunitService, |
|
|
|
|
private location: Location, |
|
|
|
|
private formBuilder: FormBuilder |
|
|
|
|
private formBuilder: FormBuilder, |
|
|
|
|
private toastr: ToastrService |
|
|
|
|
) { |
|
|
|
|
this.id = Number(this.route.snapshot.paramMap.get('id')) |
|
|
|
|
} |
|
|
|
@ -112,13 +114,12 @@ export class CollaborateurEditComponent implements OnInit { |
|
|
|
|
this.collaborateur.status = this.registerForm.value.status |
|
|
|
|
|
|
|
|
|
if (this.collaborateur) { |
|
|
|
|
this.collaborateurService.updateCollaborateur(this.collaborateur).subscribe({ |
|
|
|
|
next: () => { |
|
|
|
|
this.collaborateurService.updateCollaborateur(this.collaborateur).subscribe(() => { |
|
|
|
|
this.showSuccess(); |
|
|
|
|
this.goBack(); |
|
|
|
|
}, |
|
|
|
|
error: () => { |
|
|
|
|
this.errorValue = 1; |
|
|
|
|
} |
|
|
|
|
() => { |
|
|
|
|
this.showError() |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
} |
|
|
|
@ -139,4 +140,12 @@ export class CollaborateurEditComponent implements OnInit { |
|
|
|
|
onBirthDateChange($event: any):void { |
|
|
|
|
this.collaborateur.birthDate = new Date($event.target.value); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
showSuccess() { |
|
|
|
|
this.toastr.success('Modification réussie', 'Collaborateur'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
showError() { |
|
|
|
|
this.toastr.error('Modification échouée', 'Collaborateur'); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|