dev
Last change
on this file since dab7a9b was dab7a9b, checked in by Стојков Марко <mst@…>, 3 years ago |
Preview question component
|
-
Property mode
set to
100644
|
File size:
936 bytes
|
Line | |
---|
1 | import { Injectable } from '@angular/core';
|
---|
2 | import { ToastrService } from 'ngx-toastr';
|
---|
3 |
|
---|
4 | import { ErrorResponse } from 'src/app/shared-app/models';
|
---|
5 | import { TranslateFromJsonService } from 'src/app/shared-app/services';
|
---|
6 |
|
---|
7 | @Injectable({
|
---|
8 | providedIn: 'root'
|
---|
9 | })
|
---|
10 | export class NotificationService {
|
---|
11 | constructor(private toastr: ToastrService, private translate: TranslateFromJsonService) {}
|
---|
12 |
|
---|
13 | public handleErrorsNotification(error: ErrorResponse): void {
|
---|
14 | if (error) {
|
---|
15 | Object.keys(error).forEach((errorField) => {
|
---|
16 | error[errorField].forEach((message) => {
|
---|
17 | this.toastr.error(this.translate.instant(message), errorField);
|
---|
18 | });
|
---|
19 | });
|
---|
20 | }
|
---|
21 | }
|
---|
22 |
|
---|
23 | public successNotification(title: string, description?: string): void {
|
---|
24 | if (description) {
|
---|
25 | this.toastr.success(this.translate.instant(description), this.translate.instant(title));
|
---|
26 | }
|
---|
27 | this.toastr.success(this.translate.instant(title));
|
---|
28 | }
|
---|
29 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.