actually make it function this time and refactor
This commit is contained in:
parent
710ce96764
commit
9acdc6bfc0
@ -57,7 +57,12 @@ export class EditComponent implements OnInit {
|
||||
return;
|
||||
}
|
||||
|
||||
this.employeeService.create(this.employeeForm.value as Employee).subscribe();
|
||||
if (this.employee.id === undefined) {
|
||||
console.error('Employee ID is undefined');
|
||||
return;
|
||||
}
|
||||
|
||||
this.employeeService.update(this.employeeForm.value as Employee, this.employee.id).subscribe();
|
||||
this.dialogRef.close();
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,17 @@
|
||||
import {Component, inject, OnInit} from '@angular/core';
|
||||
import {Observable} from "rxjs";
|
||||
import {Qualification} from "../Qualification";
|
||||
import {AsyncPipe, NgFor} from "@angular/common";
|
||||
import {AsyncPipe} from "@angular/common";
|
||||
import {
|
||||
MatCell, MatCellDef,
|
||||
MatCell,
|
||||
MatCellDef,
|
||||
MatColumnDef,
|
||||
MatHeaderCell,
|
||||
MatHeaderCellDef,
|
||||
MatHeaderRow, MatHeaderRowDef,
|
||||
MatRow, MatRowDef,
|
||||
MatHeaderRow,
|
||||
MatHeaderRowDef,
|
||||
MatRow,
|
||||
MatRowDef,
|
||||
MatTable
|
||||
} from "@angular/material/table";
|
||||
import QualificationService from "../../services/qualification.service";
|
||||
@ -24,7 +27,6 @@ import {MatProgressSpinner} from "@angular/material/progress-spinner";
|
||||
selector: 'app-qualifications',
|
||||
imports: [
|
||||
AsyncPipe,
|
||||
NgFor,
|
||||
MatTable,
|
||||
MatHeaderCell,
|
||||
MatColumnDef,
|
||||
@ -43,6 +45,7 @@ import {MatProgressSpinner} from "@angular/material/progress-spinner";
|
||||
MatProgressSpinner
|
||||
],
|
||||
templateUrl: './table.component.html',
|
||||
standalone: true,
|
||||
styleUrl: './table.component.css'
|
||||
})
|
||||
export class QualificationsComponent implements OnInit{
|
||||
|
@ -23,4 +23,8 @@ export default class EmployeeApiService {
|
||||
public create(employee: Employee) {
|
||||
return this.http.post<Employee>(`${EmployeeApiService.BASE_URL}/employees`, employee)
|
||||
}
|
||||
|
||||
public update(employee: Employee, id: number) {
|
||||
return this.http.patch(`${EmployeeApiService.BASE_URL}/employees/${id}`, employee)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user