From 3ec2b87e52e4ba112522379d6e706431781828b9 Mon Sep 17 00:00:00 2001
From: Phan Huy Tran
Date: Wed, 15 Jan 2025 09:28:45 +0100
Subject: [PATCH] Fix employeedetails opened from qualification details not
showing any skills
---
.../details/details.component.html | 22 ++++++++++---------
.../details/details.component.ts | 21 +++++++++++++++---
src/app/services/employee-api.service.ts | 4 ++++
3 files changed, 34 insertions(+), 13 deletions(-)
diff --git a/src/app/qualification/details/details.component.html b/src/app/qualification/details/details.component.html
index 33cbe2b..3197fa6 100644
--- a/src/app/qualification/details/details.component.html
+++ b/src/app/qualification/details/details.component.html
@@ -1,20 +1,22 @@
- Employees with {{ qualification.skill }}
+ {{ qualification.skill }} Developers
-
+
@if (employees$ | async; as employees) {
@if (employees.length === 0) {
No employees found with this qualification.
} @else {
- @for (employee of employees; track employee.id) {
-
- {{ employee.firstName }} {{ employee.lastName }}
-
- }
+
}
}
diff --git a/src/app/qualification/details/details.component.ts b/src/app/qualification/details/details.component.ts
index 593eeb1..1857aaf 100644
--- a/src/app/qualification/details/details.component.ts
+++ b/src/app/qualification/details/details.component.ts
@@ -12,6 +12,14 @@ import {AsyncPipe} from "@angular/common";
import {MatButton} from "@angular/material/button";
import {Employee} from "../../employee/Employee";
import {DetailsComponent as EmployeeDetailsComponent} from "../../employee/details/details.component";
+import EmployeeApiService from "../../services/employee-api.service";
+
+interface QualificationEmployee {
+ id: number;
+ lastName: string;
+ firstName: string;
+}
+
@Component({
selector: 'app-details',
@@ -27,6 +35,7 @@ import {DetailsComponent as EmployeeDetailsComponent} from "../../employee/detai
})
export class DetailsComponent {
private qualificationService = inject(QualificationService);
+ private employeeService = inject(EmployeeApiService);
private dialogRef: MatDialogRef = inject(MatDialogRef);
private dialog: MatDialog = inject(MatDialog);
@@ -37,9 +46,15 @@ export class DetailsComponent {
this.dialogRef.close();
}
- openEmployeeDetailsModal(employee: Employee) {
- this.dialog.open(EmployeeDetailsComponent, {
- data: employee
+ openEmployeeDetailsModal(id: number | undefined) {
+ if (!id) {
+ throw new Error("ID must not be undefined");
+ }
+
+ this.employeeService.getById(id).subscribe(employee => {
+ this.dialog.open(EmployeeDetailsComponent, {
+ data: employee
+ });
});
}
}
diff --git a/src/app/services/employee-api.service.ts b/src/app/services/employee-api.service.ts
index 16aded1..b8e6d8b 100644
--- a/src/app/services/employee-api.service.ts
+++ b/src/app/services/employee-api.service.ts
@@ -12,6 +12,10 @@ export default class EmployeeApiService {
private static readonly BASE_URL = 'http://localhost:8089';
+ public getById(id: number): Observable {
+ return this.http.get(`${EmployeeApiService.BASE_URL}/employees/${id}`)
+ }
+
public deleteById(id: number): Observable {
return this.http.delete(`${EmployeeApiService.BASE_URL}/employees/${id}`)
}