add functionality to delete employee button (#11)

Reviewed-on: #11
Reviewed-by: Hernd Beidemann <huydw@proton.me>
This commit is contained in:
2024-12-18 13:02:46 +00:00
parent 4f31bc1358
commit 0eb4fe419b
7 changed files with 93 additions and 42 deletions

View File

@ -0,0 +1,34 @@
import {Component, Inject, inject} from '@angular/core';
import {Employee} from "../Employee";
import {
MAT_DIALOG_DATA,
MatDialogActions,
MatDialogClose,
MatDialogContent,
MatDialogTitle
} from "@angular/material/dialog";
import {MatButton} from "@angular/material/button";
import EmployeeApiService from "../services/employee-api.service";
@Component({
selector: 'app-delete-employee',
imports: [
MatDialogContent,
MatDialogTitle,
MatDialogActions,
MatButton,
MatDialogClose
],
templateUrl: './delete-employee.component.html',
standalone: true,
styleUrl: './delete-employee.component.css'
})
export class DeleteEmployeeComponent {
private apiService: EmployeeApiService = inject(EmployeeApiService);
protected employee: Employee = inject(MAT_DIALOG_DATA);
deleteEmployee(id: number) {
this.apiService.deleteById(id).subscribe();
}
}