Extract snackbar error message implementation to service (#42)
Co-authored-by: Phan Huy Tran <p.tran@neusta.de> Reviewed-on: http://git.simonis.lol/angular/ems-frontend/pulls/42 Reviewed-by: Constantin Simonis <constantin@simonis.lol>
This commit is contained in:
18
src/app/services/error.handler.service.ts
Normal file
18
src/app/services/error.handler.service.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import {inject, Injectable} from '@angular/core';
|
||||
import {MatSnackBar} from "@angular/material/snack-bar";
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class ErrorHandlerService {
|
||||
private readonly snackBar: MatSnackBar = inject(MatSnackBar);
|
||||
|
||||
public showErrorMessage(message: string): void {
|
||||
this.snackBar.open(message, 'Close', {
|
||||
duration: 5000,
|
||||
horizontalPosition: 'end',
|
||||
verticalPosition: 'bottom',
|
||||
panelClass: ['!bg-red-50', '!text-red-900', '!border', '!border-red-100']
|
||||
});
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user