ng-miam 9.1.3 → 9.1.5

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.
Files changed (39) hide show
  1. package/bundles/ng-miam.umd.js +137 -76
  2. package/bundles/ng-miam.umd.js.map +1 -1
  3. package/bundles/ng-miam.umd.min.js +1 -1
  4. package/bundles/ng-miam.umd.min.js.map +1 -1
  5. package/esm2015/lib/_models/basket-entry.js +4 -1
  6. package/esm2015/lib/_models/item.js +7 -1
  7. package/esm2015/lib/_services/analytics.service.js +39 -10
  8. package/esm2015/lib/_services/baskets-synchronizing/baskets-synchronizer.service.js +25 -10
  9. package/esm2015/lib/_services/context-registry.service.js +18 -0
  10. package/esm2015/lib/_services/context.service.js +18 -8
  11. package/esm2015/lib/_services/price.service.js +2 -2
  12. package/esm2015/lib/_services/recipe-details.service.js +16 -23
  13. package/esm2015/lib/_types/builded/mealz-interface.js +1 -1
  14. package/esm2015/lib/_web-components/basket-preview/basket-preview-product/basket-preview-product.component.js +17 -28
  15. package/esm2015/lib/_web-components/basket-preview/replace-item/replace-item.component.js +4 -3
  16. package/esm2015/lib/_web-components/preferences/preferences.component.js +1 -2
  17. package/esm2015/lib/environments/version.js +2 -2
  18. package/fesm2015/ng-miam.js +168 -111
  19. package/fesm2015/ng-miam.js.map +1 -1
  20. package/lib/_models/basket-entry.d.ts +1 -0
  21. package/lib/_models/basket-entry.d.ts.map +1 -1
  22. package/lib/_models/item.d.ts +6 -0
  23. package/lib/_models/item.d.ts.map +1 -1
  24. package/lib/_services/analytics.service.d.ts +11 -3
  25. package/lib/_services/analytics.service.d.ts.map +1 -1
  26. package/lib/_services/baskets-synchronizing/baskets-synchronizer.service.d.ts +13 -3
  27. package/lib/_services/baskets-synchronizing/baskets-synchronizer.service.d.ts.map +1 -1
  28. package/lib/_services/context-registry.service.d.ts +8 -0
  29. package/lib/_services/context-registry.service.d.ts.map +1 -0
  30. package/lib/_services/context.service.d.ts +4 -2
  31. package/lib/_services/context.service.d.ts.map +1 -1
  32. package/lib/_services/recipe-details.service.d.ts +1 -2
  33. package/lib/_services/recipe-details.service.d.ts.map +1 -1
  34. package/lib/_types/builded/mealz-interface.d.ts +14 -1
  35. package/lib/_types/builded/mealz-interface.d.ts.map +1 -1
  36. package/lib/_web-components/basket-preview/basket-preview-product/basket-preview-product.component.d.ts +2 -4
  37. package/lib/_web-components/basket-preview/basket-preview-product/basket-preview-product.component.d.ts.map +1 -1
  38. package/lib/environments/version.d.ts +1 -1
  39. package/package.json +1 -1
@@ -1786,6 +1786,9 @@
1786
1786
  brand: '',
1787
1787
  'product-page': '',
1788
1788
  image: '',
1789
+ /**
1790
+ * @deprecated
1791
+ */
1789
1792
  'unit-price': '',
1790
1793
  currency: '',
1791
1794
  'capacity-unit': '',
@@ -1885,6 +1888,9 @@
1885
1888
  configurable: true
1886
1889
  });
1887
1890
  Object.defineProperty(Item.prototype, "price", {
1891
+ /**
1892
+ * @deprecated
1893
+ */
1888
1894
  get: function () {
1889
1895
  return (this.attributes['unit-price'] ? parseFloat(this.attributes['unit-price']) : 0.0);
1890
1896
  },
@@ -2679,6 +2685,13 @@
2679
2685
  enumerable: false,
2680
2686
  configurable: true
2681
2687
  });
