ng-miam 8.5.2 → 8.5.4
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.
- package/bundles/ng-miam.umd.js +43 -29
- package/bundles/ng-miam.umd.js.map +1 -1
- package/bundles/ng-miam.umd.min.js +1 -1
- package/bundles/ng-miam.umd.min.js.map +1 -1
- package/esm2015/lib/_services/baskets-synchronizing/baskets-synchronizer.service.js +2 -2
- package/esm2015/lib/_services/baskets.service.js +28 -21
- package/esm2015/lib/_services/interceptor.service.js +2 -2
- package/esm2015/lib/_web-components/recipe-modal/recipe-modal.component.js +15 -9
- package/fesm2015/ng-miam.js +42 -29
- package/fesm2015/ng-miam.js.map +1 -1
- package/lib/_services/baskets.service.d.ts +10 -1
- package/lib/_services/baskets.service.d.ts.map +1 -1
- package/lib/_web-components/recipe-modal/recipe-modal.component.d.ts.map +1 -1
- package/package.json +1 -1
package/bundles/ng-miam.umd.js
CHANGED
|
@@ -4130,30 +4130,38 @@
|
|
|
4130
4130
|
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); })); })); }));
|
|
4131
4131
|
};
|
|
4132
4132
|
/** ********************************************************* CONFIRM BASKET ********************************************************* **/
|
|
4133
|
-
|
|
4134
|
-
|
|
4133
|
+
/**
|
|
4134
|
+
* Sends payment.confirm event then confirm basket if retailer's cart price and Mealz basket price are both non-zero
|
|
4135
|
+
* @param totalPrice The price of retailer's basket
|
|
4136
|
+
* @returns the current basket
|
|
4137
|
+
*/
|
|
4138
|
+
BasketsService.prototype.confirmPaymentAndBasket = function (totalPrice) {
|
|
4135
4139
|
var _this = this;
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
return this.waitForBasket.pipe(operators.tap(function (basket) {
|
|
4139
|
-
if (basket.totalPrice > 0) {
|
|
4140
|
+
return this.waitForBasket.pipe(operators.switchMap(function (basket) {
|
|
4141
|
+
if (+totalPrice > 0 && basket.totalPrice > 0) {
|
|
4140
4142
|
_this.analyticsService.sendEventWhenReady(_this.analyticsService.EVENT_PAYMENT_CONFIRMED, null, _this.eventProps(basket, totalPrice));
|
|
4143
|
+
return _this.confirmBasket(basket, totalPrice);
|
|
4141
4144
|
}
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4145
|
+
return _this._basket$;
|
|
4146
|
+
}));
|
|
4147
|
+
};
|
|
4148
|
+
/**
|
|
4149
|
+
* Tries to confirm basket. Sends analytic event and refresh current basket on successfull confirmation
|
|
4150
|
+
*/
|
|
4151
|
+
BasketsService.prototype.confirmBasket = function (basket, totalPrice) {
|
|
4152
|
+
var _this = this;
|
|
4153
|
+
console.debug('[Miam] Confirm Mealz basket');
|
|
4154
|
+
return this.posService.pos$.pipe(operators.skipWhile(function (pos) { return !pos; }), operators.take(1), operators.switchMap(function (pos) {
|
|
4155
|
+
var url = environment$1.miamAPI + "/api/v1/baskets/confirm?point_of_sale_id=" + pos.id;
|
|
4156
|
+
return _this.http.patch(url, {});
|
|
4157
|
+
}), operators.catchError(function () { return rxjs.of(null); }), operators.switchMap(function (result) {
|
|
4158
|
+
if (!result) {
|
|
4159
|
+
return rxjs.of(null);
|
|
4153
4160
|
}
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
|
|
4161
|
+
localStorage.removeItem('_miam/affiliate');
|
|
4162
|
+
_this.analyticsService.sendEventWhenReady(_this.analyticsService.EVENT_BASKET_CONFIRMED, null, _this.eventProps(basket, totalPrice));
|
|
4163
|
+
return _this.refreshCurrentBasket();
|
|
4164
|
+
}), operators.take(1));
|
|
4157
4165
|
};
|
|
4158
4166
|
BasketsService.prototype.eventProps = function (basket, totalPrice) {
|
|
4159
4167
|
return {
|
|
@@ -5314,7 +5322,7 @@
|
|
|
5314
5322
|
BasketsSynchronizerService.prototype.handlePayment = function (total) {
|
|
5315
5323
|
var _this = this;
|
|
5316
5324
|
if (total) {
|
|
5317
|
-
this.basketsService.
|
|
5325
|
+
this.basketsService.confirmPaymentAndBasket(total).subscribe(function () {
|
|
5318
5326
|
_this.firstRetailerBasket = [];
|
|
5319
5327
|
});
|
|
5320
5328
|
}
|
|
@@ -8548,7 +8556,7 @@
|
|
|
8548
8556
|
MiamInterceptor.prototype.setMiamHeaders = function (request) {
|
|
8549
8557
|
var headersToAdd = {
|
|
8550
8558
|
'miam-origin': this.context.origin.value,
|
|
8551
|
-
'miam-front-version': '8.5.
|
|
8559
|
+
'miam-front-version': '8.5.4',
|
|
8552
8560
|
'miam-front-type': 'web',
|
|
8553
8561
|
'miam-api-version': '4.7.0'
|
|
8554
8562
|
};
|
|
@@ -28636,7 +28644,7 @@
|
|
|
28636
28644
|
_this.basketChangedSinceOpened = true;
|
|
28637
28645
|
_this.cdr.detectChanges();
|
|
28638
28646
|
}
|
|
28639
|
-
}), this.basketsService.basket$.pipe(operators.
|
|
28647
|
+
}), this.basketsService.basket$.pipe(operators.skipWhile(function (basket) { return !basket; }), operators.map(function (basket) { return basket.totalPrice; })).subscribe(function (totalPrice) {
|
|
28640
28648
|
_this.totalPrice = totalPrice;
|
|
28641
28649
|
_this.updateShowPlaceOrderFooter();
|
|
28642
28650
|
_this.cdr.detectChanges();
|
|
@@ -28668,18 +28676,24 @@
|
|
|
28668
28676
|
_this.registerTrace(result === null || result === void 0 ? void 0 : result.eventTrace);
|
|
28669
28677
|
if (!(result === null || result === void 0 ? void 0 : result.recipe)) {
|
|
28670
28678
|
if (result === null || result === void 0 ? void 0 : result.force) {
|
|
28671
|
-
_this.
|
|
28672
|
-
|
|
28673
|
-
|
|
28674
|
-
|
|
28675
|
-
|
|
28679
|
+
_this.subscriptions.push(_this.posService.posWasInitialized().pipe(operators.take(1)).subscribe(function (wasInitialized) {
|
|
28680
|
+
if (!wasInitialized) {
|
|
28681
|
+
_this.storeLocatorService.storeLocatorOpened$.next(true);
|
|
28682
|
+
}
|
|
28683
|
+
_this.previewMode.next(result.previewMode);
|
|
28684
|
+
_this.previewAllowed = result.previewAllowed;
|
|
28685
|
+
_this.show = true;
|
|
28686
|
+
// Put back if/when printing is reimplemented
|
|
28687
|
+
// this.printService.prepareForPrint(this.elRef);
|
|
28688
|
+
_this.cdr.detectChanges();
|
|
28689
|
+
}));
|
|
28676
28690
|
}
|
|
28677
28691
|
else {
|
|
28678
28692
|
_this.show = false;
|
|
28679
28693
|
_this._storeLocatorInit = false;
|
|
28680
28694
|
_this.storeLocatorService.storeLocatorOpened$.next(false);
|
|
28695
|
+
_this.cdr.detectChanges();
|
|
28681
28696
|
}
|
|
28682
|
-
_this.cdr.detectChanges();
|
|
28683
28697
|
}
|
|
28684
28698
|
else {
|
|
28685
28699
|
_this.recipeWasAdded = result.wasAdded;
|