Changes to some models and data coming from API

This commit is contained in:
Erik Tiekstra
2021-09-01 10:26:05 +02:00
parent 02cf0f6114
commit e4f5802f97
9 changed files with 55 additions and 62 deletions

View File

@@ -50,12 +50,16 @@ export class AvropApiService {
this._lockedAvropSnapshot$.next(avrop);
return this.httpClient.get<{ data: HandledareResponse[] }>(`${this._apiBaseUrl}/handledare`).pipe(
map(({ data }) => data.map(handledare => mapHandledareResponseToHandledare(handledare))),
tap(handledare => {
this._availableHandledareSnapshot$.next(handledare);
return this.httpClient
.get<{ data: HandledareResponse[] }>(`${this._apiBaseUrl}/handledare`, {
params: { avropIds: avrop.map(a => a.id) },
})
);
.pipe(
map(({ data }) => data.map(handledare => mapHandledareResponseToHandledare(handledare))),
tap(handledare => {
this._availableHandledareSnapshot$.next(handledare);
})
);
}
fetchAvailableTjanster$(params: Params): Observable<AvropTjanst[]> {

View File

@@ -190,15 +190,17 @@ export class EmployeeService extends UnsubscribeDirective {
}
public updateEmployeeData(employeeData: Employee): Observable<string> {
return /* this.httpClient.put<{ id: string }>(`${this._apiBaseUrl}/${employeeData.id}`,
return; /* this.httpClient.put<{ id: string }>(`${this._apiBaseUrl}/${employeeData.id}`,
mapEmployeeToRequestData(employeeData), API_HEADERS).pipe(
map(({ id }) => id),
catchError(error => throwError({ message: error as string, type: ErrorType.API }))
); */
}
public getAllRoles(): Role[] {
const allAuths: string[] = Object.keys(RoleEnum).filter((item) => {return isNaN(Number(item))});
return allAuths.map(key => mapRoleResponseToRoleObject(key));
public get allRoles(): Role[] {
const allAuths: string[] = Object.keys(RoleEnum).filter(item => {
return isNaN(Number(item));
});
return allAuths.map(key => mapRoleResponseToRoleObject(key));
}
}