2688
+ Object.defineProperty(BasketEntry.prototype, "price", {
2689
+ get: function () {
2690
+ return this.attributes.price;
2691
+ },
2692
+ enumerable: false,
2693
+ configurable: true
2694
+ });
2682
2695
  Object.defineProperty(BasketEntry.prototype, "pricePerUnit", {
2683
2696
  get: function () {
2684
2697
  return this.attributes['price-per-unit'];
@@ -3502,7 +3515,26 @@
3502
3515
  return RecipeFilters;
3503
3516
  }());
3504
3517
 
3505
- var VERSION = '9.1.3'; // TODO: replace by ##VERSION## and update it in the CI/CD
3518
+ var VERSION = '9.1.5'; // TODO: replace by ##VERSION## and update it in the CI/CD
3519
+
3520
+ var ContextRegistryService = /** @class */ (function () {
3521
+ function ContextRegistryService() {
3522
+ // VARIABLES
3523
+ this.forbidProfiling = false;
3524
+ this.disabledAnalytics = false;
3525
+ }
3526
+ return ContextRegistryService;
3527
+ }());
3528
+ ContextRegistryService.ɵfac = function ContextRegistryService_Factory(t) { return new (t || ContextRegistryService)(); };
3529
+ ContextRegistryService.ɵprov = i0__namespace.ɵɵdefineInjectable({ token: ContextRegistryService, factory: ContextRegistryService.ɵfac, providedIn: 'root' });
3530
+ (function () {
3531
+ (typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(ContextRegistryService, [{
3532
+ type: i0.Injectable,
3533
+ args: [{
3534
+ providedIn: 'root'
3535
+ }]
3536
+ }], null, null);
3537
+ })();
3506
3538
 
3507
3539
  /**
3508
3540
  * Analytics library cannot refer to "this." so we use a global variable
@@ -3525,21 +3557,33 @@
3525
3557
  }));
3526
3558
  }
3527
3559
  var AnalyticsService = /** @class */ (function () {
3528
- function AnalyticsService() {
3560
+ function AnalyticsService(contextRegistryService) {
3561
+ var _this = this;
3562
+ this.contextRegistryService = contextRegistryService;
3529
3563
  this.eventEmitter = _eventEmitter;
3530
- this.alreadyInitialized = false;
3564
+ this.subscriptions = [];
3565
+ this.alreadyInitialized$ = new rxjs.BehaviorSubject(false);
3566
+ this.queuedEvents = [];
3567
+ this.subscriptions.push(this.alreadyInitialized$.subscribe(function (isInitialised) {
3568
+ if (isInitialised) {
3569
+ _this.executeQueuedEvents();
3570
+ }
3571
+ }));
3531
3572
  }
3573
+ AnalyticsService.prototype.ngOnDestroy = function () {
3574
+ this.subscriptions.forEach(function (sub) { return sub.unsubscribe(); });
3575
+ };
3532
3576
  /**
3533
3577
  * Set the identifier of the ABTest experience if one is running
3534
3578
  * It will then be added as props to all events sent
3535
3579
  * @param key A unique identifier for the ABTest experience
3536
3580
  */
3537
3581
  AnalyticsService.prototype.setAbTestKey = function (key) {
3538
- mealzSharedAnalytics.setABTestKey(key);
3582
+ this.callMethodOrAddToQueue(function () { return mealzSharedAnalytics.setABTestKey(key); });
3539
3583
  };
3540
3584
  AnalyticsService.prototype.init = function (domain) {
3541
3585
  var _a;
3542
- if (this.alreadyInitialized) {
3586
+ if (this.alreadyInitialized$.value) {
3543
3587
  return;
3544
3588
  }
3545
3589
  if (!domain) {
@@ -3549,11 +3593,14 @@
3549
3593
  if (((_a = localStorage.getItem('_miam/affiliate')) === null || _a === void 0 ? void 0 : _a.length) > 0) {
3550
3594
  mealzSharedAnalytics.setAffiliate(localStorage.getItem('_miam/affiliate'));
3551
3595
  }
3552
- this.alreadyInitialized = true;
3596
+ this.alreadyInitialized$.next(true);
3553
3597
  };
3554
3598
  AnalyticsService.prototype.sendEvent = function (name, path, props, journey) {
3555
3599
  if (journey === void 0) { journey = EventJourney.MEALZ; }
3556
- mealzSharedAnalytics.sendEvent(name, url(path), journey, props);
3600
+ if (this.contextRegistryService.disabledAnalytics && this.contextRegistryService.forbidProfiling) {
3601
+ return;
3602
+ }
3603
+ this.callMethodOrAddToQueue(function () { return mealzSharedAnalytics.sendEvent(name, url(path), journey, props); });
3557
3604
  };
3558
3605
  /** ************************************************* SEND EVENT FOR BASKET ACTIONS ************************************************* **/
3559
3606
  AnalyticsService.prototype.sendRemoveRecipesEvents = function (actions) {
@@ -3619,9 +3666,21 @@
3619
3666
  });
3620
3667
  });
3621
3668
  };
3669
+ AnalyticsService.prototype.callMethodOrAddToQueue = function (method) {
3670
+ if (this.alreadyInitialized$.value) {
3671
+ method();
3672
+ }
3673
+ else {
3674
+ this.queuedEvents.push(method);
3675
+ }
3676
+ };
3677
+ AnalyticsService.prototype.executeQueuedEvents = function () {
3678
+ this.queuedEvents.forEach(function (event) { return event(); });
3679
+ this.queuedEvents = [];
3680
+ };
3622
3681
  return AnalyticsService;
3623
3682
  }());
3624
- AnalyticsService.ɵfac = function AnalyticsService_Factory(t) { return new (t || AnalyticsService)(); };
3683
+ AnalyticsService.ɵfac = function AnalyticsService_Factory(t) { return new (t || AnalyticsService)(i0__namespace.ɵɵinject(ContextRegistryService)); };
3625
3684
  AnalyticsService.ɵprov = i0__namespace.ɵɵdefineInjectable({ token: AnalyticsService, factory: AnalyticsService.ɵfac, providedIn: 'root' });
3626
3685
  (function () {
3627
3686
  (typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(AnalyticsService, [{
@@ -3629,7 +3688,7 @@
3629
3688
  args: [{
3630
3689
  providedIn: 'root'
3631
3690
  }]
3632
- }], null, null);
3691
+ }], function () { return [{ type: ContextRegistryService }]; }, null);
3633
3692
  })();
3634
3693
 
3635
3694
  var RecipeProviderService = /** @class */ (function (_super) {
@@ -5485,7 +5544,7 @@
5485
5544
  };
5486
5545
  PriceService.prototype.getPriceFromBasketEntry = function (basketEntry) {
5487
5546
  return {
5488
- unit: basketEntry.attributes.price,
5547
+ unit: basketEntry.price,
5489
5548
  pricePerUnit: basketEntry.pricePerUnit,
5490
5549
  unitOfMeasurement: basketEntry.unitOfMeasurement,
5491
5550
  discountAmount: basketEntry.discountAmount,
@@ -7107,12 +7166,6 @@
7107
7166
  this.noSupplier$ = new rxjs.BehaviorSubject(false);
7108
7167
  this.lockWhileConfirming = new rxjs.BehaviorSubject(false);
7109
7168
  this.lockWhileSynchronizing = new rxjs.BehaviorSubject(false);
7110
- /**
7111
- * Method to be defined through context
7112
- */
7113
- this.pushProductsToRetailerCart = function () {
7114
- throw new Error('No method was passed to \'window.mealz.basketSync.definePushProductsToCart\'');
7115
- };
7116
7169
  this.pushBasketEntriesToBasket = function () {
7117
7170
  throw new Error('No method was passed to \'window.mealz.basketSync.definePushBasketEntriesToBasket\'');
7118
7171
  };
@@ -7152,13 +7205,33 @@
7152
7205
  if (actionsForRetailer.length > 0) {
7153
7206
  mealzDebug('[Mealz] Pushing products to retailer cart', actionsForRetailer);
7154
7207
  _this.checkActionsToSkip(actionsForRetailer);
7155
- _this.pushProductsToRetailerCart(actionsForRetailer);
7208
+ _this.sendActionsToRetailerCart(actionsForRetailer);
7156
7209
  }
7157
7210
  else {
7158
7211
  _this.syncMealzBasketWithRetailerCart(_this.supplierService.lastSupplierCart);
7159
7212
  }
7160
7213
  }));
