Extract snackbar error message implementation to service #43

Closed
ptran wants to merge 37 commits from refactor/error-message into main
2 changed files with 8 additions and 4 deletions
Showing only changes of commit b0009229d1 - Show all commits

View File

@ -4,7 +4,7 @@ import {
MAT_DIALOG_DATA,
MatDialogActions,
MatDialogClose,
MatDialogContent,
MatDialogContent, MatDialogRef,
MatDialogTitle
} from "@angular/material/dialog";
import {MatButton} from "@angular/material/button";
@ -25,12 +25,12 @@ import EmployeeApiService from "../../services/employee-api.service";
})
export class DeleteComponent {
private apiService: EmployeeApiService = inject(EmployeeApiService);
private dialogRef: MatDialogRef<DeleteComponent> = inject(MatDialogRef);
protected employee: Employee = inject(MAT_DIALOG_DATA);
deleteEmployee(id: number) {
this.apiService.deleteById(id).subscribe();
location.reload();
this.dialogRef.close()
}
}

View File

@ -73,7 +73,11 @@ export class TableComponent implements OnInit{
}
protected openDeleteDialogue(employee: Employee): void {
this.deleteDialogue.open(DeleteComponent, {data: employee});
this.deleteDialogue.open(DeleteComponent, {data: employee})
.afterClosed()
.subscribe(() => {
this.employees$ = this.fetchEmployees();
});
}
protected showCreateEmployeeModal() {