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;
|
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();
|
this.dialogRef.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,17 @@
|
|||||||
import {Component, inject, OnInit} from '@angular/core';
|
import {Component, inject, OnInit} from '@angular/core';
|
||||||
import {Observable} from "rxjs";
|
import {Observable} from "rxjs";
|
||||||
import {Qualification} from "../Qualification";
|
import {Qualification} from "../Qualification";
|
||||||
import {AsyncPipe, NgFor} from "@angular/common";
|
import {AsyncPipe} from "@angular/common";
|
||||||
import {
|
import {
|
||||||
MatCell, MatCellDef,
|
MatCell,
|
||||||
|
MatCellDef,
|
||||||
MatColumnDef,
|
MatColumnDef,
|
||||||
MatHeaderCell,
|
MatHeaderCell,
|
||||||
MatHeaderCellDef,
|
MatHeaderCellDef,
|
||||||
MatHeaderRow, MatHeaderRowDef,
|
MatHeaderRow,
|
||||||
MatRow, MatRowDef,
|
MatHeaderRowDef,
|
||||||
|
MatRow,
|
||||||
|
MatRowDef,
|
||||||
MatTable
|
MatTable
|
||||||
} from "@angular/material/table";
|
} from "@angular/material/table";
|
||||||
import QualificationService from "../../services/qualification.service";
|
import QualificationService from "../../services/qualification.service";
|
||||||
@ -24,7 +27,6 @@ import {MatProgressSpinner} from "@angular/material/progress-spinner";
|
|||||||
selector: 'app-qualifications',
|
selector: 'app-qualifications',
|
||||||
imports: [
|
imports: [
|
||||||
AsyncPipe,
|
AsyncPipe,
|
||||||
NgFor,
|
|
||||||
MatTable,
|
MatTable,
|
||||||
MatHeaderCell,
|
MatHeaderCell,
|
||||||
MatColumnDef,
|
MatColumnDef,
|
||||||
@ -43,6 +45,7 @@ import {MatProgressSpinner} from "@angular/material/progress-spinner";
|
|||||||
MatProgressSpinner
|
MatProgressSpinner
|
||||||
],
|
],
|
||||||
templateUrl: './table.component.html',
|
templateUrl: './table.component.html',
|
||||||
|
standalone: true,
|
||||||
styleUrl: './table.component.css'
|
styleUrl: './table.component.css'
|
||||||
})
|
})
|
||||||
export class QualificationsComponent implements OnInit{
|
export class QualificationsComponent implements OnInit{
|
||||||
|
@ -23,4 +23,8 @@ export default class EmployeeApiService {
|
|||||||
public create(employee: Employee) {
|
public create(employee: Employee) {
|
||||||
return this.http.post<Employee>(`${EmployeeApiService.BASE_URL}/employees`, 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