7161
7214
  };
7215
+ BasketsSynchronizerService.prototype.sendActionsToRetailerCart = function (actionsForRetailer) {
7216
+ if (this.pushProductsToRetailerCart) {
7217
+ this.pushProductsToRetailerCart(actionsForRetailer);
7218
+ }
7219
+ else if (this.addProductsToRetailerCart && this.removeProductsFromRetailerCart) {
7220
+ var productsToAdd_1 = [];
7221
+ var productsToRemove_1 = [];
7222
+ actionsForRetailer.forEach(function (action) { return action.quantity < 0 ? productsToRemove_1.push(action) : productsToAdd_1.push(action); });
7223
+ if (productsToAdd_1.length > 0) {
7224
+ this.addProductsToRetailerCart(productsToAdd_1);
7225
+ }
7226
+ if (productsToRemove_1.length > 0) {
7227
+ this.removeProductsFromRetailerCart(productsToRemove_1);
7228
+ }
7229
+ }
7230
+ else {
7231
+ throw new Error('[Mealz] is missing a callback to add to cart: ' + 'You need to call either \'window.mealz.basketSync.definePushProductsToCart\' ' +
7232
+ 'or both \'window.mealz.basketSync.defineAddProductsToCart\' and \'window.mealz.basketSync.defineRemoveProductsToCart\'');
7233
+ }
7234
+ };
7162
7235
  /**
7163
7236
  * Takes a list of BasketActions and for each action that is not a duplicate (based on the action's id)
7164
7237
  * it calls the createActionForRetailer() method and adds the observable returned by this method
@@ -7205,7 +7278,8 @@
7205
7278
  return _this.handleNonMatchingProduct(basketEntry);
7206
7279
  }
7207
7280
  });
7208
- if (syncOperations.length === 0) { // forkJoin needs an array of at least 1 observable otherwise the following subscribe never completes
7281
+ // forkJoin needs an array of at least 1 observable otherwise the following subscribe never completes
7282
+ if (syncOperations.length === 0) {
7209
7283
  syncOperations.push(rxjs.of(null));
7210
7284
  }
7211
7285
  return rxjs.forkJoin(syncOperations);
@@ -7704,7 +7778,7 @@
7704
7778
  var ContextService = /** @class */ (function () {
7705
7779
  function ContextService(posService, basketsService, userService, preferencesService, analyticsService, recipesService, mediaMatcher, suppliersService, breakpointObserver,
7706
7780
  // private basketHandler: LegacyBasketsSynchronizerService,
7707
- basketHandler, storeLocatorService, recipeLikesService, fakeCartService, historyService) {
7781
+ basketHandler, storeLocatorService, recipeLikesService, fakeCartService, historyService, contextRegistryService) {
7708
7782
  var _this = this;
7709
7783
  this.posService = posService;
7710
7784
  this.basketsService = basketsService;
@@ -7720,6 +7794,7 @@
7720
7794
  this.recipeLikesService = recipeLikesService;
7721
7795
  this.fakeCartService = fakeCartService;
7722
7796
  this.historyService = historyService;
7797
+ this.contextRegistryService = contextRegistryService;
7723
7798
  this.videoRecipesEnabled = false;
7724
7799
  this.articlesInCatalogEnabled = false;
7725
7800
  this.tagsOnRecipesEnabled = false;
@@ -7790,6 +7865,12 @@
7790
7865
  definePushProductsToCart: function (pushProductsToCart) {
7791
7866
  _this.basketHandler.pushProductsToRetailerCart = pushProductsToCart;
7792
7867
  },
7868
+ defineAddProductsToCart: function (addProductsToCart) {
7869
+ _this.basketHandler.addProductsToRetailerCart = addProductsToCart;
7870
+ },
7871
+ defineRemoveProductsFromCart: function (removeProductsFromCart) {
7872
+ _this.basketHandler.removeProductsFromRetailerCart = removeProductsFromCart;
7873
+ },
7793
7874
  definePushBasketEntriesToBasket: function (pushBasketEntriesToBasket) {
7794
7875
  _this.basketHandler.pushBasketEntriesToBasket = pushBasketEntriesToBasket;
7795
7876
  },
@@ -7934,9 +8015,8 @@
7934
8015
  throw new Error('the token does not have the correct format');
7935
8016
  }
7936
8017
  _this.mealz.supplier.setOrigin(parsedToken.origin);
7937
- if (!parsedToken.disableAnalytics) {
7938
- _this.mealz.analytics.init(parsedToken.domain);
7939
- }
8018
+ _this.mealz.analytics.init(parsedToken.domain);
8019
+ _this.contextRegistryService.disabledAnalytics = !!parsedToken.disableAnalytics;
7940
8020
  if (parsedToken.orderHistory) {
7941
8021
  _this.orderHistoryEnabled = parsedToken.orderHistory;
7942
8022
  }
@@ -7961,12 +8041,14 @@
7961
8041
  user: {
7962
8042
  loadWithAuthlessId: function (id, forbidProfiling) {
7963
8043
  if (forbidProfiling === void 0) { forbidProfiling = false; }
8044
+ _this.contextRegistryService.forbidProfiling = forbidProfiling;
7964
8045
  localStorage.setItem('_miam/authlessId', id);
7965
8046
  localStorage.setItem('_miam/authless-forbid-profiling', '' + forbidProfiling);
7966
8047
  },
7967
8048
  loadWithExternalId: function (id, forbidProfiling, initBasket) {
7968
8049
  if (forbidProfiling === void 0) { forbidProfiling = false; }
7969
8050
  if (initBasket === void 0) { initBasket = false; }
8051
+ _this.contextRegistryService.forbidProfiling = forbidProfiling;
7970
8052
  _this.loggedOnSession = true;
7971
8053
  localStorage.setItem('_miam/userId', id);
7972
8054
  localStorage.removeItem('_miam/userToken');
@@ -8202,7 +8284,7 @@
8202
8284
  };
8203
8285
  return ContextService;
8204
8286
  }());
8205
- ContextService.ɵfac = function ContextService_Factory(t) { return new (t || ContextService)(i0__namespace.ɵɵinject(PointOfSalesService), i0__namespace.ɵɵinject(BasketsService), i0__namespace.ɵɵinject(UserService), i0__namespace.ɵɵinject(PreferencesService), i0__namespace.ɵɵinject(AnalyticsService), i0__namespace.ɵɵinject(RecipesService), i0__namespace.ɵɵinject(i7__namespace.MediaMatcher), i0__namespace.ɵɵinject(SuppliersService), i0__namespace.ɵɵinject(i7__namespace.BreakpointObserver), i0__namespace.ɵɵinject(BasketsSynchronizerService), i0__namespace.ɵɵinject(StoreLocatorService), i0__namespace.ɵɵinject(RecipeLikesService), i0__namespace.ɵɵinject(FakeRetailerCartService), i0__namespace.ɵɵinject(HistoryService)); };
8287
+ ContextService.ɵfac = function ContextService_Factory(t) { return new (t || ContextService)(i0__namespace.ɵɵinject(PointOfSalesService), i0__namespace.ɵɵinject(BasketsService), i0__namespace.ɵɵinject(UserService), i0__namespace.ɵɵinject(PreferencesService), i0__namespace.ɵɵinject(AnalyticsService), i0__namespace.ɵɵinject(RecipesService), i0__namespace.ɵɵinject(i7__namespace.MediaMatcher), i0__namespace.ɵɵinject(SuppliersService), i0__namespace.ɵɵinject(i7__namespace.BreakpointObserver), i0__namespace.ɵɵinject(BasketsSynchronizerService), i0__namespace.ɵɵinject(StoreLocatorService), i0__namespace.ɵɵinject(RecipeLikesService), i0__namespace.ɵɵinject(FakeRetailerCartService), i0__namespace.ɵɵinject(HistoryService), i0__namespace.ɵɵinject(ContextRegistryService)); };
8206
8288
  ContextService.ɵprov = i0__namespace.ɵɵdefineInjectable({ token: ContextService, factory: ContextService.ɵfac, providedIn: 'root' });
8207
8289
  (function () {
8208
8290
  (typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(ContextService, [{
@@ -8210,7 +8292,7 @@
8210
8292
  args: [{
8211
8293
  providedIn: 'root'
8212
8294
  }]
8213
- }], function () { return [{ type: PointOfSalesService }, { type: BasketsService }, { type: UserService }, { type: PreferencesService }, { type: AnalyticsService }, { type: RecipesService }, { type: i7__namespace.MediaMatcher }, { type: SuppliersService }, { type: i7__namespace.BreakpointObserver }, { type: BasketsSynchronizerService }, { type: StoreLocatorService }, { type: RecipeLikesService }, { type: FakeRetailerCartService }, { type: HistoryService }]; }, null);
8295
+ }], function () { return [{ type: PointOfSalesService }, { type: BasketsService }, { type: UserService }, { type: PreferencesService }, { type: AnalyticsService }, { type: RecipesService }, { type: i7__namespace.MediaMatcher }, { type: SuppliersService }, { type: i7__namespace.BreakpointObserver }, { type: BasketsSynchronizerService }, { type: StoreLocatorService }, { type: RecipeLikesService }, { type: FakeRetailerCartService }, { type: HistoryService }, { type: ContextRegistryService }]; }, null);
8214
8296
  })();
