@infrab4a/connect-angular 4.0.0-beta.25 → 4.0.0-beta.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -338,11 +338,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
338
338
  }] }]; } });
339
339
 
340
340
  class CartService {
341
- constructor(authService, checkoutService, defaultShop, productRepository, variantRepository, buy2WinRepository) {
341
+ constructor(authService, checkoutService, defaultShop, productRepository, categoryRepository, variantRepository, buy2WinRepository) {
342
342
  this.authService = authService;
343
343
  this.checkoutService = checkoutService;
344
344
  this.defaultShop = defaultShop;
345
345
  this.productRepository = productRepository;
346
+ this.categoryRepository = categoryRepository;
346
347
  this.variantRepository = variantRepository;
347
348
  this.buy2WinRepository = buy2WinRepository;
348
349
  this.cartSubject = new Subject();
@@ -515,11 +516,17 @@ class CartService {
515
516
  if (!(campaign.startDate <= today) && !(campaign.endDate >= today))
516
517
  continue;
517
518
  if (campaign.activeCategory) {
518
- const categoriesCampaing = campaign.categories.map((c) => c.id);
519
+ const categoriesCampaing = campaign.categories.map((c) => c.id.toString());
520
+ const categoriesCampaingFullTree = [];
521
+ for (const id of categoriesCampaing) {
522
+ const children = await this.categoryRepository.getChildren(parseInt(id));
523
+ categoriesCampaingFullTree.push(id, ...children.map((c) => c.id.toString()));
524
+ }
525
+ const categoriesCampaingTree = [...new Set(categoriesCampaingFullTree)];
519
526
  const filterProductsCategories = checkout.lineItems.filter((l) => {
520
527
  if (!l.categories || !l.categories?.length)
521
528
  return true;
522
- return l.categories.some((c) => categoriesCampaing.some((cat) => cat == c));
529
+ return l.categories.some((c) => categoriesCampaingTree.some((cat) => cat == c));
523
530
  });
524
531
  if (filterProductsCategories.length) {
525
532
  const cartTotalCategories = filterProductsCategories.reduce((a, b) => a + b.pricePaid * b.quantity, 0);
@@ -579,7 +586,7 @@ class CartService {
579
586
  });
580
587
  }
581
588
  }
582
- CartService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService, deps: [{ token: AuthService }, { token: CheckoutService }, { token: DEFAULT_SHOP }, { token: 'ProductRepository' }, { token: 'VariantRepository' }, { token: 'Buy2WinRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
589
+ CartService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService, deps: [{ token: AuthService }, { token: CheckoutService }, { token: DEFAULT_SHOP }, { token: 'ProductRepository' }, { token: 'CategoryRepository' }, { token: 'VariantRepository' }, { token: 'Buy2WinRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
583
590
  CartService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService });
584
591
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService, decorators: [{
585
592
  type: Injectable
@@ -589,6 +596,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
589
596
  }] }, { type: undefined, decorators: [{
590
597
  type: Inject,
591
598
  args: ['ProductRepository']
599
+ }] }, { type: undefined, decorators: [{
600
+ type: Inject,
601
+ args: ['CategoryRepository']
592
602
  }] }, { type: undefined, decorators: [{
593
603
  type: Inject,
594
604
  args: ['VariantRepository']