Fix employee details opened from qualification details not showing any skills #34

Merged
ptran merged 2 commits from bugfix/no-skills into main 2025-01-15 08:31:13 +00:00
3 changed files with 34 additions and 13 deletions
Showing only changes of commit a62b7e7d37 - Show all commits

View File

@ -1,20 +1,22 @@
<h2 mat-dialog-title class="text-xl font-semibold mb-4"> <h2 mat-dialog-title class="text-xl font-semibold mb-4">
Employees with {{ qualification.skill }} {{ qualification.skill }} Developers
</h2> </h2>
<mat-dialog-content> <mat-dialog-content class="px-1">
@if (employees$ | async; as employees) { @if (employees$ | async; as employees) {
@if (employees.length === 0) { @if (employees.length === 0) {
<p class="text-gray-500 italic">No employees found with this qualification.</p> <p class="text-gray-500 italic">No employees found with this qualification.</p>
} @else { } @else {
<div class="space-y-1">
@for (employee of employees; track employee.id) { @for (employee of employees; track employee.id) {
<a <a
class="flex items-center p-3 bg-gray-50 rounded-lg hover:bg-gray-100 transition-colors" class="block w-full px-4 py-2 text-blue-600 rounded-lg hover:bg-blue-50 transition-colors cursor-pointer"
(click)="openEmployeeDetailsModal(employee)" (click)="openEmployeeDetailsModal(employee.id)"
> >
<span class="font-medium">{{ employee.firstName }} {{ employee.lastName }}</span> <span class="font-medium">{{ employee.firstName }} {{ employee.lastName }}</span>
</a> </a>
} }
</div>
} }
} }
</mat-dialog-content> </mat-dialog-content>

View File

@ -12,6 +12,14 @@ import {AsyncPipe} from "@angular/common";
import {MatButton} from "@angular/material/button"; import {MatButton} from "@angular/material/button";
import {Employee} from "../../employee/Employee"; import {Employee} from "../../employee/Employee";
import {DetailsComponent as EmployeeDetailsComponent} from "../../employee/details/details.component"; 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({ @Component({
selector: 'app-details', selector: 'app-details',
@ -27,6 +35,7 @@ import {DetailsComponent as EmployeeDetailsComponent} from "../../employee/detai
}) })
export class DetailsComponent { export class DetailsComponent {
private qualificationService = inject(QualificationService); private qualificationService = inject(QualificationService);
private employeeService = inject(EmployeeApiService);
private dialogRef: MatDialogRef<DetailsComponent> = inject(MatDialogRef); private dialogRef: MatDialogRef<DetailsComponent> = inject(MatDialogRef);
private dialog: MatDialog = inject(MatDialog); private dialog: MatDialog = inject(MatDialog);
@ -37,9 +46,15 @@ export class DetailsComponent {
this.dialogRef.close(); this.dialogRef.close();
} }
openEmployeeDetailsModal(employee: 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, { this.dialog.open(EmployeeDetailsComponent, {
data: employee data: employee
}); });
});
} }
} }

View File

@ -12,6 +12,10 @@ export default class EmployeeApiService {
private static readonly BASE_URL = 'http://localhost:8089'; private static readonly BASE_URL = 'http://localhost:8089';
public getById(id: number): Observable<Employee> {
return this.http.get(`${EmployeeApiService.BASE_URL}/employees/${id}`)
}
public deleteById(id: number): Observable<Employee> { public deleteById(id: number): Observable<Employee> {
return this.http.delete(`${EmployeeApiService.BASE_URL}/employees/${id}`) return this.http.delete(`${EmployeeApiService.BASE_URL}/employees/${id}`)
} }