Added error handling for edit employee

This commit is contained in:
Erik Tiekstra
2021-09-07 14:44:14 +02:00
parent bb4d88a8e0
commit 39a0090881
6 changed files with 91 additions and 64 deletions

View File

@@ -82,29 +82,6 @@ export class EmployeeService extends UnsubscribeDirective {
.subscribe(employee => {
this._employee$.next(employee as Employee);
})
// this._currentEmployeeId$
// .pipe(
// filter(currentEmployeeId => !!currentEmployeeId),
// switchMap(currentEmployeeId =>
// combineLatest([this._fetchEmployee$(currentEmployeeId), this.tjanstService.tjanster$]).pipe(
// filter(([employee, allTjanster]) => !!(employee && allTjanster?.length)),
// map(([employee, allTjanster]) => {
// const tjanster = [];
// employee.tjanstCodes?.forEach(code => {
// const currentTjanst = allTjanster.find(tjanst => tjanst.code === code);
// if (currentTjanst) {
// tjanster.push(currentTjanst);
// }
// });
// return { ...employee, tjanster };
// })
// )
// )
// )
// .subscribe(employee => {
// this._employee$.next(employee as Employee);
// })
);
}
@@ -215,7 +192,7 @@ export class EmployeeService extends UnsubscribeDirective {
map(({ data }) => data),
catchError(error => {
this.errorService.add(errorToCustomError(error));
return of(null);
return throwError(errorToCustomError(error));
})
);
}
@@ -229,8 +206,7 @@ export class EmployeeService extends UnsubscribeDirective {
}),
map(() => true),
catchError(error => {
this.errorService.add(errorToCustomError(error));
return of(false);
return throwError(errorToCustomError(error));
})
);
}