update toaster service

This commit is contained in:
Dan Percic 2024-03-07 15:22:06 +02:00
parent 3776e8ecef
commit 1610a4c3a5

View File

@ -1,12 +1,12 @@
import { HttpErrorResponse, HttpStatusCode } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { ActiveToast, ToastrService } from 'ngx-toastr';
import { IndividualConfig } from 'ngx-toastr/toastr/toastr-config';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { NavigationStart, Router } from '@angular/router';
import { TranslateService } from '@ngx-translate/core';
import { HttpErrorResponse, HttpStatusCode } from '@angular/common/http';
import { ActiveToast, ToastrService } from 'ngx-toastr';
import { IndividualConfig } from 'ngx-toastr/toastr/toastr-config';
import { filter, tap } from 'rxjs/operators';
import { ErrorMessageService } from './error-message.service';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
const enum NotificationType {
SUCCESS = 'SUCCESS',
@ -26,6 +26,7 @@ export interface ToasterOptions extends IndividualConfig {
*/
readonly params?: Record<string, string | number>;
readonly actions?: ToasterActions[];
readonly useRaw?: boolean;
}
export interface ErrorToasterOptions extends ToasterOptions {
@ -86,7 +87,7 @@ export class Toaster {
notificationType = NotificationType.INFO,
options?: Partial<ToasterOptions>,
): ActiveToast<unknown> {
const translatedMsg = this._translateService.instant(message, options?.params) as string;
const translatedMsg = options?.useRaw ? message : (this._translateService.instant(message, options?.params) as string);
switch (notificationType) {
case NotificationType.SUCCESS: