All files / src/app/extensions/wishlists/pages/account-wishlist account-wishlist-page.component.ts

77.77% Statements 7/9
75% Branches 3/4
50% Functions 2/4
77.77% Lines 7/9

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 41 42 43 44 45 461x         1x               1x                           1x     1x 1x 1x                          
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
import { Observable } from 'rxjs';
 
import { HttpError } from 'ish-core/models/http-error/http-error.model';
 
import { WishlistsFacade } from '../../facades/wishlists.facade';
import { Wishlist, WishlistHeader } from '../../models/wishlist/wishlist.model';
 
@Component({
  selector: 'ish-account-wishlist-page',
  templateUrl: './account-wishlist-page.component.html',
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class AccountWishlistPageComponent implements OnInit {
  /**
   * The list of wishlists of the customer.
   */
  wishlists$: Observable<Wishlist[]>;
  /**
   * Indicator for loading state of wishlists
   */
  wishlistLoading$: Observable<boolean>;
  /**
   * Error state in case of an error during creation of a new wishlist.
   */
  wishlistError$: Observable<HttpError>;
 
  constructor(private wishlistsFacade: WishlistsFacade) {}
 
  ngOnInit() {
    this.wishlists$ = this.wishlistsFacade.wishlists$;
    this.wishlistLoading$ = this.wishlistsFacade.wishlistLoading$;
    this.wishlistError$ = this.wishlistsFacade.wishlistError$;
  }
 
  /** dispatch delete request */
  deleteWishlist(id: string) {
    this.wishlistsFacade.deleteWishlist(id);
  }
 
  /** dispatch creation request */
  addWishlist(wishlist: WishlistHeader) {
    this.wishlistsFacade.addWishlist(wishlist);
  }
}