All files / src/app/pages/category/category-navigation category-navigation.component.ts

100% Statements 8/8
75% Branches 3/4
100% Functions 4/4
100% Lines 7/7

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 293x   3x   3x               3x           8x     8x       8x      
import { ChangeDetectionStrategy, Component, Input, OnChanges, OnInit } from '@angular/core';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
 
import { ShoppingFacade } from 'ish-core/facades/shopping.facade';
import { NavigationCategory } from 'ish-core/models/navigation-category/navigation-category.model';
 
@Component({
  selector: 'ish-category-navigation',
  templateUrl: './category-navigation.component.html',
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class CategoryNavigationComponent implements OnInit, OnChanges {
  @Input({ required: true }) uniqueId: string;
 
  navigationCategories$: Observable<NavigationCategory[]>;
  currentCategoryId$: Observable<string>;
 
  constructor(private shoppingFacade: ShoppingFacade) {}
 
  ngOnInit() {
    this.currentCategoryId$ = this.shoppingFacade.selectedCategory$.pipe(map(c => c?.uniqueId));
  }
 
  ngOnChanges() {
    this.navigationCategories$ = this.shoppingFacade.navigationCategories$(this.uniqueId);
  }
}