actually make it function this time and refactor
This commit is contained in:
parent
3692116aca
commit
cbb5d6e08d
@ -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,6 +1,7 @@
|
||||
import {Component, inject, OnInit} from '@angular/core';
|
||||
import {Observable} from "rxjs";
|
||||
import {Qualification} from "../Qualification";
|
||||
import {AsyncPipe} from "@angular/common";
|
||||
import {MatDialog} from "@angular/material/dialog";
|
||||
import QualificationService from "../../services/qualification.service";
|
||||
import {CreateComponent} from "../create/create.component";
|
||||
@ -14,10 +15,18 @@ import {
|
||||
MatColumnDef,
|
||||
MatHeaderCell,
|
||||
MatHeaderCellDef,
|
||||
MatHeaderRow, MatHeaderRowDef, MatRow, MatRowDef,
|
||||
MatHeaderRow,
|
||||
MatHeaderRowDef,
|
||||
MatRow,
|
||||
MatRowDef,
|
||||
MatTable
|
||||
} from "@angular/material/table";
|
||||
import QualificationService from "../../services/qualification.service";
|
||||
import {MatDialog} from "@angular/material/dialog";
|
||||
import {CreateComponent} from "../create/create.component";
|
||||
import {MatIcon} from "@angular/material/icon";
|
||||
import {MatButton, MatIconButton} from "@angular/material/button";
|
||||
import {EditComponent} from "../edit/edit.component";
|
||||
import {MatCard, MatCardContent} from "@angular/material/card";
|
||||
import {MatTooltip} from "@angular/material/tooltip";
|
||||
import {MatProgressSpinner} from "@angular/material/progress-spinner";
|
||||
@ -45,6 +54,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