Implement deleting qualifications (#24)
Co-authored-by: Phan Huy Tran <p.tran@neusta.de> Reviewed-on: #24 Reviewed-by: Constantin Simonis <constantin@simonis.lol>
This commit is contained in:
51
src/app/qualification/delete/delete.component.ts
Normal file
51
src/app/qualification/delete/delete.component.ts
Normal file
@ -0,0 +1,51 @@
|
||||
import {Component, inject} from '@angular/core';
|
||||
import {
|
||||
MAT_DIALOG_DATA,
|
||||
MatDialogActions,
|
||||
MatDialogContent,
|
||||
MatDialogRef,
|
||||
MatDialogTitle
|
||||
} from "@angular/material/dialog";
|
||||
import {FormsModule, ReactiveFormsModule} from "@angular/forms";
|
||||
import QualificationService from "../../services/qualification.service";
|
||||
import {MatError} from "@angular/material/form-field";
|
||||
import {MatButton} from "@angular/material/button";
|
||||
|
||||
@Component({
|
||||
selector: 'app-delete-qualification',
|
||||
imports: [
|
||||
FormsModule,
|
||||
MatDialogContent,
|
||||
MatDialogTitle,
|
||||
ReactiveFormsModule,
|
||||
MatError,
|
||||
MatDialogActions,
|
||||
MatButton
|
||||
],
|
||||
templateUrl: './delete.component.html',
|
||||
styleUrl: './delete.component.css'
|
||||
})
|
||||
export class DeleteComponent {
|
||||
public id: number = inject(MAT_DIALOG_DATA);
|
||||
public apiError: string | null = null;
|
||||
|
||||
private qualificationService: QualificationService = inject(QualificationService);
|
||||
private dialogRef: MatDialogRef<DeleteComponent> = inject(MatDialogRef);
|
||||
|
||||
delete() {
|
||||
this.qualificationService.delete(this.id).subscribe({
|
||||
next: () => {
|
||||
this.dialogRef.close(true);
|
||||
},
|
||||
error: (error) => {
|
||||
console.error('Error deleting qualification:', error);
|
||||
|
||||
this.apiError = 'API Error';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
closeModal() {
|
||||
this.dialogRef.close(false);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user