All files / src/app/extensions/product-notifications/pages/account-product-notifications account-product-notifications-page.component.ts

100% Statements 12/12
75% Branches 3/4
100% Functions 3/3
100% Lines 12/12

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 411x 1x         1x                     1x           3x     3x     3x 3x 3x   3x   3x 3x        
import { ChangeDetectionStrategy, Component, DestroyRef, OnInit, inject } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { Observable } from 'rxjs';
 
import { HttpError } from 'ish-core/models/http-error/http-error.model';
 
import { ProductNotificationsFacade } from '../../facades/product-notifications.facade';
import {
  ProductNotification,
  ProductNotificationType,
} from '../../models/product-notification/product-notification.model';
 
@Component({
  selector: 'ish-account-product-notifications-page',
  templateUrl: './account-product-notifications-page.component.html',
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class AccountProductNotificationsPageComponent implements OnInit {
  productNotifications$: Observable<ProductNotification[]>;
  productNotificationsLoading$: Observable<boolean>;
  productNotificationsError$: Observable<HttpError>;
  active$: Observable<ProductNotificationType>;
 
  constructor(private productNotificationsFacade: ProductNotificationsFacade) {}
 
  active: ProductNotificationType;
  private destroyRef = inject(DestroyRef);
 
  ngOnInit() {
    this.productNotifications$ = this.productNotificationsFacade.productNotificationsByRoute$;
    this.productNotificationsLoading$ = this.productNotificationsFacade.productNotificationsLoading$;
    this.productNotificationsError$ = this.productNotificationsFacade.productNotificationsError$;
 
    this.active$ = this.productNotificationsFacade.productNotificationType$ as Observable<ProductNotificationType>;
 
    this.active$.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(active => {
      this.active = active;
    });
  }
}