feat(mitarbeiterverwaltung): add edit employee functionality

This commit is contained in:
Jan K9f 2025-01-15 13:32:37 +01:00
parent d80f98f2a0
commit 4c0371efb3
Signed by: jank
GPG key ID: 50620ADD22CD330B
2 changed files with 7 additions and 2 deletions

View file

@ -46,7 +46,7 @@
<td>{{ employee.city }}</td>
<td>{{ employee.phone }}</td>
<td>
<button>Edit</button>
<button (click)="editEmployee(employee.id)">Edit</button>
<button>Delete</button>
</td>
</tr>

View file

@ -4,6 +4,7 @@ import { Observable, of } from 'rxjs';
import { EmployeeResponseDTO } from '../../models/mitarbeiter';
import { EmployeeService } from '../../service/employee.service';
import { FormControl, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms';
import { Router } from '@angular/router';
@Component({
selector: 'app-mitarbeiterverwaltung-view',
@ -16,7 +17,7 @@ export class MitarbeiterverwaltungViewComponent implements OnInit {
employees: Array<EmployeeResponseDTO> = [];
searchForm!: FormGroup;
constructor(private employeeService: EmployeeService) {}
constructor(private employeeService: EmployeeService, private router: Router) {}
submit() {
const searchTerm = this.searchForm.get("search")?.value || '';
@ -41,6 +42,10 @@ export class MitarbeiterverwaltungViewComponent implements OnInit {
});
}
editEmployee(id: number) {
this.router.navigate([`/mitarbeiterbearbeiten/${id}`]);
}
ngOnInit(): void {
this.searchForm = new FormGroup({
search: new FormControl(''),