Added fetch for single employee and prepared data for access-groups

This commit is contained in:
Erik Tiekstra
2021-05-06 15:33:21 +02:00
parent 923cc737ae
commit 6f8bf890ba
7 changed files with 68 additions and 30 deletions

View File

@@ -12,14 +12,16 @@ function filterEmployees(employees: Employee[], searchFilter: string): Employee[
return employees.filter(person => person.fullName.toLowerCase().includes(searchFilter.toLowerCase()));
}
const API_HEADERS = { headers: environment.api.headers };
@Injectable({
providedIn: 'root',
})
export class EmployeeService {
private _employeesApiUrl = `${environment.api.meet}/employees`;
private _employeeApiUrl = `${environment.api.meet}/employee`;
private _employeesRawData: Observable<EmployeesApiResponse> = this.httpClient.get<EmployeesApiResponse>(
this._employeesApiUrl,
{ headers: environment.api.headers }
API_HEADERS
);
private _allEmployees$: Observable<Employee[]> = this._employeesRawData.pipe(
map(({ pxResults }) => pxResults.map(result => mapEmployeeReponseToEmployee(result)))
@@ -47,7 +49,9 @@ export class EmployeeService {
constructor(private httpClient: HttpClient) {}
public getDetailedEmployeeData(id: string): Observable<Employee> {
return this.httpClient.get<Employee>(`${this._employeesApiUrl}/${id}`, { params: { _embed: 'participants' } });
return this.httpClient
.get<EmployeesApiResponse>(`${this._employeeApiUrl}/${id}`, API_HEADERS)
.pipe(map(({ pxResults }) => mapEmployeeReponseToEmployee(pxResults[0])));
}
public setSearchFilter(value: string) {