@infrab4a/connect-angular 2.0.6-beta.6 → 2.0.6-beta.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.
- package/bundles/infrab4a-connect-angular.umd.js +57 -42
- package/bundles/infrab4a-connect-angular.umd.js.map +1 -1
- package/esm2015/services/coupon.service.js +20 -17
- package/fesm2015/infrab4a-connect-angular.js +19 -16
- package/fesm2015/infrab4a-connect-angular.js.map +1 -1
- package/package.json +1 -1
- package/services/coupon.service.d.ts +1 -0
|
@@ -597,50 +597,41 @@
|
|
|
597
597
|
CouponService.prototype.hasProductCategories = function (coupon, checkout) {
|
|
598
598
|
var _a;
|
|
599
599
|
return __awaiter(this, void 0, void 0, function () {
|
|
600
|
-
var hasCategories;
|
|
601
|
-
var _this = this;
|
|
600
|
+
var couponCategories, hasCategories;
|
|
602
601
|
return __generator(this, function (_d) {
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
var _b, couponCategories, index, c;
|
|
609
|
-
return __generator(this, function (_d) {
|
|
610
|
-
switch (_d.label) {
|
|
611
|
-
case 0:
|
|
612
|
-
if (!i.categories || !((_b = i.categories) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
613
|
-
console.log('produto não tem categorias');
|
|
614
|
-
return [2 /*return*/, true];
|
|
615
|
-
}
|
|
616
|
-
couponCategories = [];
|
|
617
|
-
index = 0;
|
|
618
|
-
_d.label = 1;
|
|
619
|
-
case 1:
|
|
620
|
-
if (!(index < coupon.productsCategories.length)) return [3 /*break*/, 4];
|
|
621
|
-
return [4 /*yield*/, this.categoryRepository.get({ id: coupon.productsCategories[index] })];
|
|
622
|
-
case 2:
|
|
623
|
-
c = _d.sent();
|
|
624
|
-
couponCategories.push({ id: c.id, firestoreId: c.firestoreId });
|
|
625
|
-
_d.label = 3;
|
|
626
|
-
case 3:
|
|
627
|
-
index++;
|
|
628
|
-
return [3 /*break*/, 1];
|
|
629
|
-
case 4:
|
|
630
|
-
console.log('couponCategories', couponCategories.length, couponCategories);
|
|
631
|
-
return [2 /*return*/, i.categories.some(function (c) {
|
|
632
|
-
console.log('some 1 ', c);
|
|
633
|
-
return couponCategories.some(function (cat) {
|
|
634
|
-
console.log('some 2', cat, cat.id == c, cat.firestoreId);
|
|
635
|
-
if (cat.id == c || cat.firestoreId)
|
|
636
|
-
return true;
|
|
637
|
-
});
|
|
638
|
-
})];
|
|
602
|
+
switch (_d.label) {
|
|
603
|
+
case 0:
|
|
604
|
+
if (!coupon.productsCategories && !coupon.productsCategories.length) {
|
|
605
|
+
console.log('não possui categories');
|
|
606
|
+
return [2 /*return*/, true];
|
|
639
607
|
}
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
608
|
+
return [4 /*yield*/, this.getCouponCategoriesId(coupon)];
|
|
609
|
+
case 1:
|
|
610
|
+
couponCategories = _d.sent();
|
|
611
|
+
console.log('couponCategories', couponCategories.length, couponCategories);
|
|
612
|
+
hasCategories = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.filter(function (i) {
|
|
613
|
+
var _a;
|
|
614
|
+
console.log('entrou no filter');
|
|
615
|
+
if (!i.categories || !((_a = i.categories) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
616
|
+
console.log('produto não tem categorias');
|
|
617
|
+
return true;
|
|
618
|
+
}
|
|
619
|
+
return i.categories.some(function (c) {
|
|
620
|
+
console.log('entrou no some 1', c);
|
|
621
|
+
return couponCategories.some(function (cat) { return (cat.id == c || cat.firestoreId == c); });
|
|
622
|
+
});
|
|
623
|
+
// return i.categories.some(async (c) => {
|
|
624
|
+
// console.log('some category c', c)
|
|
625
|
+
// const categoria: Category & { firestoreId?: string } = await this.categoryRepository.get({id: c})
|
|
626
|
+
// console.log(categoria)
|
|
627
|
+
// console.log(coupon.productsCategories.includes(categoria.id), coupon.productsCategories.includes(categoria.firestoreId), i.isGift)
|
|
628
|
+
// console.log('validation', (coupon.productsCategories.includes(categoria.id) || coupon.productsCategories.includes(categoria.firestoreId)) && !i.isGift)
|
|
629
|
+
// return (coupon.productsCategories.includes(categoria.id) || coupon.productsCategories.includes(categoria.firestoreId)) && !i.isGift
|
|
630
|
+
// })
|
|
631
|
+
});
|
|
632
|
+
console.log('final return', hasCategories, hasCategories.length);
|
|
633
|
+
return [2 /*return*/, hasCategories.length ? true : false];
|
|
634
|
+
}
|
|
644
635
|
});
|
|
645
636
|
});
|
|
646
637
|
};
|
|
@@ -688,6 +679,30 @@
|
|
|
688
679
|
});
|
|
689
680
|
});
|
|
690
681
|
};
|
|
682
|
+
CouponService.prototype.getCouponCategoriesId = function (coupon) {
|
|
683
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
684
|
+
var couponCategories, index, c;
|
|
685
|
+
return __generator(this, function (_d) {
|
|
686
|
+
switch (_d.label) {
|
|
687
|
+
case 0:
|
|
688
|
+
couponCategories = [];
|
|
689
|
+
index = 0;
|
|
690
|
+
_d.label = 1;
|
|
691
|
+
case 1:
|
|
692
|
+
if (!(index < coupon.productsCategories.length)) return [3 /*break*/, 4];
|
|
693
|
+
return [4 /*yield*/, this.categoryRepository.get({ id: coupon.productsCategories[index] })];
|
|
694
|
+
case 2:
|
|
695
|
+
c = _d.sent();
|
|
696
|
+
couponCategories.push({ id: c.id, firestoreId: c.firestoreId });
|
|
697
|
+
_d.label = 3;
|
|
698
|
+
case 3:
|
|
699
|
+
index++;
|
|
700
|
+
return [3 /*break*/, 1];
|
|
701
|
+
case 4: return [2 /*return*/, couponCategories];
|
|
702
|
+
}
|
|
703
|
+
});
|
|
704
|
+
});
|
|
705
|
+
};
|
|
691
706
|
return CouponService;
|
|
692
707
|
}());
|
|
693
708
|
CouponService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CouponService, deps: [{ token: 'CouponRepository' }, { token: DEFAULT_SHOP }, { token: 'OrderRepository' }, { token: 'SubscriptionRepository' }, { token: 'CategoryRepository' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|