@infrab4a/connect-angular 3.3.0-beta.2 → 3.3.0-beta.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/angular-firestore.module.d.ts +6 -2
- package/bundles/infrab4a-connect-angular.umd.js +37 -56
- package/bundles/infrab4a-connect-angular.umd.js.map +1 -1
- package/esm2015/angular-firestore.module.js +12 -5
- package/esm2015/services/cart.service.js +6 -31
- package/fesm2015/infrab4a-connect-angular.js +13 -32
- package/fesm2015/infrab4a-connect-angular.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
import { ModuleWithProviders } from '@angular/core';
|
|
1
|
+
import { ModuleWithProviders, OnInit } from '@angular/core';
|
|
2
2
|
import { AngularFireModule, FirebaseAppConfig, FirebaseOptions } from '@angular/fire';
|
|
3
|
+
import { AngularFirestore } from '@angular/fire/firestore';
|
|
3
4
|
import { AxiosElasticSearchConfig } from '@infrab4a/connect';
|
|
4
5
|
import * as i0 from "@angular/core";
|
|
5
6
|
import * as i1 from "@angular/fire";
|
|
6
7
|
import * as i2 from "./angular-elastic-search.module";
|
|
7
|
-
export declare class AngularFirestoreModule {
|
|
8
|
+
export declare class AngularFirestoreModule implements OnInit {
|
|
9
|
+
private readonly angularFirestore;
|
|
8
10
|
static initializeApp(options: {
|
|
9
11
|
firebase: FirebaseOptions;
|
|
10
12
|
elasticSearch: AxiosElasticSearchConfig;
|
|
11
13
|
}, nameOrConfig?: string | FirebaseAppConfig): ModuleWithProviders<AngularFireModule>;
|
|
14
|
+
constructor(angularFirestore: AngularFirestore);
|
|
15
|
+
ngOnInit(): void;
|
|
12
16
|
static ɵfac: i0.ɵɵFactoryDeclaration<AngularFirestoreModule, never>;
|
|
13
17
|
static ɵmod: i0.ɵɵNgModuleDeclaration<AngularFirestoreModule, never, [typeof i1.AngularFireModule, typeof i2.AngularElasticSeachModule], never>;
|
|
14
18
|
static ɵinj: i0.ɵɵInjectorDeclaration<AngularFirestoreModule>;
|
|
@@ -849,15 +849,15 @@
|
|
|
849
849
|
});
|
|
850
850
|
return cart;
|
|
851
851
|
};
|
|
852
|
-
this.buildLineItem = function (
|
|
853
|
-
var checkout =
|
|
852
|
+
this.buildLineItem = function (_h) {
|
|
853
|
+
var checkout = _h.checkout, item = _h.item, quantity = _h.quantity;
|
|
854
854
|
return __awaiter(_this, void 0, void 0, function () {
|
|
855
|
-
var _a, _b, _c, _d, _e, _f, _g,
|
|
856
|
-
return __generator(this, function (
|
|
857
|
-
switch (
|
|
855
|
+
var _a, _b, _c, _d, _e, _f, _g, product, image, id, name, EAN, brand, slug, stock, price, weight, categories, sku, type, isGift, pricePaid;
|
|
856
|
+
return __generator(this, function (_h) {
|
|
857
|
+
switch (_h.label) {
|
|
858
858
|
case 0: return [4 /*yield*/, this.productRepository.get({ id: item.id })];
|
|
859
859
|
case 1:
|
|
860
|
-
product =
|
|
860
|
+
product = _h.sent();
|
|
861
861
|
item.quantity = (item === null || item === void 0 ? void 0 : item.quantity) || ((_b = (_a = checkout === null || checkout === void 0 ? void 0 : checkout.lineItems) === null || _a === void 0 ? void 0 : _a.find(function (lineItem) { return lineItem.sku === item.sku; })) === null || _b === void 0 ? void 0 : _b.quantity) || 0;
|
|
862
862
|
if (this.checkMaxStock(item, quantity || 0))
|
|
863
863
|
throw new Error('Desculpe! Temos apenas ' + ((_c = item.stock) === null || _c === void 0 ? void 0 : _c.quantity) + ' em estoque.');
|
|
@@ -869,26 +869,6 @@
|
|
|
869
869
|
shop: checkout.shop || this.defaultShop,
|
|
870
870
|
isSubscriber: (_e = checkout.user) === null || _e === void 0 ? void 0 : _e.isSubscriber,
|
|
871
871
|
});
|
|
872
|
-
console.log('checkout', checkout);
|
|
873
|
-
console.log('teste PricePaid', pricePaid);
|
|
874
|
-
console.log('LineItem return', i2.LineItem.toInstance({
|
|
875
|
-
id: id,
|
|
876
|
-
name: name !== null && name !== void 0 ? name : product.name,
|
|
877
|
-
EAN: EAN !== null && EAN !== void 0 ? EAN : product.EAN,
|
|
878
|
-
brand: product.brand,
|
|
879
|
-
slug: slug !== null && slug !== void 0 ? slug : product.slug,
|
|
880
|
-
sku: sku !== null && sku !== void 0 ? sku : product.sku,
|
|
881
|
-
stock: stock,
|
|
882
|
-
price: price,
|
|
883
|
-
image: image,
|
|
884
|
-
weight: weight !== null && weight !== void 0 ? weight : product.weight,
|
|
885
|
-
quantity: (item.quantity || 0) + (quantity || 0),
|
|
886
|
-
pricePaid: pricePaid,
|
|
887
|
-
categories: (_f = product.categories) !== null && _f !== void 0 ? _f : [],
|
|
888
|
-
isGift: isGift !== null && isGift !== void 0 ? isGift : null,
|
|
889
|
-
costPrice: (_g = product.costPrice) !== null && _g !== void 0 ? _g : 0,
|
|
890
|
-
type: type,
|
|
891
|
-
}));
|
|
892
872
|
return [2 /*return*/, {
|
|
893
873
|
checkout: checkout,
|
|
894
874
|
lineItem: i2.LineItem.toInstance({
|
|
@@ -904,9 +884,9 @@
|
|
|
904
884
|
weight: weight !== null && weight !== void 0 ? weight : product.weight,
|
|
905
885
|
quantity: (item.quantity || 0) + (quantity || 0),
|
|
906
886
|
pricePaid: pricePaid,
|
|
907
|
-
categories: (
|
|
887
|
+
categories: (_f = product.categories) !== null && _f !== void 0 ? _f : [],
|
|
908
888
|
isGift: isGift !== null && isGift !== void 0 ? isGift : null,
|
|
909
|
-
costPrice: (
|
|
889
|
+
costPrice: (_g = product.costPrice) !== null && _g !== void 0 ? _g : 0,
|
|
910
890
|
type: type,
|
|
911
891
|
}),
|
|
912
892
|
}];
|
|
@@ -914,8 +894,8 @@
|
|
|
914
894
|
});
|
|
915
895
|
});
|
|
916
896
|
};
|
|
917
|
-
this.getProductPrice = function (
|
|
918
|
-
var product =
|
|
897
|
+
this.getProductPrice = function (_h) {
|
|
898
|
+
var product = _h.product, isSubscriber = _h.isSubscriber;
|
|
919
899
|
var info = product.price;
|
|
920
900
|
if (product.isGift)
|
|
921
901
|
return 0;
|
|
@@ -931,14 +911,13 @@
|
|
|
931
911
|
CartService.prototype.addItem = function (item, quantity) {
|
|
932
912
|
var _this = this;
|
|
933
913
|
if (quantity === void 0) { quantity = 1; }
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
switch (_k.label) {
|
|
914
|
+
return rxjs.from(this.checkoutService.getCheckout()).pipe(operators.concatMap(function (checkout) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_h) {
|
|
915
|
+
switch (_h.label) {
|
|
937
916
|
case 0: return [4 /*yield*/, this.buildLineItem({ checkout: checkout, item: item, quantity: quantity || 1 })];
|
|
938
|
-
case 1: return [2 /*return*/,
|
|
917
|
+
case 1: return [2 /*return*/, _h.sent()];
|
|
939
918
|
}
|
|
940
|
-
}); }); }), operators.mergeMap(function (
|
|
941
|
-
var checkout =
|
|
919
|
+
}); }); }), operators.mergeMap(function (_h) {
|
|
920
|
+
var checkout = _h.checkout, lineItem = _h.lineItem;
|
|
942
921
|
return _this.updateLineItemInCart(lineItem, quantity || 1, checkout);
|
|
943
922
|
}), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
|
|
944
923
|
};
|
|
@@ -975,32 +954,30 @@
|
|
|
975
954
|
CartService.prototype.updateUserCart = function (user) {
|
|
976
955
|
var _this = this;
|
|
977
956
|
return this.checkoutService.getCheckout().pipe(operators.concatMap(function (checkout) { return _this.checkoutService.updateCheckoutUser(i2.Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { user: user }))); }), operators.concatMap(function (checkout) { return __awaiter(_this, void 0, void 0, function () {
|
|
978
|
-
var _a, _b, _k, _l, _m, _o, _p, _q, _r
|
|
957
|
+
var _a, _b, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
979
958
|
var _this = this;
|
|
980
|
-
return __generator(this, function (
|
|
981
|
-
switch (
|
|
959
|
+
return __generator(this, function (_s) {
|
|
960
|
+
switch (_s.label) {
|
|
982
961
|
case 0:
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
_o = (_m =
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
_s = {};
|
|
962
|
+
_j = (_h = this.checkoutService).updateCheckoutLineItems;
|
|
963
|
+
_l = (_k = i2.Checkout).toInstance;
|
|
964
|
+
_o = (_m = Object).assign;
|
|
965
|
+
_p = [Object.assign({}, checkout.toPlain())];
|
|
966
|
+
_q = {};
|
|
989
967
|
if (!((_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.length)) return [3 /*break*/, 2];
|
|
990
|
-
return [4 /*yield*/, Promise.all((_b = checkout.lineItems) === null || _b === void 0 ? void 0 : _b.map(function (item) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (
|
|
991
|
-
switch (
|
|
968
|
+
return [4 /*yield*/, Promise.all((_b = checkout.lineItems) === null || _b === void 0 ? void 0 : _b.map(function (item) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_h) {
|
|
969
|
+
switch (_h.label) {
|
|
992
970
|
case 0: return [4 /*yield*/, this.buildLineItem({ checkout: checkout, item: item })];
|
|
993
|
-
case 1: return [2 /*return*/, (
|
|
971
|
+
case 1: return [2 /*return*/, (_h.sent()).lineItem];
|
|
994
972
|
}
|
|
995
973
|
}); }); }))];
|
|
996
974
|
case 1:
|
|
997
|
-
|
|
975
|
+
_r = _s.sent();
|
|
998
976
|
return [3 /*break*/, 3];
|
|
999
977
|
case 2:
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
case 3: return [2 /*return*/,
|
|
1003
|
-
.toPromise()];
|
|
978
|
+
_r = [];
|
|
979
|
+
_s.label = 3;
|
|
980
|
+
case 3: return [2 /*return*/, _j.apply(_h, [_l.apply(_k, [_o.apply(_m, _p.concat([(_q.lineItems = _r, _q)]))])]).toPromise()];
|
|
1004
981
|
}
|
|
1005
982
|
});
|
|
1006
983
|
}); }), operators.map(function (checkout) { return _this.generateCartObject(checkout.lineItems); }), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
|
|
@@ -1388,7 +1365,8 @@
|
|
|
1388
1365
|
}] });
|
|
1389
1366
|
|
|
1390
1367
|
var AngularFirestoreModule = /** @class */ (function () {
|
|
1391
|
-
function AngularFirestoreModule() {
|
|
1368
|
+
function AngularFirestoreModule(angularFirestore) {
|
|
1369
|
+
this.angularFirestore = angularFirestore;
|
|
1392
1370
|
}
|
|
1393
1371
|
AngularFirestoreModule.initializeApp = function (options, nameOrConfig) {
|
|
1394
1372
|
return {
|
|
@@ -1400,9 +1378,12 @@
|
|
|
1400
1378
|
],
|
|
1401
1379
|
};
|
|
1402
1380
|
};
|
|
1381
|
+
AngularFirestoreModule.prototype.ngOnInit = function () {
|
|
1382
|
+
this.angularFirestore.firestore.settings({ ignoreUndefinedProperties: true });
|
|
1383
|
+
};
|
|
1403
1384
|
return AngularFirestoreModule;
|
|
1404
1385
|
}());
|
|
1405
|
-
AngularFirestoreModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
|
|
1386
|
+
AngularFirestoreModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, deps: [{ token: i1__namespace$1.AngularFirestore }], target: i0__namespace.ɵɵFactoryTarget.NgModule });
|
|
1406
1387
|
AngularFirestoreModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, imports: [fire.AngularFireModule, AngularElasticSeachModule] });
|
|
1407
1388
|
AngularFirestoreModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, providers: [
|
|
1408
1389
|
{
|
|
@@ -1721,7 +1702,7 @@
|
|
|
1721
1702
|
},
|
|
1722
1703
|
],
|
|
1723
1704
|
}]
|
|
1724
|
-
}] });
|
|
1705
|
+
}], ctorParameters: function () { return [{ type: i1__namespace$1.AngularFirestore }]; } });
|
|
1725
1706
|
|
|
1726
1707
|
var AngularHasuraGraphQLModule = /** @class */ (function () {
|
|
1727
1708
|
function AngularHasuraGraphQLModule() {
|