ng-miam 8.1.5 → 8.1.7

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.
@@ -576,72 +576,6 @@
576
576
  Icon[Icon["Alert"] = 64] = "Alert";
577
577
  })(exports.Icon || (exports.Icon = {}));
578
578
 
579
- var PointOfSale = /** @class */ (function (_super) {
580
- __extends(PointOfSale, _super);
581
- function PointOfSale() {
582
- var _this = _super.apply(this, __spread(arguments)) || this;
583
- _this.attributes = {
584
- name: '',
585
- settings: {
586
- drive: {
587
- enabled: true,
588
- logo: ''
589
- },
590
- delivery: {
591
- enabled: true,
592
- logo: ''
593
- },
594
- mobile_warning: false
595
- },
596
- 'active-items-count': 0,
597
- distance: 0.0,
598
- address: '',
599
- latitude: '',
600
- longitude: '',
601
- 'ext-id': ''
602
- };
603
- _this.relationships = {
604
- supplier: new i2.DocumentResource(),
605
- items: new i2.DocumentCollection()
606
- };
607
- return _this;
608
- }
609
- Object.defineProperty(PointOfSale.prototype, "references", {
610
- get: function () {
611
- return new Intl.NumberFormat('Fr-fr').format(this.attributes['active-items-count']);
612
- },
613
- enumerable: false,
614
- configurable: true
615
- });
616
- Object.defineProperty(PointOfSale.prototype, "driveEnabled", {
617
- get: function () {
618
- var settings = this.attributes.settings;
619
- return settings && settings.drive && settings.drive.enabled;
620
- },
621
- enumerable: false,
622
- configurable: true
623
- });
624
- Object.defineProperty(PointOfSale.prototype, "deliveryEnabled", {
625
- get: function () {
626
- var settings = this.attributes.settings;
627
- return settings && settings.delivery && settings.delivery.enabled;
628
- },
629
- enumerable: false,
630
- configurable: true
631
- });
632
- Object.defineProperty(PointOfSale.prototype, "extId", {
633
- get: function () {
634
- return this.attributes['ext-id'];
635
- },
636
- set: function (id) {
637
- this.attributes['ext-id'] = id;
638
- },
639
- enumerable: false,
640
- configurable: true
641
- });
642
- return PointOfSale;
643
- }(i2.Resource));
644
-
645
579
  var Ingredient = /** @class */ (function (_super) {
646
580
  __extends(Ingredient, _super);
647
581
  function Ingredient() {
@@ -843,6 +777,72 @@
843
777
  return Item;
844
778
  }(i2.Resource));
845
779
 
780
+ var PointOfSale = /** @class */ (function (_super) {
781
+ __extends(PointOfSale, _super);
782
+ function PointOfSale() {
783
+ var _this = _super.apply(this, __spread(arguments)) || this;
784
+ _this.attributes = {
785
+ name: '',
786
+ settings: {
787
+ drive: {
788
+ enabled: true,
789
+ logo: ''
790
+ },
791
+ delivery: {
792
+ enabled: true,
793
+ logo: ''
794
+ },
795
+ mobile_warning: false
796
+ },
797
+ 'active-items-count': 0,
798
+ distance: 0.0,
799
+ address: '',
800
+ latitude: '',
801
+ longitude: '',
802
+ 'ext-id': ''
803
+ };
804
+ _this.relationships = {
805
+ supplier: new i2.DocumentResource(),
806
+ items: new i2.DocumentCollection()
807
+ };
808
+ return _this;
809
+ }
810
+ Object.defineProperty(PointOfSale.prototype, "references", {
811
+ get: function () {
812
+ return new Intl.NumberFormat('Fr-fr').format(this.attributes['active-items-count']);
813
+ },
814
+ enumerable: false,
815
+ configurable: true
816
+ });
817
+ Object.defineProperty(PointOfSale.prototype, "driveEnabled", {
818
+ get: function () {
819
+ var settings = this.attributes.settings;
820
+ return settings && settings.drive && settings.drive.enabled;
821
+ },
822
+ enumerable: false,
823
+ configurable: true
824
+ });
825
+ Object.defineProperty(PointOfSale.prototype, "deliveryEnabled", {
826
+ get: function () {
827
+ var settings = this.attributes.settings;
828
+ return settings && settings.delivery && settings.delivery.enabled;
829
+ },
830
+ enumerable: false,
831
+ configurable: true
832
+ });
833
+ Object.defineProperty(PointOfSale.prototype, "extId", {
834
+ get: function () {
835
+ return this.attributes['ext-id'];
836
+ },
837
+ set: function (id) {
838
+ this.attributes['ext-id'] = id;
839
+ },
840
+ enumerable: false,
841
+ configurable: true
842
+ });
843
+ return PointOfSale;
844
+ }(i2.Resource));
845
+
846
846
  var Package = /** @class */ (function (_super) {
847
847
  __extends(Package, _super);
848
848
  function Package() {
@@ -2049,13 +2049,18 @@
2049
2049
  _this.resource = PointOfSale;
2050
2050
  _this.type = 'point-of-sales';
2051
2051
  _this.pos$ = new rxjs.BehaviorSubject(undefined);
2052
+ _this.posIsLoading$ = new rxjs.BehaviorSubject(false);
2052
2053
  _this.register();
2053
2054
  return _this;
2054
2055
  }
2055
2056
  PointOfSalesService.prototype.loadPos = function (posId) {
2056
2057
  var _this = this;
2058
+ this.posIsLoading$.next(true);
2057
2059
  if (!this.pos$.value || this.pos$.value.id !== posId) {
2058
- this.get(posId, { include: ['supplier'] }).pipe(operators.skipWhile(function (pos) { return pos.is_loading; }), operators.tap(function (pos) { return _this.pos$.next(pos); })).subscribe();
2060
+ this.get(posId, { include: ['supplier'] }).pipe(operators.skipWhile(function (pos) { return pos.is_loading; }), operators.tap(function (pos) {
2061
+ _this.pos$.next(pos);
2062
+ _this.posIsLoading$.next(false);
2063
+ })).subscribe();
2059
2064
  }
2060
2065
  return this.pos$;
2061
2066
  };
@@ -2063,10 +2068,20 @@
2063
2068
  return this.pos$.pipe(operators.map(function (pos) { var _a, _b, _c; return !!((_c = (_b = (_a = pos === null || pos === void 0 ? void 0 : pos.relationships) === null || _a === void 0 ? void 0 : _a.supplier) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.id); }));
2064
2069
  };
2065
2070
  PointOfSalesService.prototype.posWasInitialized = function () {
2066
- return this.pos$.pipe(operators.map(function (pos) { return pos !== undefined; }));
2071
+ return rxjs.combineLatest([
2072
+ this.pos$,
2073
+ this.posIsLoading$
2074
+ ]).pipe(operators.skipWhile(function (_d) {
2075
+ var _e = __read(_d, 2), _pos = _e[0], loading = _e[1];
2076
+ return loading;
2077
+ }), operators.map(function (_d) {
2078
+ var _e = __read(_d, 2), pos = _e[0], _isLoading = _e[1];
2079
+ return pos !== undefined;
2080
+ }));
2067
2081
  };
2068
2082
  PointOfSalesService.prototype.loadPosWithExtId = function (extId) {
2069
2083
  var _this = this;
2084
+ this.posIsLoading$.next(true);
2070
2085
  this.suppliersService.supplier$.pipe(operators.skipWhile(function (supplier) { return !(supplier === null || supplier === void 0 ? void 0 : supplier.id); }), operators.take(1), operators.switchMap(function (supplier) { return _this.all({
2071
2086
  remotefilter: {
2072
2087
  'ext-id': extId,
@@ -2076,9 +2091,11 @@
2076
2091
  }).pipe(operators.skipWhile(function (pos) { return pos.is_loading; }), operators.tap(function (pos) {
2077
2092
  if (pos.data.length > 0) {
2078
2093
  _this.pos$.next(pos.data[0]);
2094
+ _this.posIsLoading$.next(false);
2079
2095
  }
2080
2096
  else {
2081
2097
  _this.pos$.next(null);
2098
+ _this.posIsLoading$.next(false);
2082
2099
  }
2083
2100
  })); })).subscribe();
2084
2101
  return this.pos$;
@@ -2936,9 +2953,13 @@
2936
2953
  this.abTestkey = key;
2937
2954
  };
2938
2955
  AnalyticsService.prototype.event = function (name, path, props) {
2956
+ var _a;
2939
2957
  if (this.abTestkey) {
2940
2958
  props.abTestKey = this.abTestkey;
2941
2959
  }
2960
+ if (((_a = localStorage.getItem('_miam/affiliate')) === null || _a === void 0 ? void 0 : _a.length) > 0) {
2961
+ props.affiliate = localStorage.getItem('_miam/affiliate');
2962
+ }
2942
2963
  // eslint-disable-next-line @typescript-eslint/no-unsafe-call
2943
2964
  plausible(name, { u: this.url(path), props: props });
2944
2965
  this.eventEmitter.emit(JSON.stringify({
@@ -3782,6 +3803,7 @@
3782
3803
  if (eventTrace === void 0) { eventTrace = { originPath: '', props: {} }; }
3783
3804
  console.log('[Miam] resetting basket');
3784
3805
  this.analyticsService.sendEventWhenReady(this.analyticsService.EVENT_RECIPE_RESET, eventTrace.originPath, eventTrace.props);
3806
+ localStorage.removeItem('_miam/affiliate');
3785
3807
  this.ignoredBasketsService.resetIgnoredIngredients();
3786
3808
  return this.posService.pos$.pipe(operators.skipWhile(function (pos) { return !pos; }), operators.take(1), operators.switchMap(function (pos) { return _this.waitForBasket.pipe(operators.tap(function (basket) { return _this.analyticsService.sendEventsOfResetBasket(basket, eventTrace); }), operators.switchMap(function () { return _this.get("reset?point_of_sale_id=" + pos.id + "&fields[baskets]=" + BASKET_SPARSE_FIELDS.baskets.join(',')).pipe(operators.skipWhile(function (basket) { return basket.is_loading; }), operators.switchMap(function (basket) { return _this.updateLocalBasket(basket); })); })); }));
3787
3809
  };
@@ -3805,6 +3827,7 @@
3805
3827
  console.log("[Miam] send push analytics event if > 0: " + JSON.stringify(confirmedBasket.totalPrice) + " " + JSON.stringify(confirmedBasket));
3806
3828
  if (confirmedBasket.totalPrice > 0 && confirmedBasket.token) {
3807
3829
  _this.analyticsService.sendEventWhenReady(_this.analyticsService.EVENT_BASKET_CONFIRMED, null, _this.eventProps(confirmedBasket, totalPrice));
3830
+ localStorage.removeItem('_miam/affiliate');
3808
3831
  }
3809
3832
  _this._basket$.next(undefined);
3810
3833
  return _this.resetBasket();
@@ -8358,35 +8381,33 @@
8358
8381
  var _this = this;
8359
8382
  var transferData = this.getTransferData();
8360
8383
  if (transferData) {
8361
- this.basketsService.waitForBasket.pipe(operators.take(1), operators.switchMap(function () { return _this.applyBasketTransfer(transferData); }), operators.switchMap(function () { return _this.basketsService.reloadBasket(); })).subscribe();
8384
+ this.setSessionData(transferData);
8385
+ this.applyBasketTransfer(transferData).pipe(operators.switchMap(function () { return _this.basketsService.reloadBasket(); })).subscribe();
8362
8386
  }
8363
8387
  };
8364
8388
  BasketTransferService.prototype.applyBasketTransfer = function (params) {
8365
8389
  var _this = this;
8366
- this.setSessionData(params);
8367
- return this.callHookbackIfNotLogged().pipe(operators.skipWhile(function (isLogged) { return !isLogged; }), operators.switchMap(function () { return _this.forcePosIfUnset(params.posExtId); }), operators.skipWhile(function (isPosSet) { return !isPosSet; }), operators.switchMap(function () {
8368
- return _this.posService.pos$.pipe(operators.skipWhile(function (pos) { return !pos; }), operators.take(1), operators.switchMap(function (pos) {
8369
- var posId = pos.id;
8370
- var transferBasketUrl = environment$1.miamAPI + "/api/v1/baskets/transfer?point_of_sale_id=" + posId + "&transferred_basket_token=" + params.basketToken;
8371
- _this.clearTransferSessionData();
8372
- sessionStorage.setItem('_miam/basketActionInterrupted', 'true');
8373
- return _this.http.patch(transferBasketUrl, {}).pipe(operators.switchMap(function () {
8374
- var getCurrentBasketUrl = environment$1.miamAPI + "/api/v1/baskets/current?point_of_sale_id=" + posId;
8375
- return _this.http.get(getCurrentBasketUrl, {}).pipe(operators.switchMap(function () {
8376
- sessionStorage.removeItem('_miam/basketActionInterrupted');
8377
- return rxjs.of(true);
8378
- }));
8390
+ return this.callHookbackIfNotLogged().pipe(operators.skipWhile(function (isLogged) { return !isLogged; }), operators.switchMap(function () { return _this.forcePosIfUnset(params.posExtId); }), operators.skipWhile(function (isPosSet) { return !isPosSet; }), operators.switchMap(function () { return _this.posService.pos$.pipe(operators.skipWhile(function (pos) { return !pos; }), operators.take(1), operators.switchMap(function (pos) { return _this.basketsService.waitForBasket
8391
+ .pipe(operators.map(function () { return pos; })); }), operators.switchMap(function (pos) {
8392
+ var posId = pos.id;
8393
+ var transferBasketUrl = environment$1.miamAPI + "/api/v1/baskets/transfer?point_of_sale_id=" + posId + "&transferred_basket_token=" + params.basketToken;
8394
+ _this.clearTransferSessionData();
8395
+ sessionStorage.setItem('_miam/basketActionInterrupted', 'true');
8396
+ return _this.http.patch(transferBasketUrl, {}).pipe(operators.switchMap(function () {
8397
+ var getCurrentBasketUrl = environment$1.miamAPI + "/api/v1/baskets/current?point_of_sale_id=" + posId;
8398
+ return _this.http.get(getCurrentBasketUrl, {}).pipe(operators.switchMap(function () {
8399
+ sessionStorage.removeItem('_miam/basketActionInterrupted');
8400
+ return rxjs.of(true);
8379
8401
  }));
8380
8402
  }));
8381
- }));
8403
+ })); }));
8382
8404
  };
8383
8405
  BasketTransferService.prototype.setSessionData = function (params) {
8384
- var basketTokenFromSession = sessionStorage.getItem('_miam/transferredBasketToken');
8385
- var posExtIdFromSession = sessionStorage.getItem('_miam/pointOfSaleExtId');
8386
- var isSessionDataMatching = basketTokenFromSession === params.basketToken && posExtIdFromSession === params.posExtId;
8387
- if (!isSessionDataMatching) {
8388
- sessionStorage.setItem('_miam/transferredBasketToken', params.basketToken);
8389
- sessionStorage.setItem('_miam/posOfSaleExtId', params.posExtId);
8406
+ var _a;
8407
+ sessionStorage.setItem('_miam/transferredBasketToken', params.basketToken);
8408
+ sessionStorage.setItem('_miam/posOfSaleExtId', params.posExtId);
8409
+ if (((_a = params.affiliate) === null || _a === void 0 ? void 0 : _a.length) > 0) {
8410
+ localStorage.setItem('_miam/affiliate', params.affiliate);
8390
8411
  }
8391
8412
  };
8392
8413
  BasketTransferService.prototype.clearTransferSessionData = function () {
@@ -8416,8 +8437,8 @@
8416
8437
  return rxjs.combineLatest([
8417
8438
  this.userService.isLogged$,
8418
8439
  this.posService.posWasInitialized()
8419
- ]).pipe(operators.take(1), operators.map(function (_a) {
8420
- var _b = __read(_a, 2), isLogged = _b[0], isPosValid = _b[1];
8440
+ ]).pipe(operators.take(1), operators.map(function (_b) {
8441
+ var _c = __read(_b, 2), isLogged = _c[0], isPosValid = _c[1];
8421
8442
  return _this.contextService.hookCallback(isLogged, isPosValid);
8422
8443
  }));
8423
8444
  };
@@ -8432,19 +8453,31 @@
8432
8453
  }));
8433
8454
  };
8434
8455
  BasketTransferService.prototype.getTransferData = function () {
8456
+ var _a;
8435
8457
  var currentUrl = window.location.href;
8436
8458
  var urlParams = new URL(currentUrl).searchParams;
8437
8459
  var basketToken = urlParams.get('transferred_basket_token') || sessionStorage.getItem('_miam/transferredBasketToken');
8438
8460
  var posExtId = urlParams.get('point_of_sale_ext_id') || sessionStorage.getItem('_miam/posOfSaleExtId');
8439
- var urlWithoutParams = currentUrl.split('?')[0];
8440
- history.replaceState({}, document.title, urlWithoutParams);
8461
+ var affiliate = (_a = urlParams.get('utm_source')) === null || _a === void 0 ? void 0 : _a.toLowerCase();
8441
8462
  if (basketToken && posExtId) {
8442
- return { basketToken: basketToken, posExtId: posExtId };
8463
+ this.removeTransferParamsFromUrl();
8464
+ return { basketToken: basketToken, posExtId: posExtId, affiliate: affiliate };
8443
8465
  }
8444
8466
  else {
8445
8467
  return null;
8446
8468
  }
8447
8469
  };
8470
+ BasketTransferService.prototype.removeTransferParamsFromUrl = function () {
8471
+ var currentUrl = window.location.href;
8472
+ var urlQuery = currentUrl.split('?')[1];
8473
+ if (urlQuery) {
8474
+ var urlParams = new URLSearchParams(urlQuery);
8475
+ urlParams.delete('transferred_basket_token');
8476
+ urlParams.delete('point_of_sale_ext_id');
8477
+ var newUrl = currentUrl.split('?')[0] + (urlParams.toString().length > 0 ? '?' + urlParams.toString() : '');
8478
+ history.replaceState({}, document.title, newUrl);
8479
+ }
8480
+ };
8448
8481
  return BasketTransferService;
8449
8482
  }());
8450
8483
  BasketTransferService.ɵfac = function BasketTransferService_Factory(t) { return new (t || BasketTransferService)(i0__namespace.ɵɵinject(BasketsService), i0__namespace.ɵɵinject(ContextService), i0__namespace.ɵɵinject(PointOfSalesService), i0__namespace.ɵɵinject(i1__namespace.HttpClient), i0__namespace.ɵɵinject(UserService)); };
@@ -8516,7 +8549,7 @@
8516
8549
  request = request.clone({
8517
8550
  setHeaders: {
8518
8551
  'miam-origin': this.context.origin.value,
8519
- 'miam-front-version': '8.1.5',
8552
+ 'miam-front-version': '8.1.7',
8520
8553
  'miam-front-type': 'web',
8521
8554
  'miam-api-version': '4.7.0'
8522
8555
  }