All files / src/app/extensions/product-notifications/shared/product-notification-delete product-notification-delete.component.ts

61.53% Statements 8/13
75% Branches 6/8
50% Functions 2/4
58.33% Lines 7/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 41 42 43 44 45 46 47 48 49 501x     1x     1x 1x                                 1x           2x     2x                                
import { ChangeDetectionStrategy, Component, Input, OnInit } from '@angular/core';
import { Observable } from 'rxjs';
 
import { ProductContextFacade } from 'ish-core/facades/product-context.facade';
import { ModalDialogComponent } from 'ish-shared/components/common/modal-dialog/modal-dialog.component';
 
import { ProductNotificationsFacade } from '../../facades/product-notifications.facade';
import { ProductNotification } from '../../models/product-notification/product-notification.model';
 
/**
 * The Product Notification Delete Component shows the customer a link to open the dialog
 * to delete the product notification.
 *
 * @example
 * <ish-product-notification-delete
 *   cssClass="btn-link btn-tool"
 *   [productNotification]="productNotification"
 * ></ish-product-notification-delete>
 */
@Component({
  selector: 'ish-product-notification-delete',
  templateUrl: './product-notification-delete.component.html',
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ProductNotificationDeleteComponent implements OnInit {
  @Input({ required: true }) productNotification: ProductNotification;
  @Input() cssClass: string;
 
  productName$: Observable<string>;
 
  constructor(private productNotificationsFacade: ProductNotificationsFacade, private context: ProductContextFacade) {}
 
  ngOnInit() {
    this.productName$ = this.context.select('product', 'name');
  }
 
  openConfirmationDialog(modal: ModalDialogComponent<string>) {
    modal.show();
  }
 
  // delete the notification
  deleteProductNotification() {
    const sku = this.context.get('sku');
    const productNotificationType = this.productNotification.type;
    const productNotificationId = this.productNotification.id;
 
    this.productNotificationsFacade.deleteProductNotification(sku, productNotificationType, productNotificationId);
  }
}