8215
8297
 
8216
8298
  var _c0$p = function (a0, a1) { return { "width": a0, "height": a1 }; };
@@ -10380,18 +10462,15 @@
10380
10462
  * @return This function does not return a value.
10381
10463
  */
10382
10464
  RecipeDetailsService.prototype.setProductsByCategory = function () {
10383
- var _this = this;
10384
- return this.fetchProductPrices().pipe(operators.switchMap(function (prices) {
10385
- _this.productsByCategory = {
10386
- toPickProducts: [],
10387
- oftenIgnoredProducts: []
10388
- };
10389
- _this.recipePrice = {
10390
- remaining: 0,
10391
- inBasket: 0
10392
- };
10393
- return _this.categorizeProducts(prices);
10394
- }));
10465
+ this.productsByCategory = {
10466
+ toPickProducts: [],
10467
+ oftenIgnoredProducts: []
10468
+ };
10469
+ this.recipePrice = {
10470
+ remaining: 0,
10471
+ inBasket: 0
10472
+ };
10473
+ this.categorizeProducts();
10395
10474
  };
10396
10475
  RecipeDetailsService.prototype.calculateProductPrice = function (product, price) {
10397
10476
  var rawTotal = product.basketEntry.status === 'active' ?
@@ -10429,7 +10508,8 @@
10429
10508
  return rxjs.forkJoin(basketEntries$).pipe(operators.switchMap(function (basketEntriesResult) {
10430
10509
  if (fromInit) {
10431
10510
  _this.products = basketEntriesResult;
10432
- return _this.setProductsByCategory();
10511
+ _this.setProductsByCategory();
10512
+ return rxjs.of([]);
10433
10513
  }
10434
10514
  else {
10435
10515
  _this.updatePriceOnGuestChange(basketEntriesResult);
@@ -10658,7 +10738,7 @@
10658
10738
  var _a;
10659
10739
  product.basketEntry = (_a = entriesForRecipe_1.entries.all.find(function (basketEntry) { return basketEntry.name === product.basketEntry.name; })) !== null && _a !== void 0 ? _a : product.basketEntry;
10660
10740
  });
10661
- return _this.setProductsByCategory();
10741
+ _this.setProductsByCategory();
10662
10742
  }
10663
10743
  }
10664
10744
  return rxjs.of(null);
@@ -10669,21 +10749,15 @@
10669
10749
  product.basketEntry.status = 'ignored';
10670
10750
  }
10671
10751
  };
