All files / src/app/pages/checkout-review checkout-review-page.component.ts

90.9% Statements 10/11
75% Branches 6/8
66.66% Functions 2/3
90% Lines 9/10

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 361x     1x 1x                 1x           1x     1x 1x 1x 1x                    
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
import { Observable } from 'rxjs';
 
import { AccountFacade } from 'ish-core/facades/account.facade';
import { CheckoutFacade } from 'ish-core/facades/checkout.facade';
import { BasketView } from 'ish-core/models/basket/basket.model';
import { HttpError } from 'ish-core/models/http-error/http-error.model';
 
@Component({
  selector: 'ish-checkout-review-page',
  templateUrl: './checkout-review-page.component.html',
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class CheckoutReviewPageComponent implements OnInit {
  basket$: Observable<BasketView>;
  loading$: Observable<boolean>;
  orderLoading$: Observable<boolean>;
  error$: Observable<HttpError>;
 
  constructor(private checkoutFacade: CheckoutFacade, private accountFacade: AccountFacade) {}
 
  ngOnInit() {
    this.basket$ = this.checkoutFacade.basket$;
    this.loading$ = this.checkoutFacade.basketLoading$;
    this.orderLoading$ = this.accountFacade.ordersLoading$;
    this.error$ = this.checkoutFacade.basketOrOrdersError$;
  }
 
  /**
   * validates the basket, creates an order and routes to receipt page in case of success
   */
  onCreateOrder() {
    this.checkoutFacade.submitOrder();
  }
}