10672
- RecipeDetailsService.prototype.fetchProductPrices = function () {
10673
- var _this = this;
10674
- return rxjs.forkJoin(this.products.map(function (product) { return product.basketEntry.selectedItem
10675
- ? _this.itemsService.getPriceForItem(product.basketEntry.selectedItem.id)
10676
- : rxjs.of({ unit: 0, pricePerUnit: 0, unitOfMeasurement: 'kg' }); }));
10677
- };
10678
- RecipeDetailsService.prototype.categorizeProducts = function (prices) {
10752
+ RecipeDetailsService.prototype.categorizeProducts = function () {
10679
10753
  var _this = this;
10680
10754
  // Iterate over each product in the entriesWithIngredients array
10681
- this.products.forEach(function (product, index) {
10755
+ this.products.forEach(function (product) {
10682
10756
  var basketEntry = product.basketEntry;
10683
10757
  var status = basketEntry.status;
10684
10758
  // Check if the product is ignored
10685
10759
  _this.isIngredientIgnored(product);
10686
- _this.calculateProductPrice(product, prices[index]);
10760
+ _this.calculateProductPrice(product, _this.priceService.getPriceFromBasketEntry(basketEntry));
10687
10761
  _this.correctProductState(product);
10688
10762
  // Check if the product is often ignored based on basketEntryStatus
10689
10763
  if (status === 'often_deleted') {
@@ -10699,7 +10773,6 @@
10699
10773
  this.updateIngredientFromBasketLoading = false;
10700
10774
  this.ingredientToBasketLoading = false;
10701
10775
  this.productsByCategory$.next(this.productsByCategory);
10702
- return rxjs.of(null);
10703
10776
  };
10704
10777
  RecipeDetailsService.prototype.correctProductState = function (product) {
10705
10778
  if (!['often_deleted', 'deleted', 'ignored'].includes(product.basketEntry.status)) {
@@ -17202,12 +17275,11 @@
17202
17275
  i0__namespace.ɵɵelementEnd();
17203
17276
  i0__namespace.ɵɵelementStart(20, "div", 16);
17204
17277
  i0__namespace.ɵɵelementStart(21, "span", 17);
17205
- i0__namespace.ɵɵlistener("inViewport", function BasketPreviewProductComponent_div_0_Template_span_inViewport_21_listener() { i0__namespace.ɵɵrestoreView(_r8_1); var ctx_r10 = i0__namespace.ɵɵnextContext(); return ctx_r10.fetchPrice(); });
17206
17278
  i0__namespace.ɵɵtext(22);
17207
17279
  i0__namespace.ɵɵpipe(23, "currency");
17208
17280
  i0__namespace.ɵɵelementEnd();
17209
17281
  i0__namespace.ɵɵelementStart(24, "ng-miam-counter-input", 18);
17210
- i0__namespace.ɵɵlistener("valueChange", function BasketPreviewProductComponent_div_0_Template_ng_miam_counter_input_valueChange_24_listener($event) { i0__namespace.ɵɵrestoreView(_r8_1); var ctx_r11 = i0__namespace.ɵɵnextContext(); return ctx_r11.counterChanged($event); });
17282
+ i0__namespace.ɵɵlistener("valueChange", function BasketPreviewProductComponent_div_0_Template_ng_miam_counter_input_valueChange_24_listener($event) { i0__namespace.ɵɵrestoreView(_r8_1); var ctx_r10 = i0__namespace.ɵɵnextContext(); return ctx_r10.counterChanged($event); });
17211
17283
  i0__namespace.ɵɵelementEnd();
17212
17284
  i0__namespace.ɵɵelementEnd();
17213
17285
  i0__namespace.ɵɵelementEnd();
@@ -17218,30 +17290,28 @@
17218
17290
  i0__namespace.ɵɵadvance(4);
17219
17291
  i0__namespace.ɵɵproperty("src", ctx_r0.basketEntry.selectedItem.attributes.image, i0__namespace.ɵɵsanitizeUrl);
17220
17292
  i0__namespace.ɵɵadvance(5);
17221
- i0__namespace.ɵɵtextInterpolate(i0__namespace.ɵɵpipeBind1(10, 16, ctx_r0.basketEntry.selectedItem.attributes.name));
17293
+ i0__namespace.ɵɵtextInterpolate(i0__namespace.ɵɵpipeBind1(10, 14, ctx_r0.basketEntry.selectedItem.attributes.name));
17222
17294
  i0__namespace.ɵɵadvance(4);
17223
- i0__namespace.ɵɵtextInterpolate2(" ", i0__namespace.ɵɵpipeBind2(14, 18, ctx_r0.basketEntry.selectedItem.capacityVolume, "1.0-2"), " ", ctx_r0.basketEntry.selectedItem.capacityUnit, " ");
17295
+ i0__namespace.ɵɵtextInterpolate2(" ", i0__namespace.ɵɵpipeBind2(14, 16, ctx_r0.basketEntry.selectedItem.capacityVolume, "1.0-2"), " ", ctx_r0.basketEntry.selectedItem.capacityUnit, " ");
17224
17296
  i0__namespace.ɵɵadvance(2);
17225
17297
  i0__namespace.ɵɵproperty("ngIf", ctx_r0.basketEntry.selectedItem.attributes.promoted);
17226
17298
  i0__namespace.ɵɵadvance(1);
17227
17299
  i0__namespace.ɵɵproperty("ngIf", ctx_r0.basketEntry.recipesIds.length != 0 || ctx_r0.displayReplace);
17228
17300
  i0__namespace.ɵɵadvance(1);
17229
- i0__namespace.ɵɵproperty("ngClass", i0__namespace.ɵɵpureFunction1(24, _c2$4, ctx_r0.loading));
17301
+ i0__namespace.ɵɵproperty("ngClass", i0__namespace.ɵɵpureFunction1(22, _c2$4, ctx_r0.loading));
17230
17302
  i0__namespace.ɵɵadvance(1);
17231
17303
  i0__namespace.ɵɵproperty("ngIf", ctx_r0.loading);
17232
17304
  i0__namespace.ɵɵadvance(1);
17233
17305
  i0__namespace.ɵɵproperty("ngIf", !ctx_r0.loading);
17234
- i0__namespace.ɵɵadvance(2);
17235
- i0__namespace.ɵɵproperty("threshold", 0)("debounceTime", 0);
17236
- i0__namespace.ɵɵadvance(1);
17237
- i0__namespace.ɵɵtextInterpolate1(" ", i0__namespace.ɵɵpipeBind2(23, 21, ctx_r0.price, ctx_r0.basketEntry.selectedItem.attributes.currency), " ");
17306
+ i0__namespace.ɵɵadvance(3);
17307
+ i0__namespace.ɵɵtextInterpolate1(" ", i0__namespace.ɵɵpipeBind2(23, 19, ctx_r0.basketEntry.price, ctx_r0.basketEntry.selectedItem.attributes.currency), " ");
17238
17308
  i0__namespace.ɵɵadvance(2);
17239
17309
  i0__namespace.ɵɵproperty("value", ctx_r0.basketEntry.quantity)("minusLoading", ctx_r0.minusLoading)("disable", ctx_r0.loading);
17240
17310
  }
17241
17311
  }
17242
17312
  var BasketPreviewProductComponent = /** @class */ (function (_super) {
17243
17313
  __extends(BasketPreviewProductComponent, _super);
17244
- function BasketPreviewProductComponent(analyticsService, cdr, recipeDetailsService, recipesService, posService, userService, basketsService, productReplacementService, itemsService, elementRef, contextService) {
17314
+ function BasketPreviewProductComponent(analyticsService, cdr, recipeDetailsService, recipesService, posService, userService, basketsService, productReplacementService, elementRef, contextService) {
17245
17315
  var _this = _super.call(this, analyticsService) || this;
17246
17316
  _this.cdr = cdr;
17247
17317
  _this.recipeDetailsService = recipeDetailsService;
@@ -17250,7 +17320,6 @@
17250
17320
  _this.userService = userService;
17251
17321
  _this.basketsService = basketsService;
17252
17322
  _this.productReplacementService = productReplacementService;
17253
- _this.itemsService = itemsService;
17254
17323
  _this.elementRef = elementRef;
17255
17324
  _this.contextService = contextService;
17256
17325
  _this.displayReplace = false;
@@ -17277,10 +17346,9 @@
17277
17346
  return '';
17278
17347
  };
17279
17348
  BasketPreviewProductComponent.prototype.replaceProduct = function () {
17280
- var _this = this;
17281
17349
  this.productReplacementService.scrollBackToBasketEntryId = this.basketEntry.id;
17282
17350
  this.replaceButtonClicked.emit();
17283
- this.productReplacementService.replaceModalOpen$.pipe(operators.skipWhile(function (isOpen) { return isOpen; }), operators.take(1)).subscribe(function () { return _this.fetchPrice(); });
17351
+ this.productReplacementService.replaceModalOpen$.pipe(operators.skipWhile(function (isOpen) { return isOpen; }), operators.take(1)).subscribe();
17284
17352
  };
17285
17353
  BasketPreviewProductComponent.prototype.scrollBackToProductCard = function () {
17286
17354
  var _this = this;
@@ -17316,13 +17384,6 @@
17316
17384
  this.removed.emit();
17317
17385
  this.cdr.detectChanges();
17318
17386
  };
17319
- BasketPreviewProductComponent.prototype.fetchPrice = function () {
17320
- var _this = this;
17321
- this.subscriptions.add(this.itemsService.getPriceForItem(this.basketEntry.selectedItem.id).subscribe(function (price) {
17322
- _this.price = price.unit.toString();
17323
- _this.cdr.detectChanges();
17324
- }));
17325
- };
17326
17387
  BasketPreviewProductComponent.prototype.initListeners = function () {
17327
17388
  var _this = this;
17328
17389
  var requests = rxjs.combineLatest([
@@ -17342,7 +17403,7 @@
17342
17403
  };
17343
17404
  return BasketPreviewProductComponent;
17344
17405
  }(EventTracerComponent));
17345
- BasketPreviewProductComponent.ɵfac = function BasketPreviewProductComponent_Factory(t) { return new (t || BasketPreviewProductComponent)(i0__namespace.ɵɵdirectiveInject(AnalyticsService), i0__namespace.ɵɵdirectiveInject(i0__namespace.ChangeDetectorRef), i0__namespace.ɵɵdirectiveInject(RecipeDetailsService), i0__namespace.ɵɵdirectiveInject(RecipesService), i0__namespace.ɵɵdirectiveInject(PointOfSalesService), i0__namespace.ɵɵdirectiveInject(UserService), i0__namespace.ɵɵdirectiveInject(BasketsService), i0__namespace.ɵɵdirectiveInject(ProductReplacementService), i0__namespace.ɵɵdirectiveInject(ItemsService), i0__namespace.ɵɵdirectiveInject(i0__namespace.ElementRef), i0__namespace.ɵɵdirectiveInject(ContextService)); };
17406
+ BasketPreviewProductComponent.ɵfac = function BasketPreviewProductComponent_Factory(t) { return new (t || BasketPreviewProductComponent)(i0__namespace.ɵɵdirectiveInject(AnalyticsService), i0__namespace.ɵɵdirectiveInject(i0__namespace.ChangeDetectorRef), i0__namespace.ɵɵdirectiveInject(RecipeDetailsService), i0__namespace.ɵɵdirectiveInject(RecipesService), i0__namespace.ɵɵdirectiveInject(PointOfSalesService), i0__namespace.ɵɵdirectiveInject(UserService), i0__namespace.ɵɵdirectiveInject(BasketsService), i0__namespace.ɵɵdirectiveInject(ProductReplacementService), i0__namespace.ɵɵdirectiveInject(i0__namespace.ElementRef), i0__namespace.ɵɵdirectiveInject(ContextService)); };
17346
17407
  BasketPreviewProductComponent.ɵcmp = i0__namespace.ɵɵdefineComponent({ type: BasketPreviewProductComponent, selectors: [["ng-miam-basket-preview-product"]], inputs: { basketEntry: "basketEntry", displayReplace: "displayReplace" }, outputs: { replaceButtonClicked: "replaceButtonClicked", removed: "removed", countChanged: "countChanged" }, features: [i0__namespace.ɵɵInheritDefinitionFeature], decls: 1, vars: 1, consts: function () {
17347
17408
  var i18n_0;
17348
17409
  if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
@@ -17352,15 +17413,15 @@
17352
17413
  else {
17353
17414
  i18n_0 = $localize(templateObject_1$y || (templateObject_1$y = __makeTemplateObject([":\u241F8e4fa20cb8b77c41c980ba077b80bc8ea128239a\u241F4705093661060921903:Remplacer"], [":\u241F8e4fa20cb8b77c41c980ba077b80bc8ea128239a\u241F4705093661060921903:Remplacer"])));
17354
17415
  }
17355
- return [["class", "miam-basket-preview-product", 3, "id", 4, "ngIf"], [1, "miam-basket-preview-product", 3, "id"], [1, "miam-basket-preview-product__infos-container"], [1, "miam-basket-preview-product__picture-container"], [1, "miam-basket-preview-product__picture"], ["alt", "product picture", 3, "src", "error"], [1, "miam-basket-preview-product__infos-and-actions"], [1, "miam-basket-preview-product__infos"], [1, "miam-basket-preview-product__title", "miam-ds-text", "weight-l", "size-s"], [1, "miam-product-card__badges"], [1, "miam-basket-preview-product__capacity", "miam-ds-badge"], ["class", "miam-basket-preview-product__sponsorised miam-ds-badge", 4, "ngIf"], ["class", "miam-basket-preview-product__replace-button miam-ds-button ghost", 3, "disabled", "click", 4, "ngIf"], [1, "miam-basket-preview-line__remove", "miam-ds-button", "ghost", 3, "ngClass", "click"], ["class", "miam-ds-loader", 4, "ngIf"], ["src", "https://storage.googleapis.com/assets.miam.tech/generic/icons/trash.svg", "alt", "remove recipe", 4, "ngIf"], [1, "miam-basket-preview-product__price-and-action"], ["ngMiamInViewport", "", 1, "miam-basket-preview-product__price", "miam-ds-text", "size-l", "weight-xl", 3, "threshold", "debounceTime", "inViewport"], ["minRange", "0", 3, "value", "minusLoading", "disable", "valueChange"], [1, "miam-basket-preview-product__sponsorised", "miam-ds-badge"], [1, "miam-basket-preview-product__replace-button", "miam-ds-button", "ghost", 3, "disabled", "click"], i18n_0, [1, "miam-ds-loader"], ["src", "https://storage.googleapis.com/assets.miam.tech/generic/icons/trash.svg", "alt", "remove recipe"]];
17416
+ return [["class", "miam-basket-preview-product", 3, "id", 4, "ngIf"], [1, "miam-basket-preview-product", 3, "id"], [1, "miam-basket-preview-product__infos-container"], [1, "miam-basket-preview-product__picture-container"], [1, "miam-basket-preview-product__picture"], ["alt", "product picture", 3, "src", "error"], [1, "miam-basket-preview-product__infos-and-actions"], [1, "miam-basket-preview-product__infos"], [1, "miam-basket-preview-product__title", "miam-ds-text", "weight-l", "size-s"], [1, "miam-product-card__badges"], [1, "miam-basket-preview-product__capacity", "miam-ds-badge"], ["class", "miam-basket-preview-product__sponsorised miam-ds-badge", 4, "ngIf"], ["class", "miam-basket-preview-product__replace-button miam-ds-button ghost", 3, "disabled", "click", 4, "ngIf"], [1, "miam-basket-preview-line__remove", "miam-ds-button", "ghost", 3, "ngClass", "click"], ["class", "miam-ds-loader", 4, "ngIf"], ["src", "https://storage.googleapis.com/assets.miam.tech/generic/icons/trash.svg", "alt", "remove recipe", 4, "ngIf"], [1, "miam-basket-preview-product__price-and-action"], [1, "miam-basket-preview-product__price", "miam-ds-text", "size-l", "weight-xl"], ["minRange", "0", 3, "value", "minusLoading", "disable", "valueChange"], [1, "miam-basket-preview-product__sponsorised", "miam-ds-badge"], [1, "miam-basket-preview-product__replace-button", "miam-ds-button", "ghost", 3, "disabled", "click"], i18n_0, [1, "miam-ds-loader"], ["src", "https://storage.googleapis.com/assets.miam.tech/generic/icons/trash.svg", "alt", "remove recipe"]];
17356
17417
  }, template: function BasketPreviewProductComponent_Template(rf, ctx) {
17357
17418
  if (rf & 1) {
17358
- i0__namespace.ɵɵtemplate(0, BasketPreviewProductComponent_div_0_Template, 25, 26, "div", 0);
17419
+ i0__namespace.ɵɵtemplate(0, BasketPreviewProductComponent_div_0_Template, 25, 24, "div", 0);
17359
17420
  }
17360
17421
  if (rf & 2) {
17361
17422
  i0__namespace.ɵɵproperty("ngIf", ctx.basketEntry.selectedItem);
17362
17423
  }
17363
- }, directives: [i2__namespace.NgIf, i2__namespace.NgClass, InViewportDirective, CounterInputComponent], pipes: [CapitalizeFirstLetterPipe, i2__namespace.DecimalPipe, i2__namespace.CurrencyPipe], styles: [".miam-basket-preview-product{display:flex;padding:12px;flex-direction:column;align-items:flex-start;align-self:stretch;background:var(--miam-ds-color-background-primary,#fff)}.miam-basket-preview-product .miam-basket-preview-product__infos-container{display:flex;flex-direction:row;align-items:flex-start;width:100%}.miam-basket-preview-product .miam-basket-preview-product__infos-container .miam-basket-preview-product__picture-container{position:relative;margin-right:12px;margin-bottom:12px}.miam-basket-preview-product .miam-basket-preview-product__infos-container .miam-basket-preview-product__picture-container .miam-basket-preview-product__picture{height:100px;width:100px;border-radius:8px;cursor:pointer}.miam-basket-preview-product .miam-basket-preview-product__infos-container .miam-basket-preview-product__picture-container .miam-basket-preview-product__picture img{height:100%;width:100%;-o-object-fit:cover;object-fit:cover;border-radius:8px}.miam-basket-preview-product .miam-basket-preview-product__infos-container .miam-basket-preview-product__infos-and-actions{display:flex;align-items:flex-start;gap:8px;flex:1 0 0}.miam-basket-preview-product .miam-basket-preview-product__infos-container .miam-basket-preview-product__infos-and-actions .miam-basket-preview-product__infos{display:flex;flex-direction:column;align-items:flex-start;flex:1 0 0;gap:4px}.miam-basket-preview-product .miam-basket-preview-product__infos-container .miam-basket-preview-product__infos-and-actions .miam-basket-preview-product__infos .miam-basket-preview-product__title{display:-webkit-box;-webkit-box-orient:vertical;-webkit-product-clamp:2;align-self:stretch;overflow:hidden;color:var(--miam-ds-color-neutral-black,#02182b);text-overflow:ellipsis;cursor:pointer}.miam-basket-preview-product .miam-basket-preview-product__price-and-action{display:flex;flex-direction:row;justify-content:space-between;align-items:center;align-self:stretch}"], encapsulation: 2, changeDetection: 0 });
17424
+ }, directives: [i2__namespace.NgIf, i2__namespace.NgClass, CounterInputComponent], pipes: [CapitalizeFirstLetterPipe, i2__namespace.DecimalPipe, i2__namespace.CurrencyPipe], styles: [".miam-basket-preview-product{display:flex;padding:12px;flex-direction:column;align-items:flex-start;align-self:stretch;background:var(--miam-ds-color-background-primary,#fff)}.miam-basket-preview-product .miam-basket-preview-product__infos-container{display:flex;flex-direction:row;align-items:flex-start;width:100%}.miam-basket-preview-product .miam-basket-preview-product__infos-container .miam-basket-preview-product__picture-container{position:relative;margin-right:12px;margin-bottom:12px}.miam-basket-preview-product .miam-basket-preview-product__infos-container .miam-basket-preview-product__picture-container .miam-basket-preview-product__picture{height:100px;width:100px;border-radius:8px;cursor:pointer}.miam-basket-preview-product .miam-basket-preview-product__infos-container .miam-basket-preview-product__picture-container .miam-basket-preview-product__picture img{height:100%;width:100%;-o-object-fit:cover;object-fit:cover;border-radius:8px}.miam-basket-preview-product .miam-basket-preview-product__infos-container .miam-basket-preview-product__infos-and-actions{display:flex;align-items:flex-start;gap:8px;flex:1 0 0}.miam-basket-preview-product .miam-basket-preview-product__infos-container .miam-basket-preview-product__infos-and-actions .miam-basket-preview-product__infos{display:flex;flex-direction:column;align-items:flex-start;flex:1 0 0;gap:4px}.miam-basket-preview-product .miam-basket-preview-product__infos-container .miam-basket-preview-product__infos-and-actions .miam-basket-preview-product__infos .miam-basket-preview-product__title{display:-webkit-box;-webkit-box-orient:vertical;-webkit-product-clamp:2;align-self:stretch;overflow:hidden;color:var(--miam-ds-color-neutral-black,#02182b);text-overflow:ellipsis;cursor:pointer}.miam-basket-preview-product .miam-basket-preview-product__price-and-action{display:flex;flex-direction:row;justify-content:space-between;align-items:center;align-self:stretch}"], encapsulation: 2, changeDetection: 0 });
17364
17425
  (function () {
17365
17426
  (typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(BasketPreviewProductComponent, [{
17366
17427
  type: i0.Component,
@@ -17371,7 +17432,7 @@
17371
17432
  encapsulation: i0.ViewEncapsulation.None,
17372
17433
  changeDetection: i0.ChangeDetectionStrategy.OnPush
17373
17434
  }]
17374
- }], function () { return [{ type: AnalyticsService }, { type: i0__namespace.ChangeDetectorRef }, { type: RecipeDetailsService }, { type: RecipesService }, { type: PointOfSalesService }, { type: UserService }, { type: BasketsService }, { type: ProductReplacementService }, { type: ItemsService }, { type: i0__namespace.ElementRef }, { type: ContextService }]; }, { basketEntry: [{
17435
+ }], function () { return [{ type: AnalyticsService }, { type: i0__namespace.ChangeDetectorRef }, { type: RecipeDetailsService }, { type: RecipesService }, { type: PointOfSalesService }, { type: UserService }, { type: BasketsService }, { type: ProductReplacementService }, { type: i0__namespace.ElementRef }, { type: ContextService }]; }, { basketEntry: [{
17375
17436
  type: i0.Input
17376
17437
  }], displayReplace: [{
17377
17438
  type: i0.Input
@@ -17962,7 +18023,7 @@
17962
18023
  items.fill(response);
17963
18024
  return items.data;
17964
18025
  }), operators.switchMap(function (items) {
17965
- if (items.find(function (item) { return item.id === _this.basketEntry.selectedItem.id; }) === undefined) {
18026
+ if (_this.basketEntry.selectedItem && items.find(function (item) { var _a; return item.id === ((_a = _this.basketEntry.selectedItem) === null || _a === void 0 ? void 0 : _a.id); }) === undefined) {
17966
18027
  items.push(_this.basketEntry.selectedItem);
17967
18028
  }
17968
18029
  var priceObservables = items.map(function (item) { return _this.itemsService.getPriceForItem(item.id).pipe(operators.map(function (price) { return ({ item: item, price: price }); })); });
@@ -17974,7 +18035,8 @@
17974
18035
  }));
17975
18036
  };
17976
18037
  ReplaceItemComponent.prototype.moveSelectedItemToFront = function (itemsWithPrices) {
17977
- var selectedItemId = this.basketEntry.selectedItem.id;
18038
+ var _a;
18039
+ var selectedItemId = (_a = this.basketEntry.selectedItem) === null || _a === void 0 ? void 0 : _a.id;
17978
18040
  return itemsWithPrices.sort(function (a, b) {
17979
18041
  if (a.item.id === selectedItemId) {
17980
18042
  return -1;
@@ -24352,7 +24414,6 @@
24352
24414
  this.subscriptions.push(this.preferencesService.isOpened$.subscribe(function (result) {
24353
24415
  _this.isOpen = result;
24354
24416
  }));
24355
- this.fetchTags();
24356
24417
  };
24357
24418
  PreferencesComponent.prototype.ngAfterViewInit = function () {
24358
24419
  window.scrollTo(0, 0);