@infrab4a/connect-angular 3.10.0-beta.8 → 3.10.1
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-connect.module.d.ts +1 -0
- package/bundles/infrab4a-connect-angular.umd.js +2143 -1777
- package/bundles/infrab4a-connect-angular.umd.js.map +1 -1
- package/consts/category-structure.d.ts +1 -0
- package/consts/index.d.ts +1 -0
- package/esm2015/angular-connect.module.js +14 -3
- package/esm2015/angular-hasura-graphql.module.js +18 -2
- package/esm2015/consts/category-structure.js +2 -0
- package/esm2015/consts/index.js +2 -1
- package/esm2015/index.js +3 -3
- package/esm2015/services/cart.service.js +3 -3
- package/esm2015/services/catalog/adapters/category-structure.adapter.js +2 -0
- package/esm2015/services/catalog/adapters/index.js +4 -0
- package/esm2015/services/catalog/adapters/new-category-structure.adapter.js +51 -0
- package/esm2015/services/catalog/adapters/old-category-structure.adapter.js +27 -0
- package/esm2015/services/catalog/catalog.service.js +94 -0
- package/esm2015/services/catalog/category.service.js +61 -0
- package/esm2015/services/catalog/enums/index.js +2 -0
- package/esm2015/services/catalog/enums/product-sorts.enum.js +11 -0
- package/esm2015/services/catalog/index.js +6 -0
- package/esm2015/services/catalog/models/category-with-tree.model.js +10 -0
- package/esm2015/services/catalog/models/index.js +2 -0
- package/esm2015/services/catalog/types/index.js +2 -0
- package/esm2015/services/catalog/types/product-sort.type.js +2 -0
- package/esm2015/services/coupon.service.js +2 -2
- package/esm2015/services/index.js +2 -1
- package/fesm2015/infrab4a-connect-angular.js +1729 -1469
- package/fesm2015/infrab4a-connect-angular.js.map +1 -1
- package/index.d.ts +2 -2
- package/package.json +2 -2
- package/services/catalog/adapters/category-structure.adapter.d.ts +4 -0
- package/services/catalog/adapters/index.d.ts +3 -0
- package/services/catalog/adapters/new-category-structure.adapter.d.ts +14 -0
- package/services/catalog/adapters/old-category-structure.adapter.d.ts +10 -0
- package/services/catalog/catalog.service.d.ts +54 -0
- package/services/catalog/category.service.d.ts +15 -0
- package/services/catalog/enums/index.d.ts +1 -0
- package/services/catalog/enums/product-sorts.enum.d.ts +9 -0
- package/services/catalog/index.d.ts +5 -0
- package/services/catalog/models/category-with-tree.model.d.ts +4 -0
- package/services/catalog/models/index.d.ts +1 -0
- package/services/catalog/types/index.d.ts +1 -0
- package/services/catalog/types/product-sort.type.d.ts +2 -0
- package/services/index.d.ts +1 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('
|
|
3
|
-
typeof define === 'function' && define.amd ? define('@infrab4a/connect-angular', ['exports', '@angular/core', '
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.infrab4a = global.infrab4a || {}, global.infrab4a["connect-angular"] = {}), global.ng.core, global.rxjs, global.rxjs.operators, global.ng.fire.auth, global["
|
|
5
|
-
})(this, (function (exports, i0,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/fire'), require('@infrab4a/connect'), require('@angular/fire/firestore'), require('rxjs'), require('rxjs/operators'), require('@angular/fire/auth'), require('js-cookie'), require('class-transformer'), require('@angular/common/http')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define('@infrab4a/connect-angular', ['exports', '@angular/core', '@angular/fire', '@infrab4a/connect', '@angular/fire/firestore', 'rxjs', 'rxjs/operators', '@angular/fire/auth', 'js-cookie', 'class-transformer', '@angular/common/http'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.infrab4a = global.infrab4a || {}, global.infrab4a["connect-angular"] = {}), global.ng.core, global.ng.fire, global["@infrab4a/connect"], global.ng.fire.firestore, global.rxjs, global.rxjs.operators, global.ng.fire.auth, global["js-cookie"], global["class-transformer"], global.ng.common.http));
|
|
5
|
+
})(this, (function (exports, i0, fire, i1, i1$1, rxjs, operators, i1$2, cookie, classTransformer, i1$3) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -25,11 +25,11 @@
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
|
|
28
|
-
var i1__namespace = /*#__PURE__*/_interopNamespace(i1);
|
|
29
|
-
var
|
|
28
|
+
var i1__namespace$1 = /*#__PURE__*/_interopNamespace(i1);
|
|
29
|
+
var i1__namespace$2 = /*#__PURE__*/_interopNamespace(i1$1);
|
|
30
|
+
var i1__namespace = /*#__PURE__*/_interopNamespace(i1$2);
|
|
30
31
|
var cookie__default = /*#__PURE__*/_interopDefaultLegacy(cookie);
|
|
31
|
-
var i1__namespace$
|
|
32
|
-
var i1__namespace$2 = /*#__PURE__*/_interopNamespace(i1$2);
|
|
32
|
+
var i1__namespace$3 = /*#__PURE__*/_interopNamespace(i1$3);
|
|
33
33
|
|
|
34
34
|
/*! *****************************************************************************
|
|
35
35
|
Copyright (c) Microsoft Corporation.
|
|
@@ -349,1927 +349,2290 @@
|
|
|
349
349
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
350
350
|
}
|
|
351
351
|
|
|
352
|
-
var
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
352
|
+
var ES_CONFIG = 'ES_CONFIG';
|
|
353
|
+
|
|
354
|
+
var AngularElasticSeachModule = /** @class */ (function () {
|
|
355
|
+
function AngularElasticSeachModule() {
|
|
356
356
|
}
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
return rxjs.combineLatest(observables).pipe(operators.map(function (_a) {
|
|
363
|
-
var _b = __read(_a, 2), fireUser = _b[0], user = _b[1];
|
|
364
|
-
return {
|
|
365
|
-
user: user,
|
|
366
|
-
isAnonymous: fireUser === null || fireUser === void 0 ? void 0 : fireUser.isAnonymous,
|
|
367
|
-
};
|
|
368
|
-
}));
|
|
369
|
-
};
|
|
370
|
-
AuthService.prototype.getUser = function () {
|
|
371
|
-
var _this = this;
|
|
372
|
-
return this.getFireUser().pipe(operators.map(function (user) { return user === null || user === void 0 ? void 0 : user.uid; }), operators.mergeMap(function (id) { return (id ? rxjs.from(_this.userRepository.get({ id: id })).pipe(operators.catchError(function () { return rxjs.of(null); })) : rxjs.of(null)); }));
|
|
373
|
-
};
|
|
374
|
-
AuthService.prototype.getTokenId = function () {
|
|
375
|
-
return this.angularFireAuth.idToken;
|
|
376
|
-
};
|
|
377
|
-
AuthService.prototype.getFireUser = function () {
|
|
378
|
-
return this.angularFireAuth.user.pipe(operators.catchError(function () { return rxjs.of(null); }));
|
|
357
|
+
AngularElasticSeachModule.initializeApp = function (options) {
|
|
358
|
+
return {
|
|
359
|
+
ngModule: AngularElasticSeachModule,
|
|
360
|
+
providers: [{ provide: ES_CONFIG, useValue: options }],
|
|
361
|
+
};
|
|
379
362
|
};
|
|
380
|
-
return
|
|
363
|
+
return AngularElasticSeachModule;
|
|
381
364
|
}());
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
i0__namespace.ɵɵ
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
365
|
+
AngularElasticSeachModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularElasticSeachModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
|
|
366
|
+
AngularElasticSeachModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularElasticSeachModule });
|
|
367
|
+
AngularElasticSeachModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularElasticSeachModule, providers: [
|
|
368
|
+
{
|
|
369
|
+
provide: i1.ProductsIndex,
|
|
370
|
+
useFactory: function (configuration) { return new i1.ProductsIndex(new i1.AxiosAdapter(configuration)); },
|
|
371
|
+
deps: [ES_CONFIG],
|
|
372
|
+
},
|
|
373
|
+
] });
|
|
374
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularElasticSeachModule, decorators: [{
|
|
375
|
+
type: i0.NgModule,
|
|
376
|
+
args: [{
|
|
377
|
+
providers: [
|
|
378
|
+
{
|
|
379
|
+
provide: i1.ProductsIndex,
|
|
380
|
+
useFactory: function (configuration) { return new i1.ProductsIndex(new i1.AxiosAdapter(configuration)); },
|
|
381
|
+
deps: [ES_CONFIG],
|
|
382
|
+
},
|
|
383
|
+
],
|
|
384
|
+
}]
|
|
385
|
+
}] });
|
|
400
386
|
|
|
401
|
-
var
|
|
402
|
-
function
|
|
403
|
-
this.couponRepository = couponRepository;
|
|
404
|
-
this.defaultShop = defaultShop;
|
|
405
|
-
this.orderRepository = orderRepository;
|
|
406
|
-
this.categoryRepository = categoryRepository;
|
|
407
|
-
this.emailIsFromCollaborator = function (userEmail) { return !!(userEmail === null || userEmail === void 0 ? void 0 : userEmail.match(/@b4a.com.br/g)); };
|
|
387
|
+
var AngularFirestoreModule = /** @class */ (function () {
|
|
388
|
+
function AngularFirestoreModule() {
|
|
408
389
|
}
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
}
|
|
418
|
-
.then(function (result) { return result.data[0]; })).pipe(operators.concatMap(function (coupon) { return _this.couponValidation(coupon, checkoutType); }), operators.concatMap(function (couponValid) { return _this.couponRulesValidation(couponValid, checkoutType, checkout, plan); }), operators.map(function (couponValidated) { return couponValidated; }));
|
|
419
|
-
};
|
|
420
|
-
CouponService.prototype.couponValidation = function (coupon, checkoutType) {
|
|
421
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
422
|
-
var isInShop, isCheckoutType;
|
|
423
|
-
return __generator(this, function (_c) {
|
|
424
|
-
if (!coupon)
|
|
425
|
-
throw 'Cupom inválido.';
|
|
426
|
-
if ((coupon === null || coupon === void 0 ? void 0 : coupon.beginAt) && (coupon === null || coupon === void 0 ? void 0 : coupon.beginAt.getTime()) > new Date().getTime())
|
|
427
|
-
throw 'Cupom inválido.';
|
|
428
|
-
if ((coupon === null || coupon === void 0 ? void 0 : coupon.expiresIn) && (coupon === null || coupon === void 0 ? void 0 : coupon.expiresIn.getTime()) < new Date().getTime())
|
|
429
|
-
throw 'Cupom expirado.';
|
|
430
|
-
isInShop = coupon.shopAvailability === i3.Shops.ALL || coupon.shopAvailability === this.defaultShop;
|
|
431
|
-
if (!isInShop)
|
|
432
|
-
throw 'Cupom inválido para loja.';
|
|
433
|
-
isCheckoutType = coupon.checkoutType === i3.CheckoutTypes.ALL || coupon.checkoutType === checkoutType;
|
|
434
|
-
if (!isCheckoutType)
|
|
435
|
-
throw 'Cupom inválido. Erro de checkout.';
|
|
436
|
-
return [2 /*return*/, coupon];
|
|
437
|
-
});
|
|
438
|
-
});
|
|
439
|
-
};
|
|
440
|
-
CouponService.prototype.couponRulesValidation = function (coupon, checkoutType, checkout, plan) {
|
|
441
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
442
|
-
var validUser, orders, ordersWithUser, couponUseLimits, hasProductCategories, hasMinSubTotal;
|
|
443
|
-
return __generator(this, function (_c) {
|
|
444
|
-
switch (_c.label) {
|
|
445
|
-
case 0:
|
|
446
|
-
if (checkoutType == i3.CheckoutTypes.SUBSCRIPTION) {
|
|
447
|
-
if (coupon.plan && coupon.plan.toUpperCase() !== plan.toUpperCase())
|
|
448
|
-
throw 'Cupom inválido para sua assinatura.';
|
|
449
|
-
return [2 /*return*/, coupon];
|
|
450
|
-
}
|
|
451
|
-
validUser = this.coupomUserValidation(coupon, checkout === null || checkout === void 0 ? void 0 : checkout.user);
|
|
452
|
-
if (!validUser)
|
|
453
|
-
throw 'Usuário não elegível.';
|
|
454
|
-
return [4 /*yield*/, this.getOrdersWithCoupon(coupon)];
|
|
455
|
-
case 1:
|
|
456
|
-
orders = _c.sent();
|
|
457
|
-
ordersWithUser = this.countOrdersWithUser(orders, checkout.user.email);
|
|
458
|
-
couponUseLimits = this.getCouponUseLimits(coupon, checkoutType, checkout.user);
|
|
459
|
-
if (couponUseLimits.useLimitPerUser && ordersWithUser > 0)
|
|
460
|
-
throw 'Limite de uso por usuário atingido.';
|
|
461
|
-
if (!couponUseLimits.unlimited && couponUseLimits.total && orders.length >= couponUseLimits.total)
|
|
462
|
-
throw 'Limite de uso atingido.';
|
|
463
|
-
return [4 /*yield*/, this.hasProductCategories(coupon, checkout)];
|
|
464
|
-
case 2:
|
|
465
|
-
hasProductCategories = _c.sent();
|
|
466
|
-
if (!hasProductCategories)
|
|
467
|
-
throw 'Seu carrinho não possui produtos elegíveis para desconto.';
|
|
468
|
-
return [4 /*yield*/, this.hasMinSubTotal(coupon, checkout)];
|
|
469
|
-
case 3:
|
|
470
|
-
hasMinSubTotal = _c.sent();
|
|
471
|
-
if (!hasMinSubTotal)
|
|
472
|
-
throw "Valor m\u00EDnimo de " + Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' }).format(coupon.minSubTotalValue) + " n\u00E3o atingido";
|
|
473
|
-
return [2 /*return*/, coupon];
|
|
474
|
-
}
|
|
475
|
-
});
|
|
476
|
-
});
|
|
477
|
-
};
|
|
478
|
-
CouponService.prototype.calcDiscountSubscription = function (coupon, checkout) {
|
|
479
|
-
var discount = 0;
|
|
480
|
-
if (coupon.discount.subscription.type == i3.CouponTypes.ABSOLUTE)
|
|
481
|
-
discount = coupon.discount.subscription.value;
|
|
482
|
-
else
|
|
483
|
-
discount = checkout.subscriptionPlan.recurrencePrice * (coupon.discount.subscription.value / 100);
|
|
484
|
-
return rxjs.of(discount);
|
|
485
|
-
};
|
|
486
|
-
CouponService.prototype.calcDiscountShopping = function (coupon, checkout) {
|
|
487
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
488
|
-
var discount;
|
|
489
|
-
return __generator(this, function (_c) {
|
|
490
|
-
switch (_c.label) {
|
|
491
|
-
case 0:
|
|
492
|
-
discount = 0;
|
|
493
|
-
if (!(checkout.user.isSubscriber && coupon.discount.subscriber.value)) return [3 /*break*/, 2];
|
|
494
|
-
return [4 /*yield*/, this.calcDiscountByType(coupon.discount.subscriber.type, coupon.discount.subscriber.value, coupon.productsCategories, checkout)];
|
|
495
|
-
case 1:
|
|
496
|
-
discount = _c.sent();
|
|
497
|
-
return [3 /*break*/, 4];
|
|
498
|
-
case 2: return [4 /*yield*/, this.calcDiscountByType(coupon.discount.non_subscriber.type, coupon.discount.non_subscriber.value, coupon.productsCategories, checkout)];
|
|
499
|
-
case 3:
|
|
500
|
-
discount = _c.sent();
|
|
501
|
-
_c.label = 4;
|
|
502
|
-
case 4: return [2 /*return*/, discount];
|
|
503
|
-
}
|
|
504
|
-
});
|
|
505
|
-
});
|
|
506
|
-
};
|
|
507
|
-
CouponService.prototype.calcDiscountByType = function (type, value, categories, checkout) {
|
|
508
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
509
|
-
var discount, lineItensDiscount, subTotal;
|
|
510
|
-
return __generator(this, function (_c) {
|
|
511
|
-
switch (_c.label) {
|
|
512
|
-
case 0:
|
|
513
|
-
discount = 0;
|
|
514
|
-
return [4 /*yield*/, this.getLineItensEligebleForDiscount(categories, checkout)];
|
|
515
|
-
case 1:
|
|
516
|
-
lineItensDiscount = _c.sent();
|
|
517
|
-
subTotal = this.calcCheckoutSubtotal(lineItensDiscount, checkout.user, checkout.shop);
|
|
518
|
-
if (type == i3.CouponTypes.ABSOLUTE) {
|
|
519
|
-
discount = value > subTotal ? subTotal : value;
|
|
520
|
-
}
|
|
521
|
-
else {
|
|
522
|
-
discount = subTotal * (value / 100);
|
|
523
|
-
}
|
|
524
|
-
return [2 /*return*/, discount];
|
|
525
|
-
}
|
|
526
|
-
});
|
|
527
|
-
});
|
|
528
|
-
};
|
|
529
|
-
CouponService.prototype.hasMinSubTotal = function (coupon, checkout) {
|
|
530
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
531
|
-
var lineItensDiscount, subTotal;
|
|
532
|
-
return __generator(this, function (_c) {
|
|
533
|
-
switch (_c.label) {
|
|
534
|
-
case 0:
|
|
535
|
-
if (!coupon.minSubTotalValue)
|
|
536
|
-
return [2 /*return*/, true];
|
|
537
|
-
return [4 /*yield*/, this.getLineItensEligebleForDiscount(coupon.productsCategories, checkout)];
|
|
538
|
-
case 1:
|
|
539
|
-
lineItensDiscount = _c.sent();
|
|
540
|
-
subTotal = this.calcCheckoutSubtotal(lineItensDiscount, checkout.user, checkout.shop);
|
|
541
|
-
if (coupon.minSubTotalValue <= subTotal)
|
|
542
|
-
return [2 /*return*/, true];
|
|
543
|
-
return [2 /*return*/, false];
|
|
544
|
-
}
|
|
545
|
-
});
|
|
546
|
-
});
|
|
547
|
-
};
|
|
548
|
-
CouponService.prototype.hasProductCategories = function (coupon, checkout) {
|
|
549
|
-
var _a;
|
|
550
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
551
|
-
var couponCategories, hasCategories;
|
|
552
|
-
return __generator(this, function (_c) {
|
|
553
|
-
switch (_c.label) {
|
|
554
|
-
case 0:
|
|
555
|
-
if (!coupon.productsCategories || !coupon.productsCategories.length) {
|
|
556
|
-
return [2 /*return*/, true];
|
|
557
|
-
}
|
|
558
|
-
return [4 /*yield*/, this.getCouponCategoriesId(coupon.productsCategories)];
|
|
559
|
-
case 1:
|
|
560
|
-
couponCategories = _c.sent();
|
|
561
|
-
hasCategories = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.filter(function (i) {
|
|
562
|
-
var _a;
|
|
563
|
-
if (!i.categories || !((_a = i.categories) === null || _a === void 0 ? void 0 : _a.length))
|
|
564
|
-
return true;
|
|
565
|
-
return i.categories.some(function (c) { return couponCategories.some(function (cat) { return cat == c; }); });
|
|
566
|
-
});
|
|
567
|
-
return [2 /*return*/, hasCategories.length ? true : false];
|
|
568
|
-
}
|
|
569
|
-
});
|
|
570
|
-
});
|
|
571
|
-
};
|
|
572
|
-
CouponService.prototype.coupomUserValidation = function (coupon, user) {
|
|
573
|
-
if (!user || coupon.exclusivityType.includes(i3.Exclusivities.ALL_USERS))
|
|
574
|
-
return true;
|
|
575
|
-
var userTypes = [];
|
|
576
|
-
if (coupon.exclusivityType.includes(i3.Exclusivities.COLLABORATORS) && this.emailIsFromCollaborator(user.email))
|
|
577
|
-
userTypes.push(i3.Exclusivities.COLLABORATORS);
|
|
578
|
-
if (coupon.exclusivityType.includes(i3.Exclusivities.SPECIFIC_USER) && coupon.userExclusiveEmail.includes(user.email))
|
|
579
|
-
userTypes.push(i3.Exclusivities.SPECIFIC_USER);
|
|
580
|
-
if (coupon.exclusivityType.includes(i3.Exclusivities.ACTIVE_SUBSCRIBER) &&
|
|
581
|
-
user.isSubscriber &&
|
|
582
|
-
user.subscriptionPlan != '')
|
|
583
|
-
userTypes.push(i3.Exclusivities.ACTIVE_SUBSCRIBER);
|
|
584
|
-
if (user.isSubscriber &&
|
|
585
|
-
user.subscriptionPlan == '' &&
|
|
586
|
-
coupon.exclusivityType.includes(i3.Exclusivities.INACTIVE_SUBSCRIBER))
|
|
587
|
-
userTypes.push(i3.Exclusivities.INACTIVE_SUBSCRIBER);
|
|
588
|
-
if (coupon.exclusivityType.includes(i3.Exclusivities.NON_SUBSCRIBER) && !user.isSubscriber)
|
|
589
|
-
userTypes.push(i3.Exclusivities.NON_SUBSCRIBER);
|
|
590
|
-
return coupon.exclusivityType.some(function (r) { return userTypes.includes(r); });
|
|
390
|
+
AngularFirestoreModule.initializeApp = function (options, nameOrConfig) {
|
|
391
|
+
return {
|
|
392
|
+
ngModule: AngularFirestoreModule,
|
|
393
|
+
providers: [
|
|
394
|
+
{ provide: fire.FIREBASE_OPTIONS, useValue: options.firebase },
|
|
395
|
+
{ provide: fire.FIREBASE_APP_NAME, useValue: nameOrConfig },
|
|
396
|
+
{ provide: ES_CONFIG, useValue: options.elasticSearch },
|
|
397
|
+
],
|
|
398
|
+
};
|
|
591
399
|
};
|
|
592
|
-
|
|
593
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
594
|
-
var couponCategories, index, category, children;
|
|
595
|
-
return __generator(this, function (_c) {
|
|
596
|
-
switch (_c.label) {
|
|
597
|
-
case 0:
|
|
598
|
-
couponCategories = [];
|
|
599
|
-
index = 0;
|
|
600
|
-
_c.label = 1;
|
|
601
|
-
case 1:
|
|
602
|
-
if (!(index < productsCategories.length)) return [3 /*break*/, 5];
|
|
603
|
-
return [4 /*yield*/, this.categoryRepository.get({
|
|
604
|
-
id: productsCategories[index],
|
|
605
|
-
})];
|
|
606
|
-
case 2:
|
|
607
|
-
category = _c.sent();
|
|
608
|
-
if (!category) return [3 /*break*/, 4];
|
|
609
|
-
return [4 /*yield*/, this.categoryRepository.getChildren(parseInt(productsCategories[index]))];
|
|
610
|
-
case 3:
|
|
611
|
-
children = _c.sent();
|
|
612
|
-
couponCategories.push.apply(couponCategories, __spreadArray([category.id], __read(children.map(function (c) { return c.id.toString(); }))));
|
|
613
|
-
_c.label = 4;
|
|
614
|
-
case 4:
|
|
615
|
-
index++;
|
|
616
|
-
return [3 /*break*/, 1];
|
|
617
|
-
case 5: return [2 /*return*/, __spreadArray([], __read(new Set(couponCategories)))];
|
|
618
|
-
}
|
|
619
|
-
});
|
|
620
|
-
});
|
|
621
|
-
};
|
|
622
|
-
CouponService.prototype.getLineItensEligebleForDiscount = function (productsCategories, checkout) {
|
|
623
|
-
var _a;
|
|
624
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
625
|
-
var lineItensDiscount, couponCategories;
|
|
626
|
-
return __generator(this, function (_c) {
|
|
627
|
-
switch (_c.label) {
|
|
628
|
-
case 0:
|
|
629
|
-
lineItensDiscount = [];
|
|
630
|
-
return [4 /*yield*/, this.getCouponCategoriesId(productsCategories)];
|
|
631
|
-
case 1:
|
|
632
|
-
couponCategories = _c.sent();
|
|
633
|
-
if (productsCategories && productsCategories.length) {
|
|
634
|
-
lineItensDiscount = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.filter(function (i) {
|
|
635
|
-
var _a;
|
|
636
|
-
if ((_a = i.categories) === null || _a === void 0 ? void 0 : _a.length) {
|
|
637
|
-
return i.categories.some(function (c) { return couponCategories.some(function (cat) { return cat == c; }); });
|
|
638
|
-
}
|
|
639
|
-
return true;
|
|
640
|
-
});
|
|
641
|
-
}
|
|
642
|
-
else {
|
|
643
|
-
lineItensDiscount = checkout.lineItems;
|
|
644
|
-
}
|
|
645
|
-
return [2 /*return*/, lineItensDiscount];
|
|
646
|
-
}
|
|
647
|
-
});
|
|
648
|
-
});
|
|
649
|
-
};
|
|
650
|
-
CouponService.prototype.calcCheckoutSubtotal = function (lineItens, user, shop) {
|
|
651
|
-
return ((lineItens === null || lineItens === void 0 ? void 0 : lineItens.reduce(function (acc, curr) {
|
|
652
|
-
var _a, _b;
|
|
653
|
-
return (user === null || user === void 0 ? void 0 : user.isSubscriber) && ((_a = curr.price[shop]) === null || _a === void 0 ? void 0 : _a.subscriberPrice)
|
|
654
|
-
? acc + ((_b = curr.price[shop]) === null || _b === void 0 ? void 0 : _b.subscriberPrice) * curr.quantity
|
|
655
|
-
: acc + curr.pricePaid * curr.quantity;
|
|
656
|
-
}, 0)) || 0);
|
|
657
|
-
};
|
|
658
|
-
CouponService.prototype.getOrdersWithCoupon = function (coupon) {
|
|
659
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
660
|
-
return __generator(this, function (_c) {
|
|
661
|
-
switch (_c.label) {
|
|
662
|
-
case 0: return [4 /*yield*/, this.orderRepository
|
|
663
|
-
.find({
|
|
664
|
-
filters: {
|
|
665
|
-
coupon: { id: coupon.id },
|
|
666
|
-
payment: { status: 'paid' },
|
|
667
|
-
},
|
|
668
|
-
})
|
|
669
|
-
.then(function (result) { return result.data; })];
|
|
670
|
-
case 1: return [2 /*return*/, _c.sent()];
|
|
671
|
-
}
|
|
672
|
-
});
|
|
673
|
-
});
|
|
674
|
-
};
|
|
675
|
-
CouponService.prototype.countOrdersWithUser = function (orders, email) {
|
|
676
|
-
return orders.filter(function (o) { return o.user.email == email; }).length;
|
|
677
|
-
};
|
|
678
|
-
CouponService.prototype.getCouponUseLimits = function (coupon, checkoutType, user) {
|
|
679
|
-
var couponUseLimits;
|
|
680
|
-
if (checkoutType == i3.CheckoutTypes.ECOMMERCE || checkoutType == i3.CheckoutTypes.ALL) {
|
|
681
|
-
couponUseLimits = user && user.isSubscriber ? coupon.useLimits.subscriber : coupon.useLimits.non_subscriber;
|
|
682
|
-
}
|
|
683
|
-
else {
|
|
684
|
-
couponUseLimits = coupon.useLimits.subscription;
|
|
685
|
-
}
|
|
686
|
-
return couponUseLimits;
|
|
687
|
-
};
|
|
688
|
-
return CouponService;
|
|
400
|
+
return AngularFirestoreModule;
|
|
689
401
|
}());
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
i0__namespace.ɵɵ
|
|
693
|
-
|
|
402
|
+
AngularFirestoreModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
|
|
403
|
+
AngularFirestoreModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, imports: [fire.AngularFireModule, AngularElasticSeachModule] });
|
|
404
|
+
AngularFirestoreModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, providers: [
|
|
405
|
+
{
|
|
406
|
+
provide: 'BeautyProfileRepository',
|
|
407
|
+
useFactory: function (firestore, userRepository) {
|
|
408
|
+
return new i1.UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
|
|
409
|
+
},
|
|
410
|
+
deps: [i1$1.AngularFirestore, 'UserRepository'],
|
|
411
|
+
},
|
|
412
|
+
{
|
|
413
|
+
provide: 'Buy2WinRepository',
|
|
414
|
+
useFactory: function (firestore) {
|
|
415
|
+
return new i1.Buy2WinFirestoreRepository(firestore.firestore);
|
|
416
|
+
},
|
|
417
|
+
deps: [i1$1.AngularFirestore],
|
|
418
|
+
},
|
|
419
|
+
{
|
|
420
|
+
provide: i1.CategoryFirestoreRepository,
|
|
421
|
+
useFactory: function (firestore) {
|
|
422
|
+
return new i1.CategoryFirestoreRepository(firestore.firestore);
|
|
423
|
+
},
|
|
424
|
+
deps: [i1$1.AngularFirestore],
|
|
425
|
+
},
|
|
426
|
+
{
|
|
427
|
+
provide: 'CheckoutRepository',
|
|
428
|
+
useFactory: function (firestore) {
|
|
429
|
+
return new i1.CheckoutFirestoreRepository(firestore.firestore);
|
|
430
|
+
},
|
|
431
|
+
deps: [i1$1.AngularFirestore],
|
|
432
|
+
},
|
|
433
|
+
{
|
|
434
|
+
provide: 'CheckoutSubscriptionRepository',
|
|
435
|
+
useFactory: function (firestore) {
|
|
436
|
+
return new i1.CheckoutSubscriptionFirestoreRepository(firestore.firestore);
|
|
437
|
+
},
|
|
438
|
+
deps: [i1$1.AngularFirestore],
|
|
439
|
+
},
|
|
440
|
+
{
|
|
441
|
+
provide: 'CouponRepository',
|
|
442
|
+
useFactory: function (firestore) {
|
|
443
|
+
return new i1.CouponFirestoreRepository(firestore.firestore);
|
|
444
|
+
},
|
|
445
|
+
deps: [i1$1.AngularFirestore],
|
|
446
|
+
},
|
|
447
|
+
{
|
|
448
|
+
provide: 'CampaignHashtagRepository',
|
|
449
|
+
useFactory: function (firestore) {
|
|
450
|
+
return new i1.CampaignHashtagFirestoreRepository(firestore.firestore);
|
|
451
|
+
},
|
|
452
|
+
deps: [i1$1.AngularFirestore],
|
|
453
|
+
},
|
|
454
|
+
{
|
|
455
|
+
provide: 'CampaignDashboardRepository',
|
|
456
|
+
useFactory: function (firestore) {
|
|
457
|
+
return new i1.CampaignDashboardFirestoreRepository(firestore.firestore);
|
|
458
|
+
},
|
|
459
|
+
deps: [i1$1.AngularFirestore],
|
|
460
|
+
},
|
|
461
|
+
{
|
|
462
|
+
provide: 'EditionRepository',
|
|
463
|
+
useFactory: function (firestore, subscriptionRepository) {
|
|
464
|
+
return new i1.SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
|
|
465
|
+
},
|
|
466
|
+
deps: [i1$1.AngularFirestore, 'SubscriptionRepository'],
|
|
467
|
+
},
|
|
468
|
+
{
|
|
469
|
+
provide: 'HomeRepository',
|
|
470
|
+
useFactory: function (firestore) {
|
|
471
|
+
return new i1.HomeFirestoreRepository(firestore.firestore);
|
|
472
|
+
},
|
|
473
|
+
deps: [i1$1.AngularFirestore],
|
|
474
|
+
},
|
|
475
|
+
{
|
|
476
|
+
provide: 'LeadRepository',
|
|
477
|
+
useFactory: function (firestore) {
|
|
478
|
+
return new i1.LeadFirestoreRepository(firestore.firestore);
|
|
479
|
+
},
|
|
480
|
+
deps: [i1$1.AngularFirestore],
|
|
481
|
+
},
|
|
482
|
+
{
|
|
483
|
+
provide: 'LegacyOrderRepository',
|
|
484
|
+
useFactory: function (firestore) {
|
|
485
|
+
return new i1.LegacyOrderFirestoreRepository(firestore.firestore);
|
|
486
|
+
},
|
|
487
|
+
deps: [i1$1.AngularFirestore],
|
|
488
|
+
},
|
|
489
|
+
{
|
|
490
|
+
provide: 'ShopMenuRepository',
|
|
491
|
+
useFactory: function (firestore) {
|
|
492
|
+
return new i1.ShopMenuFirestoreRepository(firestore.firestore);
|
|
493
|
+
},
|
|
494
|
+
deps: [i1$1.AngularFirestore],
|
|
495
|
+
},
|
|
496
|
+
{
|
|
497
|
+
provide: 'OrderRepository',
|
|
498
|
+
useFactory: function (firestore) {
|
|
499
|
+
return new i1.OrderFirestoreRepository(firestore.firestore);
|
|
500
|
+
},
|
|
501
|
+
deps: [i1$1.AngularFirestore],
|
|
502
|
+
},
|
|
503
|
+
{
|
|
504
|
+
provide: 'PaymentRepository',
|
|
505
|
+
useFactory: function (firestore) {
|
|
506
|
+
return new i1.PaymentFirestoreRepository(firestore.firestore);
|
|
507
|
+
},
|
|
508
|
+
deps: [i1$1.AngularFirestore],
|
|
509
|
+
},
|
|
510
|
+
{
|
|
511
|
+
provide: i1.ProductFirestoreRepository,
|
|
512
|
+
useFactory: function (firestore) {
|
|
513
|
+
return new i1.ProductFirestoreRepository(firestore.firestore);
|
|
514
|
+
},
|
|
515
|
+
deps: [i1$1.AngularFirestore],
|
|
516
|
+
},
|
|
517
|
+
{
|
|
518
|
+
provide: 'ShopSettingsRepository',
|
|
519
|
+
useFactory: function (firestore) {
|
|
520
|
+
return new i1.ShopSettingsFirestoreRepository(firestore.firestore);
|
|
521
|
+
},
|
|
522
|
+
deps: [i1$1.AngularFirestore],
|
|
523
|
+
},
|
|
524
|
+
{
|
|
525
|
+
provide: 'SubscriptionPaymentRepository',
|
|
526
|
+
useFactory: function (firestore, subscriptionRepository) {
|
|
527
|
+
return new i1.SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
|
|
528
|
+
},
|
|
529
|
+
deps: [i1$1.AngularFirestore, 'SubscriptionRepository'],
|
|
530
|
+
},
|
|
531
|
+
{
|
|
532
|
+
provide: 'SubscriptionPlanRepository',
|
|
533
|
+
useFactory: function (firestore) {
|
|
534
|
+
return new i1.SubscriptionPlanFirestoreRepository(firestore.firestore);
|
|
535
|
+
},
|
|
536
|
+
deps: [i1$1.AngularFirestore],
|
|
537
|
+
},
|
|
538
|
+
{
|
|
539
|
+
provide: 'SubscriptionProductRepository',
|
|
540
|
+
useFactory: function (firestore) {
|
|
541
|
+
return new i1.SubscriptionProductFirestoreRepository(firestore.firestore);
|
|
542
|
+
},
|
|
543
|
+
deps: [i1$1.AngularFirestore],
|
|
544
|
+
},
|
|
545
|
+
{
|
|
546
|
+
provide: 'SubscriptionRepository',
|
|
547
|
+
useFactory: function (firestore) {
|
|
548
|
+
return new i1.SubscriptionFirestoreRepository(firestore.firestore);
|
|
549
|
+
},
|
|
550
|
+
deps: [i1$1.AngularFirestore],
|
|
551
|
+
},
|
|
552
|
+
{
|
|
553
|
+
provide: 'UserRepository',
|
|
554
|
+
useFactory: function (firestore) {
|
|
555
|
+
return new i1.UserFirestoreRepository(firestore.firestore);
|
|
556
|
+
},
|
|
557
|
+
deps: [i1$1.AngularFirestore],
|
|
558
|
+
},
|
|
559
|
+
{
|
|
560
|
+
provide: 'UserAddressRepository',
|
|
561
|
+
useFactory: function (firestore, userRepository) {
|
|
562
|
+
return new i1.UserAddressFirestoreRepository(firestore.firestore, userRepository);
|
|
563
|
+
},
|
|
564
|
+
deps: [i1$1.AngularFirestore, 'UserRepository'],
|
|
565
|
+
},
|
|
566
|
+
{
|
|
567
|
+
provide: 'UserPaymentMethodRepository',
|
|
568
|
+
useFactory: function (firestore, userRepository) {
|
|
569
|
+
return new i1.UserPaymentMethodFirestoreRepository(firestore.firestore, userRepository);
|
|
570
|
+
},
|
|
571
|
+
deps: [i1$1.AngularFirestore, 'UserRepository'],
|
|
572
|
+
},
|
|
573
|
+
{
|
|
574
|
+
provide: i1.ProductVariantFirestoreRepository,
|
|
575
|
+
useFactory: function (firestore, productRepository) {
|
|
576
|
+
return new i1.ProductVariantFirestoreRepository(firestore.firestore, productRepository);
|
|
577
|
+
},
|
|
578
|
+
deps: [i1$1.AngularFirestore, i1.ProductFirestoreRepository],
|
|
579
|
+
},
|
|
580
|
+
{
|
|
581
|
+
provide: i0.APP_INITIALIZER,
|
|
582
|
+
useFactory: function (firestore) { return function () { return firestore.firestore.settings({ ignoreUndefinedProperties: true }); }; },
|
|
583
|
+
deps: [i1$1.AngularFirestore],
|
|
584
|
+
multi: true,
|
|
585
|
+
},
|
|
586
|
+
], imports: [[fire.AngularFireModule, AngularElasticSeachModule]] });
|
|
587
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, decorators: [{
|
|
588
|
+
type: i0.NgModule,
|
|
694
589
|
args: [{
|
|
695
|
-
|
|
590
|
+
imports: [fire.AngularFireModule, AngularElasticSeachModule],
|
|
591
|
+
providers: [
|
|
592
|
+
{
|
|
593
|
+
provide: 'BeautyProfileRepository',
|
|
594
|
+
useFactory: function (firestore, userRepository) {
|
|
595
|
+
return new i1.UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
|
|
596
|
+
},
|
|
597
|
+
deps: [i1$1.AngularFirestore, 'UserRepository'],
|
|
598
|
+
},
|
|
599
|
+
{
|
|
600
|
+
provide: 'Buy2WinRepository',
|
|
601
|
+
useFactory: function (firestore) {
|
|
602
|
+
return new i1.Buy2WinFirestoreRepository(firestore.firestore);
|
|
603
|
+
},
|
|
604
|
+
deps: [i1$1.AngularFirestore],
|
|
605
|
+
},
|
|
606
|
+
{
|
|
607
|
+
provide: i1.CategoryFirestoreRepository,
|
|
608
|
+
useFactory: function (firestore) {
|
|
609
|
+
return new i1.CategoryFirestoreRepository(firestore.firestore);
|
|
610
|
+
},
|
|
611
|
+
deps: [i1$1.AngularFirestore],
|
|
612
|
+
},
|
|
613
|
+
{
|
|
614
|
+
provide: 'CheckoutRepository',
|
|
615
|
+
useFactory: function (firestore) {
|
|
616
|
+
return new i1.CheckoutFirestoreRepository(firestore.firestore);
|
|
617
|
+
},
|
|
618
|
+
deps: [i1$1.AngularFirestore],
|
|
619
|
+
},
|
|
620
|
+
{
|
|
621
|
+
provide: 'CheckoutSubscriptionRepository',
|
|
622
|
+
useFactory: function (firestore) {
|
|
623
|
+
return new i1.CheckoutSubscriptionFirestoreRepository(firestore.firestore);
|
|
624
|
+
},
|
|
625
|
+
deps: [i1$1.AngularFirestore],
|
|
626
|
+
},
|
|
627
|
+
{
|
|
628
|
+
provide: 'CouponRepository',
|
|
629
|
+
useFactory: function (firestore) {
|
|
630
|
+
return new i1.CouponFirestoreRepository(firestore.firestore);
|
|
631
|
+
},
|
|
632
|
+
deps: [i1$1.AngularFirestore],
|
|
633
|
+
},
|
|
634
|
+
{
|
|
635
|
+
provide: 'CampaignHashtagRepository',
|
|
636
|
+
useFactory: function (firestore) {
|
|
637
|
+
return new i1.CampaignHashtagFirestoreRepository(firestore.firestore);
|
|
638
|
+
},
|
|
639
|
+
deps: [i1$1.AngularFirestore],
|
|
640
|
+
},
|
|
641
|
+
{
|
|
642
|
+
provide: 'CampaignDashboardRepository',
|
|
643
|
+
useFactory: function (firestore) {
|
|
644
|
+
return new i1.CampaignDashboardFirestoreRepository(firestore.firestore);
|
|
645
|
+
},
|
|
646
|
+
deps: [i1$1.AngularFirestore],
|
|
647
|
+
},
|
|
648
|
+
{
|
|
649
|
+
provide: 'EditionRepository',
|
|
650
|
+
useFactory: function (firestore, subscriptionRepository) {
|
|
651
|
+
return new i1.SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
|
|
652
|
+
},
|
|
653
|
+
deps: [i1$1.AngularFirestore, 'SubscriptionRepository'],
|
|
654
|
+
},
|
|
655
|
+
{
|
|
656
|
+
provide: 'HomeRepository',
|
|
657
|
+
useFactory: function (firestore) {
|
|
658
|
+
return new i1.HomeFirestoreRepository(firestore.firestore);
|
|
659
|
+
},
|
|
660
|
+
deps: [i1$1.AngularFirestore],
|
|
661
|
+
},
|
|
662
|
+
{
|
|
663
|
+
provide: 'LeadRepository',
|
|
664
|
+
useFactory: function (firestore) {
|
|
665
|
+
return new i1.LeadFirestoreRepository(firestore.firestore);
|
|
666
|
+
},
|
|
667
|
+
deps: [i1$1.AngularFirestore],
|
|
668
|
+
},
|
|
669
|
+
{
|
|
670
|
+
provide: 'LegacyOrderRepository',
|
|
671
|
+
useFactory: function (firestore) {
|
|
672
|
+
return new i1.LegacyOrderFirestoreRepository(firestore.firestore);
|
|
673
|
+
},
|
|
674
|
+
deps: [i1$1.AngularFirestore],
|
|
675
|
+
},
|
|
676
|
+
{
|
|
677
|
+
provide: 'ShopMenuRepository',
|
|
678
|
+
useFactory: function (firestore) {
|
|
679
|
+
return new i1.ShopMenuFirestoreRepository(firestore.firestore);
|
|
680
|
+
},
|
|
681
|
+
deps: [i1$1.AngularFirestore],
|
|
682
|
+
},
|
|
683
|
+
{
|
|
684
|
+
provide: 'OrderRepository',
|
|
685
|
+
useFactory: function (firestore) {
|
|
686
|
+
return new i1.OrderFirestoreRepository(firestore.firestore);
|
|
687
|
+
},
|
|
688
|
+
deps: [i1$1.AngularFirestore],
|
|
689
|
+
},
|
|
690
|
+
{
|
|
691
|
+
provide: 'PaymentRepository',
|
|
692
|
+
useFactory: function (firestore) {
|
|
693
|
+
return new i1.PaymentFirestoreRepository(firestore.firestore);
|
|
694
|
+
},
|
|
695
|
+
deps: [i1$1.AngularFirestore],
|
|
696
|
+
},
|
|
697
|
+
{
|
|
698
|
+
provide: i1.ProductFirestoreRepository,
|
|
699
|
+
useFactory: function (firestore) {
|
|
700
|
+
return new i1.ProductFirestoreRepository(firestore.firestore);
|
|
701
|
+
},
|
|
702
|
+
deps: [i1$1.AngularFirestore],
|
|
703
|
+
},
|
|
704
|
+
{
|
|
705
|
+
provide: 'ShopSettingsRepository',
|
|
706
|
+
useFactory: function (firestore) {
|
|
707
|
+
return new i1.ShopSettingsFirestoreRepository(firestore.firestore);
|
|
708
|
+
},
|
|
709
|
+
deps: [i1$1.AngularFirestore],
|
|
710
|
+
},
|
|
711
|
+
{
|
|
712
|
+
provide: 'SubscriptionPaymentRepository',
|
|
713
|
+
useFactory: function (firestore, subscriptionRepository) {
|
|
714
|
+
return new i1.SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
|
|
715
|
+
},
|
|
716
|
+
deps: [i1$1.AngularFirestore, 'SubscriptionRepository'],
|
|
717
|
+
},
|
|
718
|
+
{
|
|
719
|
+
provide: 'SubscriptionPlanRepository',
|
|
720
|
+
useFactory: function (firestore) {
|
|
721
|
+
return new i1.SubscriptionPlanFirestoreRepository(firestore.firestore);
|
|
722
|
+
},
|
|
723
|
+
deps: [i1$1.AngularFirestore],
|
|
724
|
+
},
|
|
725
|
+
{
|
|
726
|
+
provide: 'SubscriptionProductRepository',
|
|
727
|
+
useFactory: function (firestore) {
|
|
728
|
+
return new i1.SubscriptionProductFirestoreRepository(firestore.firestore);
|
|
729
|
+
},
|
|
730
|
+
deps: [i1$1.AngularFirestore],
|
|
731
|
+
},
|
|
732
|
+
{
|
|
733
|
+
provide: 'SubscriptionRepository',
|
|
734
|
+
useFactory: function (firestore) {
|
|
735
|
+
return new i1.SubscriptionFirestoreRepository(firestore.firestore);
|
|
736
|
+
},
|
|
737
|
+
deps: [i1$1.AngularFirestore],
|
|
738
|
+
},
|
|
739
|
+
{
|
|
740
|
+
provide: 'UserRepository',
|
|
741
|
+
useFactory: function (firestore) {
|
|
742
|
+
return new i1.UserFirestoreRepository(firestore.firestore);
|
|
743
|
+
},
|
|
744
|
+
deps: [i1$1.AngularFirestore],
|
|
745
|
+
},
|
|
746
|
+
{
|
|
747
|
+
provide: 'UserAddressRepository',
|
|
748
|
+
useFactory: function (firestore, userRepository) {
|
|
749
|
+
return new i1.UserAddressFirestoreRepository(firestore.firestore, userRepository);
|
|
750
|
+
},
|
|
751
|
+
deps: [i1$1.AngularFirestore, 'UserRepository'],
|
|
752
|
+
},
|
|
753
|
+
{
|
|
754
|
+
provide: 'UserPaymentMethodRepository',
|
|
755
|
+
useFactory: function (firestore, userRepository) {
|
|
756
|
+
return new i1.UserPaymentMethodFirestoreRepository(firestore.firestore, userRepository);
|
|
757
|
+
},
|
|
758
|
+
deps: [i1$1.AngularFirestore, 'UserRepository'],
|
|
759
|
+
},
|
|
760
|
+
{
|
|
761
|
+
provide: i1.ProductVariantFirestoreRepository,
|
|
762
|
+
useFactory: function (firestore, productRepository) {
|
|
763
|
+
return new i1.ProductVariantFirestoreRepository(firestore.firestore, productRepository);
|
|
764
|
+
},
|
|
765
|
+
deps: [i1$1.AngularFirestore, i1.ProductFirestoreRepository],
|
|
766
|
+
},
|
|
767
|
+
{
|
|
768
|
+
provide: i0.APP_INITIALIZER,
|
|
769
|
+
useFactory: function (firestore) { return function () { return firestore.firestore.settings({ ignoreUndefinedProperties: true }); }; },
|
|
770
|
+
deps: [i1$1.AngularFirestore],
|
|
771
|
+
multi: true,
|
|
772
|
+
},
|
|
773
|
+
],
|
|
696
774
|
}]
|
|
697
|
-
}]
|
|
698
|
-
return [{ type: undefined, decorators: [{
|
|
699
|
-
type: i0.Inject,
|
|
700
|
-
args: ['CouponRepository']
|
|
701
|
-
}] }, { type: i3__namespace.Shops, decorators: [{
|
|
702
|
-
type: i0.Inject,
|
|
703
|
-
args: [DEFAULT_SHOP]
|
|
704
|
-
}] }, { type: undefined, decorators: [{
|
|
705
|
-
type: i0.Inject,
|
|
706
|
-
args: ['OrderRepository']
|
|
707
|
-
}] }, { type: undefined, decorators: [{
|
|
708
|
-
type: i0.Inject,
|
|
709
|
-
args: ['CategoryRepository']
|
|
710
|
-
}] }];
|
|
711
|
-
} });
|
|
775
|
+
}] });
|
|
712
776
|
|
|
713
|
-
var
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
777
|
+
var BACKEND_URL = 'BACKEND_URL';
|
|
778
|
+
|
|
779
|
+
var CATEGORY_STRUCTURE = 'CATEGORY_STRUCTURE';
|
|
780
|
+
|
|
781
|
+
var DEFAULT_SHOP = 'DEFAULT_SHOP';
|
|
782
|
+
|
|
783
|
+
var HASURA_OPTIONS = 'HASURA_OPTIONS';
|
|
784
|
+
|
|
785
|
+
var AngularHasuraGraphQLModule = /** @class */ (function () {
|
|
786
|
+
function AngularHasuraGraphQLModule() {
|
|
720
787
|
}
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
};
|
|
727
|
-
CheckoutService.prototype.getUserByCheckout = function (checkoutId) {
|
|
728
|
-
var _this = this;
|
|
729
|
-
return rxjs.from(this.checkoutRepository.get({ id: checkoutId })).pipe(operators.concatMap(function (checkout) { var _a; return ((_a = checkout === null || checkout === void 0 ? void 0 : checkout.user) === null || _a === void 0 ? void 0 : _a.id) ? rxjs.of(checkout.user) : rxjs.from(_this.userRepository.get({ id: checkout.user.id })); }), operators.concatMap(function (user) { return rxjs.of(user) || rxjs.throwError(function () { return new i3.NotFoundError('User is not found'); }); }));
|
|
730
|
-
};
|
|
731
|
-
CheckoutService.prototype.updateCheckoutLineItems = function (checkout) {
|
|
732
|
-
return rxjs.from(this.checkoutRepository.update(i3.Checkout.toInstance({ id: checkout.id, lineItems: checkout.lineItems })));
|
|
733
|
-
};
|
|
734
|
-
CheckoutService.prototype.updateCheckoutUser = function (checkout) {
|
|
735
|
-
return rxjs.from(this.checkoutRepository.update(i3.Checkout.toInstance({ id: checkout.id, user: checkout.user })));
|
|
736
|
-
};
|
|
737
|
-
CheckoutService.prototype.clearCheckoutFromSession = function () {
|
|
738
|
-
cookie__default["default"].remove('checkoutId');
|
|
739
|
-
return rxjs.of();
|
|
740
|
-
};
|
|
741
|
-
CheckoutService.prototype.calcDiscount = function (coupon) {
|
|
742
|
-
var _this = this;
|
|
743
|
-
return this.getCheckout().pipe(operators.concatMap(function (checkout) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_b) {
|
|
744
|
-
switch (_b.label) {
|
|
745
|
-
case 0: return [4 /*yield*/, this.couponService.calcDiscountShopping(coupon, checkout)];
|
|
746
|
-
case 1: return [2 /*return*/, _b.sent()];
|
|
747
|
-
}
|
|
748
|
-
}); }); }));
|
|
749
|
-
};
|
|
750
|
-
CheckoutService.prototype.checkCoupon = function (nickname, checkoutType) {
|
|
751
|
-
var _this = this;
|
|
752
|
-
return this.getCheckout().pipe(operators.concatMap(function (checkout) { return _this.couponService.checkCoupon(nickname, i3.CheckoutTypes.ECOMMERCE, checkout, null).pipe(); }));
|
|
753
|
-
};
|
|
754
|
-
CheckoutService.prototype.createCheckout = function (checkoutData) {
|
|
755
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
756
|
-
var checkout;
|
|
757
|
-
return __generator(this, function (_b) {
|
|
758
|
-
switch (_b.label) {
|
|
759
|
-
case 0: return [4 /*yield*/, this.checkoutRepository.create(Object.assign(Object.assign({ createdAt: new Date() }, i3.Checkout.toInstance(i3.pick(checkoutData, ['user', 'shop'])).toPlain()), { shop: (checkoutData === null || checkoutData === void 0 ? void 0 : checkoutData.shop) || this.defaultShop }))];
|
|
760
|
-
case 1:
|
|
761
|
-
checkout = _b.sent();
|
|
762
|
-
cookie__default["default"].set('checkoutId', checkout.id);
|
|
763
|
-
return [2 /*return*/, checkout];
|
|
764
|
-
}
|
|
765
|
-
});
|
|
766
|
-
});
|
|
788
|
+
AngularHasuraGraphQLModule.initializeApp = function (options) {
|
|
789
|
+
return {
|
|
790
|
+
ngModule: AngularHasuraGraphQLModule,
|
|
791
|
+
providers: [{ provide: HASURA_OPTIONS, useValue: options }],
|
|
792
|
+
};
|
|
767
793
|
};
|
|
768
|
-
return
|
|
794
|
+
return AngularHasuraGraphQLModule;
|
|
769
795
|
}());
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
i0__namespace.ɵɵ
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
796
|
+
AngularHasuraGraphQLModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularHasuraGraphQLModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
|
|
797
|
+
AngularHasuraGraphQLModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularHasuraGraphQLModule });
|
|
798
|
+
AngularHasuraGraphQLModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularHasuraGraphQLModule, providers: [
|
|
799
|
+
{
|
|
800
|
+
provide: 'CategoryRepository',
|
|
801
|
+
useExisting: i1.CategoryHasuraGraphQLRepository,
|
|
802
|
+
},
|
|
803
|
+
{
|
|
804
|
+
provide: i1.CategoryHasuraGraphQLRepository,
|
|
805
|
+
useFactory: function (options, productRepository, categoryFilterRepository) {
|
|
806
|
+
return new i1.CategoryHasuraGraphQLRepository(options.endpoint, options.credentials, productRepository, categoryFilterRepository);
|
|
807
|
+
},
|
|
808
|
+
deps: [HASURA_OPTIONS, i1.ProductHasuraGraphQLRepository, i1.CategoryFilterHasuraGraphQLRepository],
|
|
809
|
+
},
|
|
810
|
+
{
|
|
811
|
+
provide: 'ProductRepository',
|
|
812
|
+
useExisting: i1.ProductHasuraGraphQLRepository,
|
|
813
|
+
},
|
|
814
|
+
{
|
|
815
|
+
provide: i1.ProductHasuraGraphQLRepository,
|
|
816
|
+
useFactory: function (options) {
|
|
817
|
+
return new i1.ProductHasuraGraphQLRepository(options.endpoint, options.credentials);
|
|
818
|
+
},
|
|
819
|
+
deps: [HASURA_OPTIONS],
|
|
820
|
+
},
|
|
821
|
+
{
|
|
822
|
+
provide: 'VariantRepository',
|
|
823
|
+
useExisting: i1.VariantHasuraGraphQLRepository,
|
|
824
|
+
},
|
|
825
|
+
{
|
|
826
|
+
provide: i1.VariantHasuraGraphQLRepository,
|
|
827
|
+
useFactory: function (options) {
|
|
828
|
+
return new i1.VariantHasuraGraphQLRepository(options.endpoint, options.credentials);
|
|
829
|
+
},
|
|
830
|
+
deps: [HASURA_OPTIONS],
|
|
831
|
+
},
|
|
832
|
+
{
|
|
833
|
+
provide: 'CategoryFilterRepository',
|
|
834
|
+
useExisting: i1.CategoryFilterHasuraGraphQLRepository,
|
|
835
|
+
},
|
|
836
|
+
{
|
|
837
|
+
provide: i1.CategoryFilterHasuraGraphQLRepository,
|
|
838
|
+
useFactory: function (options) {
|
|
839
|
+
return new i1.CategoryFilterHasuraGraphQLRepository(options.endpoint, options.credentials);
|
|
840
|
+
},
|
|
841
|
+
deps: [HASURA_OPTIONS],
|
|
842
|
+
},
|
|
843
|
+
{
|
|
844
|
+
provide: 'FilterOptionRepository',
|
|
845
|
+
useExisting: i1.FilterOptionHasuraGraphQLRepository,
|
|
846
|
+
},
|
|
847
|
+
{
|
|
848
|
+
provide: i1.FilterOptionHasuraGraphQLRepository,
|
|
849
|
+
useFactory: function (options) {
|
|
850
|
+
return new i1.FilterOptionHasuraGraphQLRepository(options.endpoint, options.credentials);
|
|
851
|
+
},
|
|
852
|
+
deps: [HASURA_OPTIONS],
|
|
853
|
+
},
|
|
854
|
+
{
|
|
855
|
+
provide: 'FilterRepository',
|
|
856
|
+
useExisting: i1.FilterHasuraGraphQLRepository,
|
|
857
|
+
},
|
|
858
|
+
{
|
|
859
|
+
provide: i1.FilterHasuraGraphQLRepository,
|
|
860
|
+
useFactory: function (options, filterOptionRepository, categoryFilterRepository) {
|
|
861
|
+
return new i1.FilterHasuraGraphQLRepository(options.endpoint, options.credentials, filterOptionRepository, categoryFilterRepository);
|
|
862
|
+
},
|
|
863
|
+
deps: [HASURA_OPTIONS, i1.FilterOptionHasuraGraphQLRepository, i1.CategoryFilterHasuraGraphQLRepository],
|
|
864
|
+
},
|
|
865
|
+
{
|
|
866
|
+
provide: i1.CategoryCollectionChildrenHasuraGraphQLRepository,
|
|
867
|
+
useFactory: function (options) { return new i1.CategoryCollectionChildrenHasuraGraphQLRepository(options.endpoint, options.credentials); },
|
|
868
|
+
},
|
|
869
|
+
{
|
|
870
|
+
provide: 'CategoryCollectionChildrenRepository',
|
|
871
|
+
useExisting: i1.CategoryCollectionChildrenHasuraGraphQLRepository,
|
|
872
|
+
},
|
|
873
|
+
] });
|
|
874
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularHasuraGraphQLModule, decorators: [{
|
|
875
|
+
type: i0.NgModule,
|
|
876
|
+
args: [{
|
|
877
|
+
providers: [
|
|
878
|
+
{
|
|
879
|
+
provide: 'CategoryRepository',
|
|
880
|
+
useExisting: i1.CategoryHasuraGraphQLRepository,
|
|
881
|
+
},
|
|
882
|
+
{
|
|
883
|
+
provide: i1.CategoryHasuraGraphQLRepository,
|
|
884
|
+
useFactory: function (options, productRepository, categoryFilterRepository) {
|
|
885
|
+
return new i1.CategoryHasuraGraphQLRepository(options.endpoint, options.credentials, productRepository, categoryFilterRepository);
|
|
886
|
+
},
|
|
887
|
+
deps: [HASURA_OPTIONS, i1.ProductHasuraGraphQLRepository, i1.CategoryFilterHasuraGraphQLRepository],
|
|
888
|
+
},
|
|
889
|
+
{
|
|
890
|
+
provide: 'ProductRepository',
|
|
891
|
+
useExisting: i1.ProductHasuraGraphQLRepository,
|
|
892
|
+
},
|
|
893
|
+
{
|
|
894
|
+
provide: i1.ProductHasuraGraphQLRepository,
|
|
895
|
+
useFactory: function (options) {
|
|
896
|
+
return new i1.ProductHasuraGraphQLRepository(options.endpoint, options.credentials);
|
|
897
|
+
},
|
|
898
|
+
deps: [HASURA_OPTIONS],
|
|
899
|
+
},
|
|
900
|
+
{
|
|
901
|
+
provide: 'VariantRepository',
|
|
902
|
+
useExisting: i1.VariantHasuraGraphQLRepository,
|
|
903
|
+
},
|
|
904
|
+
{
|
|
905
|
+
provide: i1.VariantHasuraGraphQLRepository,
|
|
906
|
+
useFactory: function (options) {
|
|
907
|
+
return new i1.VariantHasuraGraphQLRepository(options.endpoint, options.credentials);
|
|
908
|
+
},
|
|
909
|
+
deps: [HASURA_OPTIONS],
|
|
910
|
+
},
|
|
911
|
+
{
|
|
912
|
+
provide: 'CategoryFilterRepository',
|
|
913
|
+
useExisting: i1.CategoryFilterHasuraGraphQLRepository,
|
|
914
|
+
},
|
|
915
|
+
{
|
|
916
|
+
provide: i1.CategoryFilterHasuraGraphQLRepository,
|
|
917
|
+
useFactory: function (options) {
|
|
918
|
+
return new i1.CategoryFilterHasuraGraphQLRepository(options.endpoint, options.credentials);
|
|
919
|
+
},
|
|
920
|
+
deps: [HASURA_OPTIONS],
|
|
921
|
+
},
|
|
922
|
+
{
|
|
923
|
+
provide: 'FilterOptionRepository',
|
|
924
|
+
useExisting: i1.FilterOptionHasuraGraphQLRepository,
|
|
925
|
+
},
|
|
926
|
+
{
|
|
927
|
+
provide: i1.FilterOptionHasuraGraphQLRepository,
|
|
928
|
+
useFactory: function (options) {
|
|
929
|
+
return new i1.FilterOptionHasuraGraphQLRepository(options.endpoint, options.credentials);
|
|
930
|
+
},
|
|
931
|
+
deps: [HASURA_OPTIONS],
|
|
932
|
+
},
|
|
933
|
+
{
|
|
934
|
+
provide: 'FilterRepository',
|
|
935
|
+
useExisting: i1.FilterHasuraGraphQLRepository,
|
|
936
|
+
},
|
|
937
|
+
{
|
|
938
|
+
provide: i1.FilterHasuraGraphQLRepository,
|
|
939
|
+
useFactory: function (options, filterOptionRepository, categoryFilterRepository) {
|
|
940
|
+
return new i1.FilterHasuraGraphQLRepository(options.endpoint, options.credentials, filterOptionRepository, categoryFilterRepository);
|
|
941
|
+
},
|
|
942
|
+
deps: [HASURA_OPTIONS, i1.FilterOptionHasuraGraphQLRepository, i1.CategoryFilterHasuraGraphQLRepository],
|
|
943
|
+
},
|
|
944
|
+
{
|
|
945
|
+
provide: i1.CategoryCollectionChildrenHasuraGraphQLRepository,
|
|
946
|
+
useFactory: function (options) { return new i1.CategoryCollectionChildrenHasuraGraphQLRepository(options.endpoint, options.credentials); },
|
|
947
|
+
},
|
|
948
|
+
{
|
|
949
|
+
provide: 'CategoryCollectionChildrenRepository',
|
|
950
|
+
useExisting: i1.CategoryCollectionChildrenHasuraGraphQLRepository,
|
|
951
|
+
},
|
|
952
|
+
],
|
|
953
|
+
}]
|
|
954
|
+
}] });
|
|
955
|
+
|
|
956
|
+
var AuthService = /** @class */ (function () {
|
|
957
|
+
function AuthService(angularFireAuth, userRepository) {
|
|
958
|
+
this.angularFireAuth = angularFireAuth;
|
|
959
|
+
this.userRepository = userRepository;
|
|
883
960
|
}
|
|
884
|
-
|
|
885
|
-
var
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
})
|
|
961
|
+
AuthService.prototype.getAuthstate = function () {
|
|
962
|
+
var observables = [
|
|
963
|
+
this.angularFireAuth.authState.pipe(operators.catchError(function () { return rxjs.of(null); })),
|
|
964
|
+
this.getUser().pipe(operators.catchError(function () { return rxjs.of(null); })),
|
|
965
|
+
];
|
|
966
|
+
return rxjs.combineLatest(observables).pipe(operators.map(function (_a) {
|
|
967
|
+
var _b = __read(_a, 2), fireUser = _b[0], user = _b[1];
|
|
968
|
+
return {
|
|
969
|
+
user: user,
|
|
970
|
+
isAnonymous: fireUser === null || fireUser === void 0 ? void 0 : fireUser.isAnonymous,
|
|
971
|
+
};
|
|
972
|
+
}));
|
|
896
973
|
};
|
|
897
|
-
|
|
974
|
+
AuthService.prototype.getUser = function () {
|
|
898
975
|
var _this = this;
|
|
899
|
-
return this.
|
|
900
|
-
var _a;
|
|
901
|
-
var checkoutItem = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.find(function (lineItem) { return lineItem.id === item.id; });
|
|
902
|
-
if (!i3.isNil(checkoutItem))
|
|
903
|
-
checkoutItem.quantity -= checkoutItem.quantity > 1 ? 1 : 0;
|
|
904
|
-
return checkout;
|
|
905
|
-
}), operators.concatMap(function (checkout) { return _this.checkoutService.updateCheckoutLineItems(checkout); }), operators.map(function (checkout) { return _this.generateCartObject(checkout.lineItems); }), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
|
|
976
|
+
return this.getFireUser().pipe(operators.map(function (user) { return user === null || user === void 0 ? void 0 : user.uid; }), operators.mergeMap(function (id) { return (id ? rxjs.from(_this.userRepository.get({ id: id })).pipe(operators.catchError(function () { return rxjs.of(null); })) : rxjs.of(null)); }));
|
|
906
977
|
};
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
this.buildCartFromCheckout(checkout).subscribe(function (cart) { return _this.cartSubject.next(cart); });
|
|
910
|
-
return this.cartSubject;
|
|
978
|
+
AuthService.prototype.getTokenId = function () {
|
|
979
|
+
return this.angularFireAuth.idToken;
|
|
911
980
|
};
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
*/
|
|
915
|
-
CartService.prototype.getVariantPriceDiscount = function (item) {
|
|
916
|
-
return this.authService.getUser().pipe(operators.concatMap(function (user) { return rxjs.iif(function () { return user.isSubscriber && !!item.price.subscriberPrice; }, rxjs.of(item.price.subscriberPrice), rxjs.of(item.price.price)); }), operators.catchError(function () { return rxjs.of(item.price.price); }));
|
|
981
|
+
AuthService.prototype.getFireUser = function () {
|
|
982
|
+
return this.angularFireAuth.user.pipe(operators.catchError(function () { return rxjs.of(null); }));
|
|
917
983
|
};
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
984
|
+
return AuthService;
|
|
985
|
+
}());
|
|
986
|
+
AuthService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AuthService, deps: [{ token: i1__namespace.AngularFireAuth }, { token: 'UserRepository' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
987
|
+
AuthService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AuthService });
|
|
988
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AuthService, decorators: [{
|
|
989
|
+
type: i0.Injectable
|
|
990
|
+
}], ctorParameters: function () {
|
|
991
|
+
return [{ type: i1__namespace.AngularFireAuth }, { type: undefined, decorators: [{
|
|
992
|
+
type: i0.Inject,
|
|
993
|
+
args: ['UserRepository']
|
|
994
|
+
}] }];
|
|
995
|
+
} });
|
|
996
|
+
|
|
997
|
+
var CouponService = /** @class */ (function () {
|
|
998
|
+
function CouponService(couponRepository, defaultShop, orderRepository, categoryRepository) {
|
|
999
|
+
this.couponRepository = couponRepository;
|
|
1000
|
+
this.defaultShop = defaultShop;
|
|
1001
|
+
this.orderRepository = orderRepository;
|
|
1002
|
+
this.categoryRepository = categoryRepository;
|
|
1003
|
+
this.emailIsFromCollaborator = function (userEmail) { return !!(userEmail === null || userEmail === void 0 ? void 0 : userEmail.match(/@b4a.com.br/g)); };
|
|
1004
|
+
}
|
|
1005
|
+
CouponService.prototype.checkCoupon = function (nickname, checkoutType, checkout, plan) {
|
|
928
1006
|
var _this = this;
|
|
929
|
-
return
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
1007
|
+
return rxjs.from(this.couponRepository
|
|
1008
|
+
.find({
|
|
1009
|
+
filters: {
|
|
1010
|
+
nickname: { operator: i1.Where.EQUALS, value: nickname },
|
|
1011
|
+
active: { operator: i1.Where.EQUALS, value: true },
|
|
1012
|
+
},
|
|
1013
|
+
})
|
|
1014
|
+
.then(function (result) { return result.data[0]; })).pipe(operators.concatMap(function (coupon) { return _this.couponValidation(coupon, checkoutType); }), operators.concatMap(function (couponValid) { return _this.couponRulesValidation(couponValid, checkoutType, checkout, plan); }), operators.map(function (couponValidated) { return couponValidated; }));
|
|
1015
|
+
};
|
|
1016
|
+
CouponService.prototype.couponValidation = function (coupon, checkoutType) {
|
|
1017
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1018
|
+
var isInShop, isCheckoutType;
|
|
1019
|
+
return __generator(this, function (_c) {
|
|
1020
|
+
if (!coupon)
|
|
1021
|
+
throw 'Cupom inválido.';
|
|
1022
|
+
if ((coupon === null || coupon === void 0 ? void 0 : coupon.beginAt) && (coupon === null || coupon === void 0 ? void 0 : coupon.beginAt.getTime()) > new Date().getTime())
|
|
1023
|
+
throw 'Cupom inválido.';
|
|
1024
|
+
if ((coupon === null || coupon === void 0 ? void 0 : coupon.expiresIn) && (coupon === null || coupon === void 0 ? void 0 : coupon.expiresIn.getTime()) < new Date().getTime())
|
|
1025
|
+
throw 'Cupom expirado.';
|
|
1026
|
+
isInShop = coupon.shopAvailability === i1.Shops.ALL || coupon.shopAvailability === this.defaultShop;
|
|
1027
|
+
if (!isInShop)
|
|
1028
|
+
throw 'Cupom inválido para loja.';
|
|
1029
|
+
isCheckoutType = coupon.checkoutType === i1.CheckoutTypes.ALL || coupon.checkoutType === checkoutType;
|
|
1030
|
+
if (!isCheckoutType)
|
|
1031
|
+
throw 'Cupom inválido. Erro de checkout.';
|
|
1032
|
+
return [2 /*return*/, coupon];
|
|
1033
|
+
});
|
|
1034
|
+
});
|
|
1035
|
+
};
|
|
1036
|
+
CouponService.prototype.couponRulesValidation = function (coupon, checkoutType, checkout, plan) {
|
|
1037
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1038
|
+
var validUser, orders, ordersWithUser, couponUseLimits, hasProductCategories, hasMinSubTotal;
|
|
1039
|
+
return __generator(this, function (_c) {
|
|
1040
|
+
switch (_c.label) {
|
|
934
1041
|
case 0:
|
|
935
|
-
|
|
936
|
-
.
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
if (!
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
case 0: return [4 /*yield*/, this.buildLineItem({ checkout: checkout, item: item })];
|
|
945
|
-
case 1: return [2 /*return*/, (_h.sent()).lineItem];
|
|
946
|
-
}
|
|
947
|
-
}); }); }))];
|
|
1042
|
+
if (checkoutType == i1.CheckoutTypes.SUBSCRIPTION) {
|
|
1043
|
+
if (coupon.plan && coupon.plan.toUpperCase() !== plan.toUpperCase())
|
|
1044
|
+
throw 'Cupom inválido para sua assinatura.';
|
|
1045
|
+
return [2 /*return*/, coupon];
|
|
1046
|
+
}
|
|
1047
|
+
validUser = this.coupomUserValidation(coupon, checkout === null || checkout === void 0 ? void 0 : checkout.user);
|
|
1048
|
+
if (!validUser)
|
|
1049
|
+
throw 'Usuário não elegível.';
|
|
1050
|
+
return [4 /*yield*/, this.getOrdersWithCoupon(coupon)];
|
|
948
1051
|
case 1:
|
|
949
|
-
|
|
950
|
-
|
|
1052
|
+
orders = _c.sent();
|
|
1053
|
+
ordersWithUser = this.countOrdersWithUser(orders, checkout.user.email);
|
|
1054
|
+
couponUseLimits = this.getCouponUseLimits(coupon, checkoutType, checkout.user);
|
|
1055
|
+
if (couponUseLimits.limitedPerUser && ordersWithUser > 0)
|
|
1056
|
+
throw 'Limite de uso por usuário atingido.';
|
|
1057
|
+
if (!couponUseLimits.unlimited && couponUseLimits.total && orders.length >= couponUseLimits.total)
|
|
1058
|
+
throw 'Limite de uso atingido.';
|
|
1059
|
+
return [4 /*yield*/, this.hasProductCategories(coupon, checkout)];
|
|
951
1060
|
case 2:
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
1061
|
+
hasProductCategories = _c.sent();
|
|
1062
|
+
if (!hasProductCategories)
|
|
1063
|
+
throw 'Seu carrinho não possui produtos elegíveis para desconto.';
|
|
1064
|
+
return [4 /*yield*/, this.hasMinSubTotal(coupon, checkout)];
|
|
1065
|
+
case 3:
|
|
1066
|
+
hasMinSubTotal = _c.sent();
|
|
1067
|
+
if (!hasMinSubTotal)
|
|
1068
|
+
throw "Valor m\u00EDnimo de " + Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' }).format(coupon.minSubTotalValue) + " n\u00E3o atingido";
|
|
1069
|
+
return [2 /*return*/, coupon];
|
|
956
1070
|
}
|
|
957
1071
|
});
|
|
958
|
-
});
|
|
1072
|
+
});
|
|
959
1073
|
};
|
|
960
|
-
|
|
961
|
-
var
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
1074
|
+
CouponService.prototype.calcDiscountSubscription = function (coupon, checkout) {
|
|
1075
|
+
var discount = 0;
|
|
1076
|
+
if (coupon.discount.subscription.type == i1.CouponTypes.ABSOLUTE)
|
|
1077
|
+
discount = coupon.discount.subscription.value;
|
|
1078
|
+
else
|
|
1079
|
+
discount = checkout.subscriptionPlan.recurrencePrice * (coupon.discount.subscription.value / 100);
|
|
1080
|
+
return rxjs.of(discount);
|
|
966
1081
|
};
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
1082
|
+
CouponService.prototype.calcDiscountShopping = function (coupon, checkout) {
|
|
1083
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1084
|
+
var discount;
|
|
1085
|
+
return __generator(this, function (_c) {
|
|
1086
|
+
switch (_c.label) {
|
|
1087
|
+
case 0:
|
|
1088
|
+
discount = 0;
|
|
1089
|
+
if (!(checkout.user.isSubscriber && coupon.discount.subscriber.value)) return [3 /*break*/, 2];
|
|
1090
|
+
return [4 /*yield*/, this.calcDiscountByType(coupon.discount.subscriber.type, coupon.discount.subscriber.value, coupon.productsCategories, checkout)];
|
|
1091
|
+
case 1:
|
|
1092
|
+
discount = _c.sent();
|
|
1093
|
+
return [3 /*break*/, 4];
|
|
1094
|
+
case 2: return [4 /*yield*/, this.calcDiscountByType(coupon.discount.non_subscriber.type, coupon.discount.non_subscriber.value, coupon.productsCategories, checkout)];
|
|
1095
|
+
case 3:
|
|
1096
|
+
discount = _c.sent();
|
|
1097
|
+
_c.label = 4;
|
|
1098
|
+
case 4: return [2 /*return*/, discount];
|
|
1099
|
+
}
|
|
1100
|
+
});
|
|
1101
|
+
});
|
|
970
1102
|
};
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
1103
|
+
CouponService.prototype.calcDiscountByType = function (type, value, categories, checkout) {
|
|
1104
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1105
|
+
var discount, lineItensDiscount, subTotal;
|
|
1106
|
+
return __generator(this, function (_c) {
|
|
1107
|
+
switch (_c.label) {
|
|
1108
|
+
case 0:
|
|
1109
|
+
discount = 0;
|
|
1110
|
+
return [4 /*yield*/, this.getLineItensEligebleForDiscount(categories, checkout)];
|
|
1111
|
+
case 1:
|
|
1112
|
+
lineItensDiscount = _c.sent();
|
|
1113
|
+
subTotal = this.calcCheckoutSubtotal(lineItensDiscount, checkout.user, checkout.shop);
|
|
1114
|
+
if (type == i1.CouponTypes.ABSOLUTE) {
|
|
1115
|
+
discount = value > subTotal ? subTotal : value;
|
|
1116
|
+
}
|
|
1117
|
+
else {
|
|
1118
|
+
discount = subTotal * (value / 100);
|
|
1119
|
+
}
|
|
1120
|
+
return [2 /*return*/, discount];
|
|
1121
|
+
}
|
|
1122
|
+
});
|
|
1123
|
+
});
|
|
974
1124
|
};
|
|
975
|
-
|
|
1125
|
+
CouponService.prototype.hasMinSubTotal = function (coupon, checkout) {
|
|
976
1126
|
return __awaiter(this, void 0, void 0, function () {
|
|
977
|
-
var
|
|
978
|
-
return __generator(this, function (
|
|
979
|
-
switch (
|
|
1127
|
+
var lineItensDiscount, subTotal;
|
|
1128
|
+
return __generator(this, function (_c) {
|
|
1129
|
+
switch (_c.label) {
|
|
980
1130
|
case 0:
|
|
981
|
-
|
|
982
|
-
|
|
1131
|
+
if (!coupon.minSubTotalValue)
|
|
1132
|
+
return [2 /*return*/, true];
|
|
1133
|
+
return [4 /*yield*/, this.getLineItensEligebleForDiscount(coupon.productsCategories, checkout)];
|
|
983
1134
|
case 1:
|
|
984
|
-
|
|
985
|
-
|
|
1135
|
+
lineItensDiscount = _c.sent();
|
|
1136
|
+
subTotal = this.calcCheckoutSubtotal(lineItensDiscount, checkout.user, checkout.shop);
|
|
1137
|
+
if (coupon.minSubTotalValue <= subTotal)
|
|
1138
|
+
return [2 /*return*/, true];
|
|
1139
|
+
return [2 /*return*/, false];
|
|
1140
|
+
}
|
|
1141
|
+
});
|
|
1142
|
+
});
|
|
1143
|
+
};
|
|
1144
|
+
CouponService.prototype.hasProductCategories = function (coupon, checkout) {
|
|
1145
|
+
var _a;
|
|
1146
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1147
|
+
var couponCategories, hasCategories;
|
|
1148
|
+
return __generator(this, function (_c) {
|
|
1149
|
+
switch (_c.label) {
|
|
1150
|
+
case 0:
|
|
1151
|
+
if (!coupon.productsCategories || !coupon.productsCategories.length) {
|
|
1152
|
+
return [2 /*return*/, true];
|
|
1153
|
+
}
|
|
1154
|
+
return [4 /*yield*/, this.getCouponCategoriesId(coupon.productsCategories)];
|
|
1155
|
+
case 1:
|
|
1156
|
+
couponCategories = _c.sent();
|
|
1157
|
+
hasCategories = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.filter(function (i) {
|
|
1158
|
+
var _a;
|
|
1159
|
+
if (!i.categories || !((_a = i.categories) === null || _a === void 0 ? void 0 : _a.length))
|
|
1160
|
+
return true;
|
|
1161
|
+
return i.categories.some(function (c) { return couponCategories.some(function (cat) { return cat == c; }); });
|
|
1162
|
+
});
|
|
1163
|
+
return [2 /*return*/, hasCategories.length ? true : false];
|
|
1164
|
+
}
|
|
1165
|
+
});
|
|
1166
|
+
});
|
|
1167
|
+
};
|
|
1168
|
+
CouponService.prototype.coupomUserValidation = function (coupon, user) {
|
|
1169
|
+
if (!user || coupon.exclusivityType.includes(i1.Exclusivities.ALL_USERS))
|
|
1170
|
+
return true;
|
|
1171
|
+
var userTypes = [];
|
|
1172
|
+
if (coupon.exclusivityType.includes(i1.Exclusivities.COLLABORATORS) && this.emailIsFromCollaborator(user.email))
|
|
1173
|
+
userTypes.push(i1.Exclusivities.COLLABORATORS);
|
|
1174
|
+
if (coupon.exclusivityType.includes(i1.Exclusivities.SPECIFIC_USER) && coupon.userExclusiveEmail.includes(user.email))
|
|
1175
|
+
userTypes.push(i1.Exclusivities.SPECIFIC_USER);
|
|
1176
|
+
if (coupon.exclusivityType.includes(i1.Exclusivities.ACTIVE_SUBSCRIBER) &&
|
|
1177
|
+
user.isSubscriber &&
|
|
1178
|
+
user.subscriptionPlan != '')
|
|
1179
|
+
userTypes.push(i1.Exclusivities.ACTIVE_SUBSCRIBER);
|
|
1180
|
+
if (user.isSubscriber &&
|
|
1181
|
+
user.subscriptionPlan == '' &&
|
|
1182
|
+
coupon.exclusivityType.includes(i1.Exclusivities.INACTIVE_SUBSCRIBER))
|
|
1183
|
+
userTypes.push(i1.Exclusivities.INACTIVE_SUBSCRIBER);
|
|
1184
|
+
if (coupon.exclusivityType.includes(i1.Exclusivities.NON_SUBSCRIBER) && !user.isSubscriber)
|
|
1185
|
+
userTypes.push(i1.Exclusivities.NON_SUBSCRIBER);
|
|
1186
|
+
return coupon.exclusivityType.some(function (r) { return userTypes.includes(r); });
|
|
1187
|
+
};
|
|
1188
|
+
CouponService.prototype.getCouponCategoriesId = function (productsCategories) {
|
|
1189
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1190
|
+
var couponCategories, index, category, children;
|
|
1191
|
+
return __generator(this, function (_c) {
|
|
1192
|
+
switch (_c.label) {
|
|
1193
|
+
case 0:
|
|
1194
|
+
couponCategories = [];
|
|
1195
|
+
index = 0;
|
|
1196
|
+
_c.label = 1;
|
|
1197
|
+
case 1:
|
|
1198
|
+
if (!(index < productsCategories.length)) return [3 /*break*/, 5];
|
|
1199
|
+
return [4 /*yield*/, this.categoryRepository.get({
|
|
1200
|
+
id: productsCategories[index],
|
|
1201
|
+
})];
|
|
986
1202
|
case 2:
|
|
987
|
-
|
|
988
|
-
if (!
|
|
989
|
-
|
|
990
|
-
return [4 /*yield*/, this.variantRepository.find({ filters: { id: productId } })];
|
|
1203
|
+
category = _c.sent();
|
|
1204
|
+
if (!category) return [3 /*break*/, 4];
|
|
1205
|
+
return [4 /*yield*/, this.categoryRepository.getChildren(parseInt(productsCategories[index]))];
|
|
991
1206
|
case 3:
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
throw error_1;
|
|
996
|
-
return [4 /*yield*/, this.productRepository.get({ id: variant.productId })];
|
|
1207
|
+
children = _c.sent();
|
|
1208
|
+
couponCategories.push.apply(couponCategories, __spreadArray([category.id], __read(children.map(function (c) { return c.id.toString(); }))));
|
|
1209
|
+
_c.label = 4;
|
|
997
1210
|
case 4:
|
|
998
|
-
|
|
999
|
-
return [3 /*break*/,
|
|
1000
|
-
case 5: return [2 /*return*/,
|
|
1211
|
+
index++;
|
|
1212
|
+
return [3 /*break*/, 1];
|
|
1213
|
+
case 5: return [2 /*return*/, __spreadArray([], __read(new Set(couponCategories)))];
|
|
1001
1214
|
}
|
|
1002
1215
|
});
|
|
1003
1216
|
});
|
|
1004
1217
|
};
|
|
1005
|
-
|
|
1006
|
-
var
|
|
1007
|
-
return
|
|
1008
|
-
var
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
switch (_o.label) {
|
|
1218
|
+
CouponService.prototype.getLineItensEligebleForDiscount = function (productsCategories, checkout) {
|
|
1219
|
+
var _a;
|
|
1220
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1221
|
+
var lineItensDiscount, couponCategories;
|
|
1222
|
+
return __generator(this, function (_c) {
|
|
1223
|
+
switch (_c.label) {
|
|
1012
1224
|
case 0:
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
return [2 /*return*/, Object.assign(Object.assign({}, checkout), { lineItems: [] })];
|
|
1016
|
-
cartTotal = notGiftItems.reduce(function (a, b) { return a + b.pricePaid * b.quantity; }, 0);
|
|
1017
|
-
return [4 /*yield*/, this.buy2WinRepository
|
|
1018
|
-
.find({
|
|
1019
|
-
filters: {
|
|
1020
|
-
active: { operator: i3.Where.EQUALS, value: true },
|
|
1021
|
-
shop: { operator: i3.Where.EQUALS, value: this.defaultShop },
|
|
1022
|
-
},
|
|
1023
|
-
})
|
|
1024
|
-
.then(function (data) { return data.data; })];
|
|
1225
|
+
lineItensDiscount = [];
|
|
1226
|
+
return [4 /*yield*/, this.getCouponCategoriesId(productsCategories)];
|
|
1025
1227
|
case 1:
|
|
1026
|
-
|
|
1027
|
-
if (
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
var e_4, _p;
|
|
1033
|
-
return __generator(this, function (_q) {
|
|
1034
|
-
switch (_q.label) {
|
|
1035
|
-
case 0:
|
|
1036
|
-
today = new Date();
|
|
1037
|
-
if (!(campaign.startDate <= today) && !(campaign.endDate >= today))
|
|
1038
|
-
return [2 /*return*/, "continue"];
|
|
1039
|
-
if (!campaign.activeCategory) return [3 /*break*/, 9];
|
|
1040
|
-
categoriesCampaing = campaign.categories.map(function (c) { return c.id.toString(); });
|
|
1041
|
-
categoriesCampaingFullTree = [];
|
|
1042
|
-
_q.label = 1;
|
|
1043
|
-
case 1:
|
|
1044
|
-
_q.trys.push([1, 6, 7, 8]);
|
|
1045
|
-
categoriesCampaing_1 = (e_4 = void 0, __values(categoriesCampaing)), categoriesCampaing_1_1 = categoriesCampaing_1.next();
|
|
1046
|
-
_q.label = 2;
|
|
1047
|
-
case 2:
|
|
1048
|
-
if (!!categoriesCampaing_1_1.done) return [3 /*break*/, 5];
|
|
1049
|
-
id = categoriesCampaing_1_1.value;
|
|
1050
|
-
return [4 /*yield*/, this_1.categoryRepository.getChildren(parseInt(id))];
|
|
1051
|
-
case 3:
|
|
1052
|
-
children = _q.sent();
|
|
1053
|
-
categoriesCampaingFullTree.push.apply(categoriesCampaingFullTree, __spreadArray([id], __read(children.map(function (c) { return c.id.toString(); }))));
|
|
1054
|
-
_q.label = 4;
|
|
1055
|
-
case 4:
|
|
1056
|
-
categoriesCampaing_1_1 = categoriesCampaing_1.next();
|
|
1057
|
-
return [3 /*break*/, 2];
|
|
1058
|
-
case 5: return [3 /*break*/, 8];
|
|
1059
|
-
case 6:
|
|
1060
|
-
e_4_1 = _q.sent();
|
|
1061
|
-
e_4 = { error: e_4_1 };
|
|
1062
|
-
return [3 /*break*/, 8];
|
|
1063
|
-
case 7:
|
|
1064
|
-
try {
|
|
1065
|
-
if (categoriesCampaing_1_1 && !categoriesCampaing_1_1.done && (_p = categoriesCampaing_1.return)) _p.call(categoriesCampaing_1);
|
|
1066
|
-
}
|
|
1067
|
-
finally { if (e_4) throw e_4.error; }
|
|
1068
|
-
return [7 /*endfinally*/];
|
|
1069
|
-
case 8:
|
|
1070
|
-
categoriesCampaingTree_1 = __spreadArray([], __read(new Set(categoriesCampaingFullTree)));
|
|
1071
|
-
filterProductsCategories = checkout.lineItems.filter(function (l) {
|
|
1072
|
-
var _a;
|
|
1073
|
-
if (!l.categories || !((_a = l.categories) === null || _a === void 0 ? void 0 : _a.length))
|
|
1074
|
-
return true;
|
|
1075
|
-
return l.categories.some(function (c) { return categoriesCampaingTree_1.some(function (cat) { return cat == c; }); });
|
|
1076
|
-
});
|
|
1077
|
-
if (filterProductsCategories.length) {
|
|
1078
|
-
cartTotalCategories = filterProductsCategories.reduce(function (a, b) { return a + b.pricePaid * b.quantity; }, 0);
|
|
1079
|
-
if (cartTotalCategories >= campaign.cartValueMin)
|
|
1080
|
-
elegibleCampaigns.push(campaign);
|
|
1081
|
-
}
|
|
1082
|
-
return [3 /*break*/, 10];
|
|
1083
|
-
case 9:
|
|
1084
|
-
if (campaign.cartValue && campaign.cartValue > 0) {
|
|
1085
|
-
if (campaign.cartValue <= cartTotal)
|
|
1086
|
-
elegibleCampaigns.push(campaign);
|
|
1087
|
-
}
|
|
1088
|
-
_q.label = 10;
|
|
1089
|
-
case 10: return [2 /*return*/];
|
|
1228
|
+
couponCategories = _c.sent();
|
|
1229
|
+
if (productsCategories && productsCategories.length) {
|
|
1230
|
+
lineItensDiscount = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.filter(function (i) {
|
|
1231
|
+
var _a;
|
|
1232
|
+
if ((_a = i.categories) === null || _a === void 0 ? void 0 : _a.length) {
|
|
1233
|
+
return i.categories.some(function (c) { return couponCategories.some(function (cat) { return cat == c; }); });
|
|
1090
1234
|
}
|
|
1235
|
+
return true;
|
|
1091
1236
|
});
|
|
1092
|
-
};
|
|
1093
|
-
this_1 = this;
|
|
1094
|
-
_o.label = 2;
|
|
1095
|
-
case 2:
|
|
1096
|
-
_o.trys.push([2, 7, 8, 9]);
|
|
1097
|
-
campaigns_1 = __values(campaigns), campaigns_1_1 = campaigns_1.next();
|
|
1098
|
-
_o.label = 3;
|
|
1099
|
-
case 3:
|
|
1100
|
-
if (!!campaigns_1_1.done) return [3 /*break*/, 6];
|
|
1101
|
-
campaign = campaigns_1_1.value;
|
|
1102
|
-
return [5 /*yield**/, _loop_1(campaign)];
|
|
1103
|
-
case 4:
|
|
1104
|
-
_o.sent();
|
|
1105
|
-
_o.label = 5;
|
|
1106
|
-
case 5:
|
|
1107
|
-
campaigns_1_1 = campaigns_1.next();
|
|
1108
|
-
return [3 /*break*/, 3];
|
|
1109
|
-
case 6: return [3 /*break*/, 9];
|
|
1110
|
-
case 7:
|
|
1111
|
-
e_1_1 = _o.sent();
|
|
1112
|
-
e_1 = { error: e_1_1 };
|
|
1113
|
-
return [3 /*break*/, 9];
|
|
1114
|
-
case 8:
|
|
1115
|
-
try {
|
|
1116
|
-
if (campaigns_1_1 && !campaigns_1_1.done && (_k = campaigns_1.return)) _k.call(campaigns_1);
|
|
1117
|
-
}
|
|
1118
|
-
finally { if (e_1) throw e_1.error; }
|
|
1119
|
-
return [7 /*endfinally*/];
|
|
1120
|
-
case 9:
|
|
1121
|
-
if (!elegibleCampaigns.length)
|
|
1122
|
-
return [2 /*return*/, Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems })];
|
|
1123
|
-
campaingnProducts = [];
|
|
1124
|
-
_o.label = 10;
|
|
1125
|
-
case 10:
|
|
1126
|
-
_o.trys.push([10, 22, 23, 24]);
|
|
1127
|
-
elegibleCampaigns_1 = __values(elegibleCampaigns), elegibleCampaigns_1_1 = elegibleCampaigns_1.next();
|
|
1128
|
-
_o.label = 11;
|
|
1129
|
-
case 11:
|
|
1130
|
-
if (!!elegibleCampaigns_1_1.done) return [3 /*break*/, 21];
|
|
1131
|
-
campaign = elegibleCampaigns_1_1.value;
|
|
1132
|
-
elegibleProducts = [];
|
|
1133
|
-
_o.label = 12;
|
|
1134
|
-
case 12:
|
|
1135
|
-
_o.trys.push([12, 17, 18, 19]);
|
|
1136
|
-
_h = (e_2 = void 0, __values(campaign.products)), _j = _h.next();
|
|
1137
|
-
_o.label = 13;
|
|
1138
|
-
case 13:
|
|
1139
|
-
if (!!_j.done) return [3 /*break*/, 16];
|
|
1140
|
-
product = _j.value;
|
|
1141
|
-
return [4 /*yield*/, this.productRepository.find({ filters: { sku: product } })];
|
|
1142
|
-
case 14:
|
|
1143
|
-
productData = (_o.sent()).data;
|
|
1144
|
-
if (!productData.length)
|
|
1145
|
-
return [3 /*break*/, 15];
|
|
1146
|
-
gift = productData.shift();
|
|
1147
|
-
if (gift.stock.quantity < 1)
|
|
1148
|
-
return [3 /*break*/, 15];
|
|
1149
|
-
elegibleProducts.push(gift);
|
|
1150
|
-
_o.label = 15;
|
|
1151
|
-
case 15:
|
|
1152
|
-
_j = _h.next();
|
|
1153
|
-
return [3 /*break*/, 13];
|
|
1154
|
-
case 16: return [3 /*break*/, 19];
|
|
1155
|
-
case 17:
|
|
1156
|
-
e_2_1 = _o.sent();
|
|
1157
|
-
e_2 = { error: e_2_1 };
|
|
1158
|
-
return [3 /*break*/, 19];
|
|
1159
|
-
case 18:
|
|
1160
|
-
try {
|
|
1161
|
-
if (_j && !_j.done && (_m = _h.return)) _m.call(_h);
|
|
1162
1237
|
}
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
case 19:
|
|
1166
|
-
campaingnProducts.push(elegibleProducts);
|
|
1167
|
-
_o.label = 20;
|
|
1168
|
-
case 20:
|
|
1169
|
-
elegibleCampaigns_1_1 = elegibleCampaigns_1.next();
|
|
1170
|
-
return [3 /*break*/, 11];
|
|
1171
|
-
case 21: return [3 /*break*/, 24];
|
|
1172
|
-
case 22:
|
|
1173
|
-
e_3_1 = _o.sent();
|
|
1174
|
-
e_3 = { error: e_3_1 };
|
|
1175
|
-
return [3 /*break*/, 24];
|
|
1176
|
-
case 23:
|
|
1177
|
-
try {
|
|
1178
|
-
if (elegibleCampaigns_1_1 && !elegibleCampaigns_1_1.done && (_l = elegibleCampaigns_1.return)) _l.call(elegibleCampaigns_1);
|
|
1238
|
+
else {
|
|
1239
|
+
lineItensDiscount = checkout.lineItems;
|
|
1179
1240
|
}
|
|
1180
|
-
|
|
1181
|
-
return [7 /*endfinally*/];
|
|
1182
|
-
case 24:
|
|
1183
|
-
if (!campaingnProducts.length)
|
|
1184
|
-
return [2 /*return*/, Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems })];
|
|
1185
|
-
gifts = this.giftToLineItems([].concat.apply([], __spreadArray([], __read(campaingnProducts))));
|
|
1186
|
-
return [2 /*return*/, Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems.concat(gifts) })];
|
|
1241
|
+
return [2 /*return*/, lineItensDiscount];
|
|
1187
1242
|
}
|
|
1188
1243
|
});
|
|
1189
|
-
});
|
|
1244
|
+
});
|
|
1190
1245
|
};
|
|
1191
|
-
|
|
1192
|
-
return
|
|
1193
|
-
var _a;
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1246
|
+
CouponService.prototype.calcCheckoutSubtotal = function (lineItens, user, shop) {
|
|
1247
|
+
return ((lineItens === null || lineItens === void 0 ? void 0 : lineItens.reduce(function (acc, curr) {
|
|
1248
|
+
var _a, _b;
|
|
1249
|
+
return (user === null || user === void 0 ? void 0 : user.isSubscriber) && ((_a = curr.price[shop]) === null || _a === void 0 ? void 0 : _a.subscriberPrice)
|
|
1250
|
+
? acc + ((_b = curr.price[shop]) === null || _b === void 0 ? void 0 : _b.subscriberPrice) * curr.quantity
|
|
1251
|
+
: acc + curr.pricePaid * curr.quantity;
|
|
1252
|
+
}, 0)) || 0);
|
|
1253
|
+
};
|
|
1254
|
+
CouponService.prototype.getOrdersWithCoupon = function (coupon) {
|
|
1255
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1256
|
+
return __generator(this, function (_c) {
|
|
1257
|
+
switch (_c.label) {
|
|
1258
|
+
case 0: return [4 /*yield*/, this.orderRepository
|
|
1259
|
+
.find({
|
|
1260
|
+
filters: {
|
|
1261
|
+
coupon: { id: coupon.id },
|
|
1262
|
+
payment: { status: 'paid' },
|
|
1263
|
+
},
|
|
1264
|
+
})
|
|
1265
|
+
.then(function (result) { return result.data; })];
|
|
1266
|
+
case 1: return [2 /*return*/, _c.sent()];
|
|
1267
|
+
}
|
|
1211
1268
|
});
|
|
1212
1269
|
});
|
|
1213
1270
|
};
|
|
1214
|
-
|
|
1271
|
+
CouponService.prototype.countOrdersWithUser = function (orders, email) {
|
|
1272
|
+
return orders.filter(function (o) { return o.user.email == email; }).length;
|
|
1273
|
+
};
|
|
1274
|
+
CouponService.prototype.getCouponUseLimits = function (coupon, checkoutType, user) {
|
|
1275
|
+
var couponUseLimits;
|
|
1276
|
+
if (checkoutType == i1.CheckoutTypes.ECOMMERCE || checkoutType == i1.CheckoutTypes.ALL) {
|
|
1277
|
+
couponUseLimits = user && user.isSubscriber ? coupon.useLimits.subscriber : coupon.useLimits.non_subscriber;
|
|
1278
|
+
}
|
|
1279
|
+
else {
|
|
1280
|
+
couponUseLimits = coupon.useLimits.subscription;
|
|
1281
|
+
}
|
|
1282
|
+
return couponUseLimits;
|
|
1283
|
+
};
|
|
1284
|
+
return CouponService;
|
|
1215
1285
|
}());
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type:
|
|
1219
|
-
type: i0.Injectable
|
|
1286
|
+
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: 'CategoryRepository' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
1287
|
+
CouponService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CouponService, providedIn: 'root' });
|
|
1288
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CouponService, decorators: [{
|
|
1289
|
+
type: i0.Injectable,
|
|
1290
|
+
args: [{
|
|
1291
|
+
providedIn: 'root',
|
|
1292
|
+
}]
|
|
1220
1293
|
}], ctorParameters: function () {
|
|
1221
|
-
return [{ type:
|
|
1294
|
+
return [{ type: undefined, decorators: [{
|
|
1295
|
+
type: i0.Inject,
|
|
1296
|
+
args: ['CouponRepository']
|
|
1297
|
+
}] }, { type: i1__namespace$1.Shops, decorators: [{
|
|
1222
1298
|
type: i0.Inject,
|
|
1223
1299
|
args: [DEFAULT_SHOP]
|
|
1224
1300
|
}] }, { type: undefined, decorators: [{
|
|
1225
1301
|
type: i0.Inject,
|
|
1226
|
-
args: ['
|
|
1302
|
+
args: ['OrderRepository']
|
|
1227
1303
|
}] }, { type: undefined, decorators: [{
|
|
1228
1304
|
type: i0.Inject,
|
|
1229
1305
|
args: ['CategoryRepository']
|
|
1230
|
-
}] }, { type: undefined, decorators: [{
|
|
1231
|
-
type: i0.Inject,
|
|
1232
|
-
args: ['VariantRepository']
|
|
1233
|
-
}] }, { type: i3__namespace.Buy2WinFirestoreRepository, decorators: [{
|
|
1234
|
-
type: i0.Inject,
|
|
1235
|
-
args: ['Buy2WinRepository']
|
|
1236
1306
|
}] }];
|
|
1237
1307
|
} });
|
|
1238
1308
|
|
|
1239
|
-
var
|
|
1240
|
-
function
|
|
1241
|
-
this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
|
|
1242
|
-
this.subscriptionRepository = subscriptionRepository;
|
|
1309
|
+
var CheckoutService = /** @class */ (function () {
|
|
1310
|
+
function CheckoutService(couponService, checkoutRepository, orderRepository, userRepository, defaultShop) {
|
|
1243
1311
|
this.couponService = couponService;
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
if (!i3.isNil(checkoutId))
|
|
1248
|
-
return rxjs.from(this.checkoutSubscriptionRepository.get({ id: checkoutId }));
|
|
1249
|
-
return rxjs.from(this.createCheckoutSubscription(checkoutData));
|
|
1250
|
-
};
|
|
1251
|
-
CheckoutSubscriptionService.prototype.createCheckoutSubscription = function (checkoutData) {
|
|
1252
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1253
|
-
var checkout;
|
|
1254
|
-
return __generator(this, function (_a) {
|
|
1255
|
-
switch (_a.label) {
|
|
1256
|
-
case 0: return [4 /*yield*/, this.checkoutSubscriptionRepository.create(Object.assign({ createdAt: new Date() }, i3.CheckoutSubscription.toInstance(i3.pick(checkoutData, ['user', 'shop'])).toPlain()))];
|
|
1257
|
-
case 1:
|
|
1258
|
-
checkout = _a.sent();
|
|
1259
|
-
cookie__default["default"].set('checkoutSubscriptionId', checkout.id);
|
|
1260
|
-
return [2 /*return*/, checkout];
|
|
1261
|
-
}
|
|
1262
|
-
});
|
|
1263
|
-
});
|
|
1264
|
-
};
|
|
1265
|
-
CheckoutSubscriptionService.prototype.clearCheckoutSubscriptionFromSession = function () {
|
|
1266
|
-
cookie__default["default"].remove('checkoutSubscriptionId');
|
|
1267
|
-
return rxjs.of();
|
|
1268
|
-
};
|
|
1269
|
-
CheckoutSubscriptionService.prototype.checkCoupon = function (nickname, userEmail) {
|
|
1270
|
-
var _this = this;
|
|
1271
|
-
return this.getCheckoutSubscription().pipe(operators.concatMap(function (checkout) { return _this.couponService
|
|
1272
|
-
.checkCoupon(nickname, i3.CheckoutTypes.SUBSCRIPTION, checkout, checkout.subscriptionPlan.name)
|
|
1273
|
-
.pipe(); }));
|
|
1274
|
-
};
|
|
1275
|
-
CheckoutSubscriptionService.prototype.calcDiscountSubscription = function (coupon) {
|
|
1276
|
-
var _this = this;
|
|
1277
|
-
return this.getCheckoutSubscription().pipe(operators.concatMap(function (checkout) { return _this.couponService.calcDiscountSubscription(coupon, checkout).pipe(); }));
|
|
1278
|
-
};
|
|
1279
|
-
return CheckoutSubscriptionService;
|
|
1280
|
-
}());
|
|
1281
|
-
CheckoutSubscriptionService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutSubscriptionService, deps: [{ token: 'CheckoutSubscriptionRepository' }, { token: 'SubscriptionRepository' }, { token: CouponService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
1282
|
-
CheckoutSubscriptionService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutSubscriptionService });
|
|
1283
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutSubscriptionService, decorators: [{
|
|
1284
|
-
type: i0.Injectable
|
|
1285
|
-
}], ctorParameters: function () {
|
|
1286
|
-
return [{ type: undefined, decorators: [{
|
|
1287
|
-
type: i0.Inject,
|
|
1288
|
-
args: ['CheckoutSubscriptionRepository']
|
|
1289
|
-
}] }, { type: undefined, decorators: [{
|
|
1290
|
-
type: i0.Inject,
|
|
1291
|
-
args: ['SubscriptionRepository']
|
|
1292
|
-
}] }, { type: CouponService }];
|
|
1293
|
-
} });
|
|
1294
|
-
|
|
1295
|
-
var HomeShopService = /** @class */ (function () {
|
|
1296
|
-
function HomeShopService(categoryRepository, homeRepository, productRepository, defaultShop) {
|
|
1297
|
-
this.categoryRepository = categoryRepository;
|
|
1298
|
-
this.homeRepository = homeRepository;
|
|
1299
|
-
this.productRepository = productRepository;
|
|
1312
|
+
this.checkoutRepository = checkoutRepository;
|
|
1313
|
+
this.orderRepository = orderRepository;
|
|
1314
|
+
this.userRepository = userRepository;
|
|
1300
1315
|
this.defaultShop = defaultShop;
|
|
1301
|
-
this.buildCategoryGroupWithRequiredData = function (group) {
|
|
1302
|
-
var _a, _b;
|
|
1303
|
-
return ({
|
|
1304
|
-
category: i3.Category.toInstance(i3.pick(((_a = group === null || group === void 0 ? void 0 : group.category) === null || _a === void 0 ? void 0 : _a.toPlain()) || {}, ['id', 'name', 'slug', 'conditions'])),
|
|
1305
|
-
products: ((_b = group === null || group === void 0 ? void 0 : group.products) === null || _b === void 0 ? void 0 : _b.map(function (product) { return i3.Product.toInstance(i3.pick((product === null || product === void 0 ? void 0 : product.toPlain()) || {}, [
|
|
1306
|
-
'id',
|
|
1307
|
-
'price',
|
|
1308
|
-
'reviews',
|
|
1309
|
-
'hasVariants',
|
|
1310
|
-
'slug',
|
|
1311
|
-
'sku',
|
|
1312
|
-
'stock',
|
|
1313
|
-
'costPrice',
|
|
1314
|
-
'images',
|
|
1315
|
-
'miniatures',
|
|
1316
|
-
'name',
|
|
1317
|
-
'weight',
|
|
1318
|
-
'rate',
|
|
1319
|
-
'type',
|
|
1320
|
-
])); })) || [],
|
|
1321
|
-
});
|
|
1322
|
-
};
|
|
1323
1316
|
}
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
return 'mens_market';
|
|
1330
|
-
return null;
|
|
1331
|
-
},
|
|
1332
|
-
enumerable: false,
|
|
1333
|
-
configurable: true
|
|
1334
|
-
});
|
|
1335
|
-
HomeShopService.prototype.getHomeData = function () {
|
|
1336
|
-
var _this = this;
|
|
1337
|
-
return this.getHomeConfiguration().pipe(operators.map(function (home) { var _a; return (((_a = home === null || home === void 0 ? void 0 : home.data) === null || _a === void 0 ? void 0 : _a.expiresAt) > new Date() ? home : null); }), operators.concatMap(function (home) { return home
|
|
1338
|
-
? rxjs.of(home)
|
|
1339
|
-
: rxjs.forkJoin([_this.getDiscoverProducts(), _this.getFeaturedProducts(), _this.getVerticalProducts()]).pipe(operators.map(function (_c) {
|
|
1340
|
-
var _d = __read(_c, 3), discoverProducts = _d[0], featuredProducts = _d[1], verticalProducts = _d[2];
|
|
1341
|
-
return ({
|
|
1342
|
-
discoverProducts: discoverProducts,
|
|
1343
|
-
featuredProducts: featuredProducts,
|
|
1344
|
-
verticalProducts: verticalProducts,
|
|
1345
|
-
});
|
|
1346
|
-
}), operators.concatMap(function (data) { return _this.saveHomeData(data); })); }));
|
|
1317
|
+
CheckoutService.prototype.getCheckout = function (checkoutData) {
|
|
1318
|
+
var checkoutId = cookie__default["default"].get('checkoutId');
|
|
1319
|
+
if (!i1.isNil(checkoutId))
|
|
1320
|
+
return rxjs.from(this.checkoutRepository.get({ id: checkoutId }));
|
|
1321
|
+
return rxjs.from(this.createCheckout(checkoutData));
|
|
1347
1322
|
};
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
return home.brandsCarousel;
|
|
1352
|
-
if (type === 'buyToWin')
|
|
1353
|
-
return [home.buyToWinBanner];
|
|
1354
|
-
if (type === 'block')
|
|
1355
|
-
return home.blockBanners;
|
|
1356
|
-
if (type === 'blog')
|
|
1357
|
-
return [home.blogBanner];
|
|
1358
|
-
}));
|
|
1323
|
+
CheckoutService.prototype.getUserByCheckout = function (checkoutId) {
|
|
1324
|
+
var _this = this;
|
|
1325
|
+
return rxjs.from(this.checkoutRepository.get({ id: checkoutId })).pipe(operators.concatMap(function (checkout) { var _a; return ((_a = checkout === null || checkout === void 0 ? void 0 : checkout.user) === null || _a === void 0 ? void 0 : _a.id) ? rxjs.of(checkout.user) : rxjs.from(_this.userRepository.get({ id: checkout.user.id })); }), operators.concatMap(function (user) { return rxjs.of(user) || rxjs.throwError(function () { return new i1.NotFoundError('User is not found'); }); }));
|
|
1359
1326
|
};
|
|
1360
|
-
|
|
1361
|
-
return
|
|
1327
|
+
CheckoutService.prototype.updateCheckoutLineItems = function (checkout) {
|
|
1328
|
+
return rxjs.from(this.checkoutRepository.update(i1.Checkout.toInstance({ id: checkout.id, lineItems: checkout.lineItems })));
|
|
1362
1329
|
};
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
return this.getHomeConfiguration().pipe(operators.concatMap(function (home) { return rxjs.from(_this.categoryRepository.getCategoriesForHome(home.discoverCategories)).pipe(operators.map(function (groups) { return groups.map(_this.buildCategoryGroupWithRequiredData); })); }));
|
|
1330
|
+
CheckoutService.prototype.updateCheckoutUser = function (checkout) {
|
|
1331
|
+
return rxjs.from(this.checkoutRepository.update(i1.Checkout.toInstance({ id: checkout.id, user: checkout.user })));
|
|
1366
1332
|
};
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
return
|
|
1333
|
+
CheckoutService.prototype.clearCheckoutFromSession = function () {
|
|
1334
|
+
cookie__default["default"].remove('checkoutId');
|
|
1335
|
+
return rxjs.of();
|
|
1370
1336
|
};
|
|
1371
|
-
|
|
1337
|
+
CheckoutService.prototype.calcDiscount = function (coupon) {
|
|
1372
1338
|
var _this = this;
|
|
1373
|
-
return this.
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
}), operators.map(_this.buildCategoryGroupWithRequiredData)); })); }));
|
|
1339
|
+
return this.getCheckout().pipe(operators.concatMap(function (checkout) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_b) {
|
|
1340
|
+
switch (_b.label) {
|
|
1341
|
+
case 0: return [4 /*yield*/, this.couponService.calcDiscountShopping(coupon, checkout)];
|
|
1342
|
+
case 1: return [2 /*return*/, _b.sent()];
|
|
1343
|
+
}
|
|
1344
|
+
}); }); }));
|
|
1380
1345
|
};
|
|
1381
|
-
|
|
1346
|
+
CheckoutService.prototype.checkCoupon = function (nickname, checkoutType) {
|
|
1382
1347
|
var _this = this;
|
|
1383
|
-
return
|
|
1384
|
-
? rxjs.of(home)
|
|
1385
|
-
: !_this.homeId
|
|
1386
|
-
? rxjs.throwError(new i3.RequiredArgumentError(['homeId']))
|
|
1387
|
-
: rxjs.from(_this.homeRepository.get({ id: _this.homeId })).pipe(operators.tap(function (homeLoaded) { return (_this.homeConfiguration = homeLoaded); })); }));
|
|
1348
|
+
return this.getCheckout().pipe(operators.concatMap(function (checkout) { return _this.couponService.checkCoupon(nickname, i1.CheckoutTypes.ECOMMERCE, checkout, null).pipe(); }));
|
|
1388
1349
|
};
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1350
|
+
CheckoutService.prototype.createCheckout = function (checkoutData) {
|
|
1351
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1352
|
+
var checkout;
|
|
1353
|
+
return __generator(this, function (_b) {
|
|
1354
|
+
switch (_b.label) {
|
|
1355
|
+
case 0: return [4 /*yield*/, this.checkoutRepository.create(Object.assign(Object.assign({ createdAt: new Date() }, i1.Checkout.toInstance(i1.pick(checkoutData, ['user', 'shop'])).toPlain()), { shop: (checkoutData === null || checkoutData === void 0 ? void 0 : checkoutData.shop) || this.defaultShop }))];
|
|
1356
|
+
case 1:
|
|
1357
|
+
checkout = _b.sent();
|
|
1358
|
+
cookie__default["default"].set('checkoutId', checkout.id);
|
|
1359
|
+
return [2 /*return*/, checkout];
|
|
1360
|
+
}
|
|
1361
|
+
});
|
|
1362
|
+
});
|
|
1400
1363
|
};
|
|
1401
|
-
return
|
|
1364
|
+
return CheckoutService;
|
|
1402
1365
|
}());
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type:
|
|
1366
|
+
CheckoutService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutService, deps: [{ token: CouponService }, { token: 'CheckoutRepository' }, { token: 'OrderRepository' }, { token: 'UserRepository' }, { token: DEFAULT_SHOP }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
1367
|
+
CheckoutService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutService });
|
|
1368
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutService, decorators: [{
|
|
1406
1369
|
type: i0.Injectable
|
|
1407
1370
|
}], ctorParameters: function () {
|
|
1408
|
-
return [{ type: undefined, decorators: [{
|
|
1371
|
+
return [{ type: CouponService }, { type: undefined, decorators: [{
|
|
1409
1372
|
type: i0.Inject,
|
|
1410
|
-
args: ['
|
|
1373
|
+
args: ['CheckoutRepository']
|
|
1411
1374
|
}] }, { type: undefined, decorators: [{
|
|
1412
1375
|
type: i0.Inject,
|
|
1413
|
-
args: ['
|
|
1376
|
+
args: ['OrderRepository']
|
|
1414
1377
|
}] }, { type: undefined, decorators: [{
|
|
1415
1378
|
type: i0.Inject,
|
|
1416
|
-
args: ['
|
|
1417
|
-
}] }, { type:
|
|
1379
|
+
args: ['UserRepository']
|
|
1380
|
+
}] }, { type: i1__namespace$1.Shops, decorators: [{
|
|
1418
1381
|
type: i0.Inject,
|
|
1419
1382
|
args: [DEFAULT_SHOP]
|
|
1420
1383
|
}] }];
|
|
1421
1384
|
} });
|
|
1422
1385
|
|
|
1423
|
-
var
|
|
1424
|
-
function
|
|
1425
|
-
this.angularFirestore = angularFirestore;
|
|
1426
|
-
this.orderRepository = orderRepository;
|
|
1427
|
-
this.orderSubject = new rxjs.Subject();
|
|
1428
|
-
}
|
|
1429
|
-
OrderService.prototype.getOrder = function (id) {
|
|
1430
|
-
var _this = this;
|
|
1431
|
-
this.angularFirestore
|
|
1432
|
-
.doc(this.orderRepository.collectionName + "/" + id)
|
|
1433
|
-
.valueChanges()
|
|
1434
|
-
.pipe(operators.map(function (doc) { return i3.Order.toInstance(doc); }))
|
|
1435
|
-
.subscribe(function (doc) { return _this.orderSubject.next(doc); });
|
|
1436
|
-
return this.orderSubject;
|
|
1437
|
-
};
|
|
1438
|
-
return OrderService;
|
|
1439
|
-
}());
|
|
1440
|
-
OrderService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: OrderService, deps: [{ token: i1__namespace$1.AngularFirestore }, { token: 'OrderRepository' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
1441
|
-
OrderService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: OrderService });
|
|
1442
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: OrderService, decorators: [{
|
|
1443
|
-
type: i0.Injectable
|
|
1444
|
-
}], ctorParameters: function () {
|
|
1445
|
-
return [{ type: i1__namespace$1.AngularFirestore }, { type: i3__namespace.OrderFirestoreRepository, decorators: [{
|
|
1446
|
-
type: i0.Inject,
|
|
1447
|
-
args: ['OrderRepository']
|
|
1448
|
-
}] }];
|
|
1449
|
-
} });
|
|
1450
|
-
|
|
1451
|
-
var ShippingService = /** @class */ (function () {
|
|
1452
|
-
function ShippingService(http, apiUrl, homeService) {
|
|
1453
|
-
this.http = http;
|
|
1454
|
-
this.apiUrl = apiUrl;
|
|
1455
|
-
this.homeService = homeService;
|
|
1456
|
-
}
|
|
1457
|
-
ShippingService.prototype.getShippingMethods = function (shop, zip, weightGrams, totalPrice, personId, subscriptionPlan) {
|
|
1386
|
+
var CartService = /** @class */ (function () {
|
|
1387
|
+
function CartService(authService, checkoutService, defaultShop, productRepository, categoryRepository, variantRepository, buy2WinRepository) {
|
|
1458
1388
|
var _this = this;
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
if (_this.isHolidays(datasSameDayNotAvaliable)) {
|
|
1475
|
-
shippingMethods = shippingMethods.filter(function (method) { return method.serviceName !== 'Same Day'; });
|
|
1476
|
-
}
|
|
1477
|
-
if (totalPrice >= 200) {
|
|
1478
|
-
shippingMethods = shippingMethods.map(function (s) {
|
|
1479
|
-
if (s.serviceName !== 'Same Day')
|
|
1480
|
-
return Object.assign(Object.assign({}, s), { totalPrice: 0 });
|
|
1481
|
-
else
|
|
1482
|
-
return s;
|
|
1483
|
-
});
|
|
1484
|
-
}
|
|
1485
|
-
if (shop == i3.Shops.GLAMSHOP)
|
|
1486
|
-
return shippingMethods;
|
|
1487
|
-
if (_this.isFreeShippingBySubscription(shop, subscriptionPlan)) {
|
|
1488
|
-
shippingMethods = shippingMethods.map(function (s) {
|
|
1489
|
-
if (s.serviceName == 'Same Day')
|
|
1490
|
-
return Object.assign(Object.assign({}, s), { totalPrice: s.totalPrice / 2 });
|
|
1491
|
-
else
|
|
1492
|
-
return Object.assign(Object.assign({}, s), { totalPrice: 0 });
|
|
1493
|
-
});
|
|
1389
|
+
this.authService = authService;
|
|
1390
|
+
this.checkoutService = checkoutService;
|
|
1391
|
+
this.defaultShop = defaultShop;
|
|
1392
|
+
this.productRepository = productRepository;
|
|
1393
|
+
this.categoryRepository = categoryRepository;
|
|
1394
|
+
this.variantRepository = variantRepository;
|
|
1395
|
+
this.buy2WinRepository = buy2WinRepository;
|
|
1396
|
+
this.cartSubject = new rxjs.Subject();
|
|
1397
|
+
this.updateLineItemInCart = function (lineItem, quantity, checkout) { return (i1.isNil(checkout) ? _this.checkoutService.getCheckout() : rxjs.of(checkout)).pipe(operators.concatMap(function (checkoutLoaded) {
|
|
1398
|
+
var _a;
|
|
1399
|
+
var items = [];
|
|
1400
|
+
var index = (_a = checkoutLoaded.lineItems) === null || _a === void 0 ? void 0 : _a.map(function (checkoutItem) { return checkoutItem.id; }).indexOf(lineItem.id);
|
|
1401
|
+
if (index > -1) {
|
|
1402
|
+
checkoutLoaded.lineItems[index].quantity += quantity;
|
|
1403
|
+
checkoutLoaded.lineItems[index].pricePaid = lineItem.pricePaid;
|
|
1494
1404
|
}
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1405
|
+
else
|
|
1406
|
+
checkoutLoaded.lineItems = items.concat(checkoutLoaded.lineItems ? checkoutLoaded.lineItems.concat([lineItem]) : [lineItem]);
|
|
1407
|
+
return _this.checkoutService
|
|
1408
|
+
.updateCheckoutLineItems(checkoutLoaded)
|
|
1409
|
+
.pipe(operators.map(function (updatedCheckout) { return _this.generateCartObject(updatedCheckout.lineItems); }));
|
|
1410
|
+
})); };
|
|
1411
|
+
this.generateCartObject = function (items) { return items
|
|
1412
|
+
? items.reduce(function (cart, item) {
|
|
1413
|
+
var _h;
|
|
1414
|
+
var _a;
|
|
1415
|
+
return (Object.assign(Object.assign({}, cart), (_h = {}, _h[item.id] = i1.LineItem.toInstance(Object.assign(Object.assign({}, (cart[item.id] || item)), { quantity: (((_a = cart[item.id]) === null || _a === void 0 ? void 0 : _a.quantity) || 0) + (item.quantity ? item.quantity : 1) })), _h)));
|
|
1416
|
+
}, {})
|
|
1417
|
+
: []; };
|
|
1418
|
+
this.buildLineItem = function (_h) {
|
|
1419
|
+
var checkout = _h.checkout, item = _h.item, quantity = _h.quantity;
|
|
1420
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
1421
|
+
var _a, _b, _c, _d, _e, _f, _g, product, image, id, name, EAN, slug, stock, price, weight, sku, type, isGift, pricePaid;
|
|
1422
|
+
return __generator(this, function (_h) {
|
|
1423
|
+
switch (_h.label) {
|
|
1424
|
+
case 0: return [4 /*yield*/, this.getProductData(item.id)];
|
|
1425
|
+
case 1:
|
|
1426
|
+
product = _h.sent();
|
|
1427
|
+
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.id === item.id; })) === null || _b === void 0 ? void 0 : _b.quantity) || 0;
|
|
1428
|
+
if (this.checkMaxStock(item, quantity || 0))
|
|
1429
|
+
throw new Error('Desculpe! Temos apenas ' + ((_c = item.stock) === null || _c === void 0 ? void 0 : _c.quantity) + ' em estoque.');
|
|
1430
|
+
image = item.image || ((_d = item.images) === null || _d === void 0 ? void 0 : _d.shift());
|
|
1431
|
+
id = item.id, name = item.name, EAN = item.EAN, slug = item.slug, stock = item.stock, price = item.price, weight = item.weight, sku = item.sku, type = item.type;
|
|
1432
|
+
isGift = item.isGift || null;
|
|
1433
|
+
pricePaid = this.getProductPrice({
|
|
1434
|
+
product: item,
|
|
1435
|
+
shop: checkout.shop || this.defaultShop,
|
|
1436
|
+
isSubscriber: (_e = checkout.user) === null || _e === void 0 ? void 0 : _e.isSubscriber,
|
|
1437
|
+
});
|
|
1438
|
+
i1.RoundProductPricesHelper.roundProductPrices(item);
|
|
1439
|
+
return [2 /*return*/, {
|
|
1440
|
+
checkout: checkout,
|
|
1441
|
+
lineItem: i1.LineItem.toInstance({
|
|
1442
|
+
id: id,
|
|
1443
|
+
name: name !== null && name !== void 0 ? name : product.name,
|
|
1444
|
+
EAN: EAN !== null && EAN !== void 0 ? EAN : product.EAN,
|
|
1445
|
+
brand: product.brand,
|
|
1446
|
+
slug: slug !== null && slug !== void 0 ? slug : product.slug,
|
|
1447
|
+
sku: sku !== null && sku !== void 0 ? sku : product.sku,
|
|
1448
|
+
stock: stock,
|
|
1449
|
+
price: this.roundPrice(price),
|
|
1450
|
+
image: image,
|
|
1451
|
+
weight: weight !== null && weight !== void 0 ? weight : product.weight,
|
|
1452
|
+
quantity: (item.quantity || 0) + (quantity || 0),
|
|
1453
|
+
pricePaid: pricePaid,
|
|
1454
|
+
categories: (_f = product.categories) !== null && _f !== void 0 ? _f : [],
|
|
1455
|
+
isGift: isGift !== null && isGift !== void 0 ? isGift : null,
|
|
1456
|
+
costPrice: (_g = product.costPrice) !== null && _g !== void 0 ? _g : 0,
|
|
1457
|
+
type: type,
|
|
1458
|
+
}),
|
|
1459
|
+
}];
|
|
1460
|
+
}
|
|
1498
1461
|
});
|
|
1462
|
+
});
|
|
1463
|
+
};
|
|
1464
|
+
this.getProductPrice = function (_h) {
|
|
1465
|
+
var product = _h.product, isSubscriber = _h.isSubscriber;
|
|
1466
|
+
var info = product.price;
|
|
1467
|
+
if (product.isGift)
|
|
1468
|
+
return 0;
|
|
1469
|
+
return isSubscriber && info.subscriberPrice > 0
|
|
1470
|
+
? Number(info.subscriberPrice.toFixed(2))
|
|
1471
|
+
: Number(info.price.toFixed(2));
|
|
1472
|
+
};
|
|
1473
|
+
this.checkMaxStock = function (item, quantity) {
|
|
1474
|
+
var _a;
|
|
1475
|
+
var maxStock = ((_a = item.stock) === null || _a === void 0 ? void 0 : _a.quantity) || 0;
|
|
1476
|
+
var currentItemAmount = item.quantity || 0;
|
|
1477
|
+
return currentItemAmount + quantity > maxStock;
|
|
1478
|
+
};
|
|
1479
|
+
}
|
|
1480
|
+
CartService.prototype.addItem = function (item, quantity) {
|
|
1481
|
+
var _this = this;
|
|
1482
|
+
if (quantity === void 0) { quantity = 1; }
|
|
1483
|
+
return rxjs.from(this.checkoutService.getCheckout()).pipe(operators.concatMap(function (checkout) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_h) {
|
|
1484
|
+
switch (_h.label) {
|
|
1485
|
+
case 0: return [4 /*yield*/, this.buildLineItem({ checkout: checkout, item: item, quantity: quantity || 1 })];
|
|
1486
|
+
case 1: return [2 /*return*/, _h.sent()];
|
|
1499
1487
|
}
|
|
1500
|
-
|
|
1501
|
-
|
|
1488
|
+
}); }); }), operators.mergeMap(function (_h) {
|
|
1489
|
+
var checkout = _h.checkout, lineItem = _h.lineItem;
|
|
1490
|
+
return _this.updateLineItemInCart(lineItem, quantity || 1, checkout);
|
|
1491
|
+
}), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
|
|
1502
1492
|
};
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
return
|
|
1508
|
-
|
|
1509
|
-
|
|
1493
|
+
CartService.prototype.decreaseItem = function (item) {
|
|
1494
|
+
var _this = this;
|
|
1495
|
+
return this.checkoutService.getCheckout().pipe(operators.map(function (checkout) {
|
|
1496
|
+
var _a;
|
|
1497
|
+
var checkoutItem = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.find(function (lineItem) { return lineItem.id === item.id; });
|
|
1498
|
+
if (!i1.isNil(checkoutItem))
|
|
1499
|
+
checkoutItem.quantity -= checkoutItem.quantity > 1 ? 1 : 0;
|
|
1500
|
+
return checkout;
|
|
1501
|
+
}), operators.concatMap(function (checkout) { return _this.checkoutService.updateCheckoutLineItems(checkout); }), operators.map(function (checkout) { return _this.generateCartObject(checkout.lineItems); }), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
|
|
1510
1502
|
};
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
return true;
|
|
1516
|
-
}
|
|
1517
|
-
return false;
|
|
1503
|
+
CartService.prototype.getCart = function (checkout) {
|
|
1504
|
+
var _this = this;
|
|
1505
|
+
this.buildCartFromCheckout(checkout).subscribe(function (cart) { return _this.cartSubject.next(cart); });
|
|
1506
|
+
return this.cartSubject;
|
|
1518
1507
|
};
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
if (start > end)
|
|
1525
|
-
end = new Date(today.getFullYear() + 1 + "-" + datas[key].endDate);
|
|
1526
|
-
if (today >= start && today <= end)
|
|
1527
|
-
return true;
|
|
1528
|
-
}
|
|
1529
|
-
return false;
|
|
1508
|
+
/**
|
|
1509
|
+
* @deprecated The method should not be used
|
|
1510
|
+
*/
|
|
1511
|
+
CartService.prototype.getVariantPriceDiscount = function (item) {
|
|
1512
|
+
return this.authService.getUser().pipe(operators.concatMap(function (user) { return rxjs.iif(function () { return user.isSubscriber && !!item.price.subscriberPrice; }, rxjs.of(item.price.subscriberPrice), rxjs.of(item.price.price)); }), operators.catchError(function () { return rxjs.of(item.price.price); }));
|
|
1530
1513
|
};
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
type: i0.Inject,
|
|
1540
|
-
args: [BACKEND_URL]
|
|
1541
|
-
}] }, { type: HomeShopService }];
|
|
1542
|
-
} });
|
|
1543
|
-
|
|
1544
|
-
var AngularFirebaseAuthModule = /** @class */ (function () {
|
|
1545
|
-
function AngularFirebaseAuthModule() {
|
|
1546
|
-
}
|
|
1547
|
-
AngularFirebaseAuthModule.initializeApp = function (options, nameOrConfig) {
|
|
1548
|
-
return {
|
|
1549
|
-
ngModule: AngularFirebaseAuthModule,
|
|
1550
|
-
providers: [
|
|
1551
|
-
{ provide: fire.FIREBASE_OPTIONS, useValue: options },
|
|
1552
|
-
{ provide: fire.FIREBASE_APP_NAME, useValue: nameOrConfig },
|
|
1553
|
-
],
|
|
1554
|
-
};
|
|
1514
|
+
CartService.prototype.removeItem = function (item) {
|
|
1515
|
+
var _this = this;
|
|
1516
|
+
return this.checkoutService.getCheckout().pipe(operators.map(function (checkout) {
|
|
1517
|
+
var index = checkout.lineItems.findIndex(function (lineItem) { return lineItem.id === item.id; });
|
|
1518
|
+
if (index >= 0)
|
|
1519
|
+
checkout.lineItems.splice(index, 1);
|
|
1520
|
+
return checkout;
|
|
1521
|
+
}), operators.concatMap(function (checkout) { return _this.checkoutService.updateCheckoutLineItems(checkout); }), operators.map(function (checkout) { return _this.generateCartObject(checkout.lineItems); }), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
|
|
1555
1522
|
};
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
}
|
|
1587
|
-
|
|
1588
|
-
},
|
|
1589
|
-
{
|
|
1590
|
-
provide: 'SignOut',
|
|
1591
|
-
useFactory: function (authenticationService) {
|
|
1592
|
-
return new i3.SignOut(authenticationService);
|
|
1593
|
-
},
|
|
1594
|
-
deps: ['AuthenticationService'],
|
|
1595
|
-
},
|
|
1596
|
-
{
|
|
1597
|
-
provide: 'RecoveryPassword',
|
|
1598
|
-
useFactory: function (authenticationService) {
|
|
1599
|
-
return new i3.RecoveryPassword(authenticationService);
|
|
1600
|
-
},
|
|
1601
|
-
deps: ['AuthenticationService'],
|
|
1602
|
-
},
|
|
1603
|
-
], imports: [[fire.AngularFireModule]] });
|
|
1604
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, decorators: [{
|
|
1605
|
-
type: i0.NgModule,
|
|
1606
|
-
args: [{
|
|
1607
|
-
imports: [fire.AngularFireModule],
|
|
1608
|
-
providers: [
|
|
1609
|
-
{
|
|
1610
|
-
provide: 'Authentication',
|
|
1611
|
-
useFactory: function (authenticationService, userRepository) {
|
|
1612
|
-
return new i3.Authentication(authenticationService, userRepository);
|
|
1613
|
-
},
|
|
1614
|
-
deps: ['AuthenticationService', 'UserRepository'],
|
|
1615
|
-
},
|
|
1616
|
-
{
|
|
1617
|
-
provide: 'AuthenticationService',
|
|
1618
|
-
useFactory: function (angularFireAuth) {
|
|
1619
|
-
return new i3.AuthenticationFirebaseAuthService(angularFireAuth);
|
|
1620
|
-
},
|
|
1621
|
-
deps: [i1.AngularFireAuth],
|
|
1622
|
-
},
|
|
1623
|
-
{
|
|
1624
|
-
provide: 'Register',
|
|
1625
|
-
useFactory: function (registerService, userRepository) {
|
|
1626
|
-
return new i3.Register(registerService, userRepository);
|
|
1627
|
-
},
|
|
1628
|
-
deps: ['RegisterService', 'UserRepository'],
|
|
1629
|
-
},
|
|
1630
|
-
{
|
|
1631
|
-
provide: 'RegisterService',
|
|
1632
|
-
useFactory: function (angularFireAuth) {
|
|
1633
|
-
return new i3.RegisterFirebaseAuthService(angularFireAuth);
|
|
1634
|
-
},
|
|
1635
|
-
deps: [i1.AngularFireAuth],
|
|
1636
|
-
},
|
|
1637
|
-
{
|
|
1638
|
-
provide: 'SignOut',
|
|
1639
|
-
useFactory: function (authenticationService) {
|
|
1640
|
-
return new i3.SignOut(authenticationService);
|
|
1641
|
-
},
|
|
1642
|
-
deps: ['AuthenticationService'],
|
|
1643
|
-
},
|
|
1644
|
-
{
|
|
1645
|
-
provide: 'RecoveryPassword',
|
|
1646
|
-
useFactory: function (authenticationService) {
|
|
1647
|
-
return new i3.RecoveryPassword(authenticationService);
|
|
1648
|
-
},
|
|
1649
|
-
deps: ['AuthenticationService'],
|
|
1650
|
-
},
|
|
1651
|
-
],
|
|
1652
|
-
}]
|
|
1653
|
-
}] });
|
|
1654
|
-
|
|
1655
|
-
var AngularElasticSeachModule = /** @class */ (function () {
|
|
1656
|
-
function AngularElasticSeachModule() {
|
|
1657
|
-
}
|
|
1658
|
-
AngularElasticSeachModule.initializeApp = function (options) {
|
|
1659
|
-
return {
|
|
1660
|
-
ngModule: AngularElasticSeachModule,
|
|
1661
|
-
providers: [{ provide: ES_CONFIG, useValue: options }],
|
|
1662
|
-
};
|
|
1523
|
+
CartService.prototype.updateUserCart = function (user) {
|
|
1524
|
+
var _this = this;
|
|
1525
|
+
return this.checkoutService.getCheckout().pipe(operators.concatMap(function (checkout) { return _this.checkoutService.updateCheckoutUser(i1.Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { user: user }))); }), operators.concatMap(function (checkout) { return __awaiter(_this, void 0, void 0, function () {
|
|
1526
|
+
var _a, _b, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
1527
|
+
var _this = this;
|
|
1528
|
+
return __generator(this, function (_s) {
|
|
1529
|
+
switch (_s.label) {
|
|
1530
|
+
case 0:
|
|
1531
|
+
_j = (_h = this.checkoutService)
|
|
1532
|
+
.updateCheckoutLineItems;
|
|
1533
|
+
_l = (_k = i1.Checkout).toInstance;
|
|
1534
|
+
_o = (_m = Object).assign;
|
|
1535
|
+
_p = [Object.assign({}, checkout.toPlain())];
|
|
1536
|
+
_q = {};
|
|
1537
|
+
if (!((_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.length)) return [3 /*break*/, 2];
|
|
1538
|
+
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) {
|
|
1539
|
+
switch (_h.label) {
|
|
1540
|
+
case 0: return [4 /*yield*/, this.buildLineItem({ checkout: checkout, item: item })];
|
|
1541
|
+
case 1: return [2 /*return*/, (_h.sent()).lineItem];
|
|
1542
|
+
}
|
|
1543
|
+
}); }); }))];
|
|
1544
|
+
case 1:
|
|
1545
|
+
_r = _s.sent();
|
|
1546
|
+
return [3 /*break*/, 3];
|
|
1547
|
+
case 2:
|
|
1548
|
+
_r = [];
|
|
1549
|
+
_s.label = 3;
|
|
1550
|
+
case 3: return [2 /*return*/, _j.apply(_h, [_l.apply(_k, [_o.apply(_m, _p.concat([(_q.lineItems = _r, _q)]))])])
|
|
1551
|
+
.toPromise()];
|
|
1552
|
+
}
|
|
1553
|
+
});
|
|
1554
|
+
}); }), operators.map(function (checkout) { return _this.generateCartObject(checkout.lineItems); }), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
|
|
1663
1555
|
};
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
{
|
|
1670
|
-
provide: i3.ProductsIndex,
|
|
1671
|
-
useFactory: function (configuration) { return new i3.ProductsIndex(new i3.AxiosAdapter(configuration)); },
|
|
1672
|
-
deps: [ES_CONFIG],
|
|
1673
|
-
},
|
|
1674
|
-
] });
|
|
1675
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularElasticSeachModule, decorators: [{
|
|
1676
|
-
type: i0.NgModule,
|
|
1677
|
-
args: [{
|
|
1678
|
-
providers: [
|
|
1679
|
-
{
|
|
1680
|
-
provide: i3.ProductsIndex,
|
|
1681
|
-
useFactory: function (configuration) { return new i3.ProductsIndex(new i3.AxiosAdapter(configuration)); },
|
|
1682
|
-
deps: [ES_CONFIG],
|
|
1683
|
-
},
|
|
1684
|
-
],
|
|
1685
|
-
}]
|
|
1686
|
-
}] });
|
|
1687
|
-
|
|
1688
|
-
var AngularFirestoreModule = /** @class */ (function () {
|
|
1689
|
-
function AngularFirestoreModule() {
|
|
1690
|
-
}
|
|
1691
|
-
AngularFirestoreModule.initializeApp = function (options, nameOrConfig) {
|
|
1692
|
-
return {
|
|
1693
|
-
ngModule: AngularFirestoreModule,
|
|
1694
|
-
providers: [
|
|
1695
|
-
{ provide: fire.FIREBASE_OPTIONS, useValue: options.firebase },
|
|
1696
|
-
{ provide: fire.FIREBASE_APP_NAME, useValue: nameOrConfig },
|
|
1697
|
-
{ provide: ES_CONFIG, useValue: options.elasticSearch },
|
|
1698
|
-
],
|
|
1699
|
-
};
|
|
1556
|
+
CartService.prototype.clearCart = function () {
|
|
1557
|
+
var _this = this;
|
|
1558
|
+
return this.checkoutService.getCheckout().pipe(operators.map(function (checkout) {
|
|
1559
|
+
_this.checkoutService.clearCheckoutFromSession();
|
|
1560
|
+
return checkout;
|
|
1561
|
+
}), operators.concatMap(function (oldCheckout) { return _this.buildCartFromCheckout(oldCheckout); }), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
|
|
1700
1562
|
};
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
{
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
}
|
|
1914
|
-
{
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
},
|
|
1919
|
-
|
|
1920
|
-
},
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
{
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
}
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
1563
|
+
CartService.prototype.buildCartFromCheckout = function (checkoutData) {
|
|
1564
|
+
var _this = this;
|
|
1565
|
+
return this.checkoutService.getCheckout(checkoutData).pipe(operators.map(function (checkout) { return checkout.lineItems; }), operators.concatMap(function (lineItems) { return rxjs.of(_this.generateCartObject(lineItems)); }));
|
|
1566
|
+
};
|
|
1567
|
+
CartService.prototype.roundPrice = function (productPrice) {
|
|
1568
|
+
var price = productPrice.price, fullPrice = productPrice.fullPrice, subscriberPrice = productPrice.subscriberPrice;
|
|
1569
|
+
return Object.assign(Object.assign(Object.assign({}, productPrice), { price: Number(price.toFixed(2)), fullPrice: Number(fullPrice.toFixed(2)) }), (subscriberPrice && { subscriberPrice: Number(subscriberPrice.toFixed(2)) }));
|
|
1570
|
+
};
|
|
1571
|
+
CartService.prototype.getProductData = function (productId) {
|
|
1572
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1573
|
+
var product, variant, error_1, variants;
|
|
1574
|
+
return __generator(this, function (_h) {
|
|
1575
|
+
switch (_h.label) {
|
|
1576
|
+
case 0:
|
|
1577
|
+
_h.trys.push([0, 2, , 5]);
|
|
1578
|
+
return [4 /*yield*/, this.productRepository.get({ id: productId })];
|
|
1579
|
+
case 1:
|
|
1580
|
+
product = _h.sent();
|
|
1581
|
+
return [3 /*break*/, 5];
|
|
1582
|
+
case 2:
|
|
1583
|
+
error_1 = _h.sent();
|
|
1584
|
+
if (!(error_1 instanceof i1.NotFoundError))
|
|
1585
|
+
throw error_1;
|
|
1586
|
+
return [4 /*yield*/, this.variantRepository.find({ filters: { id: productId } })];
|
|
1587
|
+
case 3:
|
|
1588
|
+
variants = (_h.sent()).data;
|
|
1589
|
+
variant = variants.shift();
|
|
1590
|
+
if (!variant)
|
|
1591
|
+
throw error_1;
|
|
1592
|
+
return [4 /*yield*/, this.productRepository.get({ id: variant.productId })];
|
|
1593
|
+
case 4:
|
|
1594
|
+
product = _h.sent();
|
|
1595
|
+
return [3 /*break*/, 5];
|
|
1596
|
+
case 5: return [2 /*return*/, Object.assign(Object.assign({}, product.toPlain()), (variant && Object.assign({}, variant.toPlain())))];
|
|
1597
|
+
}
|
|
1598
|
+
});
|
|
1599
|
+
});
|
|
1600
|
+
};
|
|
1601
|
+
CartService.prototype.getGifts = function () {
|
|
1602
|
+
var _this = this;
|
|
1603
|
+
return this.checkoutService.getCheckout().pipe(operators.mergeMap(function (checkout) { return __awaiter(_this, void 0, void 0, function () {
|
|
1604
|
+
var notGiftItems, cartTotal, campaigns, elegibleCampaigns, _loop_1, this_1, campaigns_1, campaigns_1_1, campaign, e_1_1, campaingnProducts, elegibleCampaigns_1, elegibleCampaigns_1_1, campaign, elegibleProducts, _h, _j, product, productData, gift, e_2_1, e_3_1, gifts;
|
|
1605
|
+
var e_1, _k, e_3, _l, e_2, _m;
|
|
1606
|
+
return __generator(this, function (_o) {
|
|
1607
|
+
switch (_o.label) {
|
|
1608
|
+
case 0:
|
|
1609
|
+
notGiftItems = checkout.lineItems ? checkout.lineItems.filter(function (item) { return !item.isGift; }) : [];
|
|
1610
|
+
if (!notGiftItems.length)
|
|
1611
|
+
return [2 /*return*/, Object.assign(Object.assign({}, checkout), { lineItems: [] })];
|
|
1612
|
+
cartTotal = notGiftItems.reduce(function (a, b) { return a + b.pricePaid * b.quantity; }, 0);
|
|
1613
|
+
return [4 /*yield*/, this.buy2WinRepository
|
|
1614
|
+
.find({
|
|
1615
|
+
filters: {
|
|
1616
|
+
active: { operator: i1.Where.EQUALS, value: true },
|
|
1617
|
+
shop: { operator: i1.Where.EQUALS, value: this.defaultShop },
|
|
1618
|
+
},
|
|
1619
|
+
})
|
|
1620
|
+
.then(function (data) { return data.data; })];
|
|
1621
|
+
case 1:
|
|
1622
|
+
campaigns = _o.sent();
|
|
1623
|
+
if (!campaigns.length)
|
|
1624
|
+
return [2 /*return*/, Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems })];
|
|
1625
|
+
elegibleCampaigns = [];
|
|
1626
|
+
_loop_1 = function (campaign) {
|
|
1627
|
+
var today, categoriesCampaing, categoriesCampaingFullTree, categoriesCampaing_1, categoriesCampaing_1_1, id, children, e_4_1, categoriesCampaingTree_1, filterProductsCategories, cartTotalCategories;
|
|
1628
|
+
var e_4, _p;
|
|
1629
|
+
return __generator(this, function (_q) {
|
|
1630
|
+
switch (_q.label) {
|
|
1631
|
+
case 0:
|
|
1632
|
+
today = new Date().getDate();
|
|
1633
|
+
if (!(campaign.startDate.getDate() <= today) && !(campaign.endDate.getDate() >= today))
|
|
1634
|
+
return [2 /*return*/, "continue"];
|
|
1635
|
+
if (!campaign.activeCategory) return [3 /*break*/, 9];
|
|
1636
|
+
categoriesCampaing = campaign.categories.map(function (c) { return c.id.toString(); });
|
|
1637
|
+
categoriesCampaingFullTree = [];
|
|
1638
|
+
_q.label = 1;
|
|
1639
|
+
case 1:
|
|
1640
|
+
_q.trys.push([1, 6, 7, 8]);
|
|
1641
|
+
categoriesCampaing_1 = (e_4 = void 0, __values(categoriesCampaing)), categoriesCampaing_1_1 = categoriesCampaing_1.next();
|
|
1642
|
+
_q.label = 2;
|
|
1643
|
+
case 2:
|
|
1644
|
+
if (!!categoriesCampaing_1_1.done) return [3 /*break*/, 5];
|
|
1645
|
+
id = categoriesCampaing_1_1.value;
|
|
1646
|
+
return [4 /*yield*/, this_1.categoryRepository.getChildren(parseInt(id))];
|
|
1647
|
+
case 3:
|
|
1648
|
+
children = _q.sent();
|
|
1649
|
+
categoriesCampaingFullTree.push.apply(categoriesCampaingFullTree, __spreadArray([id], __read(children.map(function (c) { return c.id.toString(); }))));
|
|
1650
|
+
_q.label = 4;
|
|
1651
|
+
case 4:
|
|
1652
|
+
categoriesCampaing_1_1 = categoriesCampaing_1.next();
|
|
1653
|
+
return [3 /*break*/, 2];
|
|
1654
|
+
case 5: return [3 /*break*/, 8];
|
|
1655
|
+
case 6:
|
|
1656
|
+
e_4_1 = _q.sent();
|
|
1657
|
+
e_4 = { error: e_4_1 };
|
|
1658
|
+
return [3 /*break*/, 8];
|
|
1659
|
+
case 7:
|
|
1660
|
+
try {
|
|
1661
|
+
if (categoriesCampaing_1_1 && !categoriesCampaing_1_1.done && (_p = categoriesCampaing_1.return)) _p.call(categoriesCampaing_1);
|
|
1662
|
+
}
|
|
1663
|
+
finally { if (e_4) throw e_4.error; }
|
|
1664
|
+
return [7 /*endfinally*/];
|
|
1665
|
+
case 8:
|
|
1666
|
+
categoriesCampaingTree_1 = __spreadArray([], __read(new Set(categoriesCampaingFullTree)));
|
|
1667
|
+
filterProductsCategories = checkout.lineItems.filter(function (l) {
|
|
1668
|
+
var _a;
|
|
1669
|
+
if (!l.categories || !((_a = l.categories) === null || _a === void 0 ? void 0 : _a.length))
|
|
1670
|
+
return true;
|
|
1671
|
+
return l.categories.some(function (c) { return categoriesCampaingTree_1.some(function (cat) { return cat == c; }); });
|
|
1672
|
+
});
|
|
1673
|
+
if (filterProductsCategories.length) {
|
|
1674
|
+
cartTotalCategories = filterProductsCategories.reduce(function (a, b) { return a + b.pricePaid * b.quantity; }, 0);
|
|
1675
|
+
if (cartTotalCategories >= campaign.cartValueMin)
|
|
1676
|
+
elegibleCampaigns.push(campaign);
|
|
1677
|
+
}
|
|
1678
|
+
return [3 /*break*/, 10];
|
|
1679
|
+
case 9:
|
|
1680
|
+
if (campaign.cartValue && campaign.cartValue > 0) {
|
|
1681
|
+
if (campaign.cartValue <= cartTotal)
|
|
1682
|
+
elegibleCampaigns.push(campaign);
|
|
1683
|
+
}
|
|
1684
|
+
_q.label = 10;
|
|
1685
|
+
case 10: return [2 /*return*/];
|
|
1686
|
+
}
|
|
1687
|
+
});
|
|
1688
|
+
};
|
|
1689
|
+
this_1 = this;
|
|
1690
|
+
_o.label = 2;
|
|
1691
|
+
case 2:
|
|
1692
|
+
_o.trys.push([2, 7, 8, 9]);
|
|
1693
|
+
campaigns_1 = __values(campaigns), campaigns_1_1 = campaigns_1.next();
|
|
1694
|
+
_o.label = 3;
|
|
1695
|
+
case 3:
|
|
1696
|
+
if (!!campaigns_1_1.done) return [3 /*break*/, 6];
|
|
1697
|
+
campaign = campaigns_1_1.value;
|
|
1698
|
+
return [5 /*yield**/, _loop_1(campaign)];
|
|
1699
|
+
case 4:
|
|
1700
|
+
_o.sent();
|
|
1701
|
+
_o.label = 5;
|
|
1702
|
+
case 5:
|
|
1703
|
+
campaigns_1_1 = campaigns_1.next();
|
|
1704
|
+
return [3 /*break*/, 3];
|
|
1705
|
+
case 6: return [3 /*break*/, 9];
|
|
1706
|
+
case 7:
|
|
1707
|
+
e_1_1 = _o.sent();
|
|
1708
|
+
e_1 = { error: e_1_1 };
|
|
1709
|
+
return [3 /*break*/, 9];
|
|
1710
|
+
case 8:
|
|
1711
|
+
try {
|
|
1712
|
+
if (campaigns_1_1 && !campaigns_1_1.done && (_k = campaigns_1.return)) _k.call(campaigns_1);
|
|
1713
|
+
}
|
|
1714
|
+
finally { if (e_1) throw e_1.error; }
|
|
1715
|
+
return [7 /*endfinally*/];
|
|
1716
|
+
case 9:
|
|
1717
|
+
if (!elegibleCampaigns.length)
|
|
1718
|
+
return [2 /*return*/, Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems })];
|
|
1719
|
+
campaingnProducts = [];
|
|
1720
|
+
_o.label = 10;
|
|
1721
|
+
case 10:
|
|
1722
|
+
_o.trys.push([10, 22, 23, 24]);
|
|
1723
|
+
elegibleCampaigns_1 = __values(elegibleCampaigns), elegibleCampaigns_1_1 = elegibleCampaigns_1.next();
|
|
1724
|
+
_o.label = 11;
|
|
1725
|
+
case 11:
|
|
1726
|
+
if (!!elegibleCampaigns_1_1.done) return [3 /*break*/, 21];
|
|
1727
|
+
campaign = elegibleCampaigns_1_1.value;
|
|
1728
|
+
elegibleProducts = [];
|
|
1729
|
+
_o.label = 12;
|
|
1730
|
+
case 12:
|
|
1731
|
+
_o.trys.push([12, 17, 18, 19]);
|
|
1732
|
+
_h = (e_2 = void 0, __values(campaign.products)), _j = _h.next();
|
|
1733
|
+
_o.label = 13;
|
|
1734
|
+
case 13:
|
|
1735
|
+
if (!!_j.done) return [3 /*break*/, 16];
|
|
1736
|
+
product = _j.value;
|
|
1737
|
+
return [4 /*yield*/, this.productRepository.find({ filters: { sku: product } })];
|
|
1738
|
+
case 14:
|
|
1739
|
+
productData = (_o.sent()).data;
|
|
1740
|
+
if (!productData.length)
|
|
1741
|
+
return [3 /*break*/, 15];
|
|
1742
|
+
gift = productData.shift();
|
|
1743
|
+
if (gift.stock.quantity < 1)
|
|
1744
|
+
return [3 /*break*/, 15];
|
|
1745
|
+
elegibleProducts.push(gift);
|
|
1746
|
+
_o.label = 15;
|
|
1747
|
+
case 15:
|
|
1748
|
+
_j = _h.next();
|
|
1749
|
+
return [3 /*break*/, 13];
|
|
1750
|
+
case 16: return [3 /*break*/, 19];
|
|
1751
|
+
case 17:
|
|
1752
|
+
e_2_1 = _o.sent();
|
|
1753
|
+
e_2 = { error: e_2_1 };
|
|
1754
|
+
return [3 /*break*/, 19];
|
|
1755
|
+
case 18:
|
|
1756
|
+
try {
|
|
1757
|
+
if (_j && !_j.done && (_m = _h.return)) _m.call(_h);
|
|
1758
|
+
}
|
|
1759
|
+
finally { if (e_2) throw e_2.error; }
|
|
1760
|
+
return [7 /*endfinally*/];
|
|
1761
|
+
case 19:
|
|
1762
|
+
campaingnProducts.push(elegibleProducts);
|
|
1763
|
+
_o.label = 20;
|
|
1764
|
+
case 20:
|
|
1765
|
+
elegibleCampaigns_1_1 = elegibleCampaigns_1.next();
|
|
1766
|
+
return [3 /*break*/, 11];
|
|
1767
|
+
case 21: return [3 /*break*/, 24];
|
|
1768
|
+
case 22:
|
|
1769
|
+
e_3_1 = _o.sent();
|
|
1770
|
+
e_3 = { error: e_3_1 };
|
|
1771
|
+
return [3 /*break*/, 24];
|
|
1772
|
+
case 23:
|
|
1773
|
+
try {
|
|
1774
|
+
if (elegibleCampaigns_1_1 && !elegibleCampaigns_1_1.done && (_l = elegibleCampaigns_1.return)) _l.call(elegibleCampaigns_1);
|
|
1775
|
+
}
|
|
1776
|
+
finally { if (e_3) throw e_3.error; }
|
|
1777
|
+
return [7 /*endfinally*/];
|
|
1778
|
+
case 24:
|
|
1779
|
+
if (!campaingnProducts.length)
|
|
1780
|
+
return [2 /*return*/, Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems })];
|
|
1781
|
+
gifts = this.giftToLineItems([].concat.apply([], __spreadArray([], __read(campaingnProducts))));
|
|
1782
|
+
return [2 /*return*/, Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems.concat(gifts) })];
|
|
1783
|
+
}
|
|
1784
|
+
});
|
|
1785
|
+
}); }), operators.concatMap(function (checkout) { return _this.checkoutService.updateCheckoutLineItems(checkout); }), operators.map(function (checkout) { return _this.generateCartObject(checkout.lineItems); }), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
|
|
1786
|
+
};
|
|
1787
|
+
CartService.prototype.giftToLineItems = function (items) {
|
|
1788
|
+
return items.map(function (item) {
|
|
1789
|
+
var _a;
|
|
1790
|
+
var brand = item.brand, categories = item.categories, id = item.id, name = item.name, price = item.price, sku = item.sku, slug = item.slug, stock = item.stock, weight = item.weight, EAN = item.EAN;
|
|
1791
|
+
var image = ((_a = item === null || item === void 0 ? void 0 : item.miniatures) === null || _a === void 0 ? void 0 : _a.length) ? item.miniatures[0] : item.images[0];
|
|
1792
|
+
return i1.LineItem.toInstance({
|
|
1793
|
+
brand: brand,
|
|
1794
|
+
categories: categories,
|
|
1795
|
+
id: id.toString(),
|
|
1796
|
+
name: name,
|
|
1797
|
+
price: price,
|
|
1798
|
+
sku: sku,
|
|
1799
|
+
slug: slug,
|
|
1800
|
+
stock: stock,
|
|
1801
|
+
weight: weight,
|
|
1802
|
+
EAN: EAN,
|
|
1803
|
+
image: image,
|
|
1804
|
+
pricePaid: 0,
|
|
1805
|
+
quantity: 1,
|
|
1806
|
+
isGift: true,
|
|
1807
|
+
});
|
|
1808
|
+
});
|
|
1809
|
+
};
|
|
1810
|
+
return CartService;
|
|
1811
|
+
}());
|
|
1812
|
+
CartService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CartService, deps: [{ token: AuthService }, { token: CheckoutService }, { token: DEFAULT_SHOP }, { token: 'ProductRepository' }, { token: 'CategoryRepository' }, { token: 'VariantRepository' }, { token: 'Buy2WinRepository' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
1813
|
+
CartService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CartService });
|
|
1814
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CartService, decorators: [{
|
|
1815
|
+
type: i0.Injectable
|
|
1816
|
+
}], ctorParameters: function () {
|
|
1817
|
+
return [{ type: AuthService }, { type: CheckoutService }, { type: i1__namespace$1.Shops, decorators: [{
|
|
1818
|
+
type: i0.Inject,
|
|
1819
|
+
args: [DEFAULT_SHOP]
|
|
1820
|
+
}] }, { type: undefined, decorators: [{
|
|
1821
|
+
type: i0.Inject,
|
|
1822
|
+
args: ['ProductRepository']
|
|
1823
|
+
}] }, { type: undefined, decorators: [{
|
|
1824
|
+
type: i0.Inject,
|
|
1825
|
+
args: ['CategoryRepository']
|
|
1826
|
+
}] }, { type: undefined, decorators: [{
|
|
1827
|
+
type: i0.Inject,
|
|
1828
|
+
args: ['VariantRepository']
|
|
1829
|
+
}] }, { type: i1__namespace$1.Buy2WinFirestoreRepository, decorators: [{
|
|
1830
|
+
type: i0.Inject,
|
|
1831
|
+
args: ['Buy2WinRepository']
|
|
1832
|
+
}] }];
|
|
1833
|
+
} });
|
|
1834
|
+
|
|
1835
|
+
var CatalogService = /** @class */ (function () {
|
|
1836
|
+
function CatalogService(productRepository, categoryStructureAdapter, shop) {
|
|
1837
|
+
this.productRepository = productRepository;
|
|
1838
|
+
this.categoryStructureAdapter = categoryStructureAdapter;
|
|
1839
|
+
this.shop = shop;
|
|
1840
|
+
this.buildFilterQuery = function (_j) {
|
|
1841
|
+
var clubDiscount = _j.clubDiscount, brands = _j.brands, prices = _j.prices, gender = _j.gender, tags = _j.tags, rate = _j.rate;
|
|
1842
|
+
var filters = {};
|
|
1843
|
+
if (clubDiscount === null || clubDiscount === void 0 ? void 0 : clubDiscount.length)
|
|
1844
|
+
i1.set(filters, 'price.subscriberDiscountPercentage', { operator: i1.Where.IN, value: clubDiscount });
|
|
1845
|
+
if (brands === null || brands === void 0 ? void 0 : brands.length)
|
|
1846
|
+
filters.brand = { operator: i1.Where.IN, value: brands };
|
|
1847
|
+
if (gender === null || gender === void 0 ? void 0 : gender.length)
|
|
1848
|
+
filters.tags = {
|
|
1849
|
+
operator: i1.Where.IN,
|
|
1850
|
+
value: gender
|
|
1851
|
+
.map(function (genderOptions) { return genderOptions === 'female' ? 'feminino' : genderOptions === 'male' ? 'masculino' : null; })
|
|
1852
|
+
.filter(Boolean),
|
|
1853
|
+
};
|
|
1854
|
+
if ((prices === null || prices === void 0 ? void 0 : prices.min) || (prices === null || prices === void 0 ? void 0 : prices.max))
|
|
1855
|
+
i1.set(filters, prices.subscriberPrice ? 'price.subscriberPrice' : 'price.price', __spreadArray(__spreadArray([], __read((prices.min ? [{ operator: i1.Where.GTE, value: prices.min }] : []))), __read((prices.max ? [{ operator: i1.Where.LTE, value: prices.max }] : []))));
|
|
1856
|
+
if (rate)
|
|
1857
|
+
filters.rate = { operator: i1.Where.GTE, value: rate };
|
|
1858
|
+
if (tags === null || tags === void 0 ? void 0 : tags.length)
|
|
1859
|
+
filters.tags = { operator: i1.Where.LIKE, value: tags };
|
|
1860
|
+
return filters;
|
|
1861
|
+
};
|
|
1862
|
+
this.buildSortQuery = function (sort) {
|
|
1863
|
+
if (!sort || sort === 'most-relevant')
|
|
1864
|
+
return {};
|
|
1865
|
+
if (sort === 'best-sellers')
|
|
1866
|
+
return { shoppingCount: 'desc' };
|
|
1867
|
+
if (sort === 'biggest-price')
|
|
1868
|
+
return { price: 'desc' };
|
|
1869
|
+
if (sort === 'lowest-price')
|
|
1870
|
+
return { price: 'asc' };
|
|
1871
|
+
if (sort === 'best-rating')
|
|
1872
|
+
return { rate: 'desc' };
|
|
1873
|
+
if (sort === 'news')
|
|
1874
|
+
return { createdAt: 'desc' };
|
|
1875
|
+
};
|
|
1876
|
+
this.buildLimitQuery = function (options) {
|
|
1877
|
+
var limit = (options === null || options === void 0 ? void 0 : options.perPage) || 20;
|
|
1878
|
+
return {
|
|
1879
|
+
limit: limit,
|
|
1880
|
+
offset: (((options === null || options === void 0 ? void 0 : options.page) || 1) - 1) * limit,
|
|
1881
|
+
};
|
|
1882
|
+
};
|
|
1883
|
+
}
|
|
1884
|
+
CatalogService.prototype.fetchProducts = function (category, options) {
|
|
1885
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1886
|
+
var limits, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
1887
|
+
return __generator(this, function (_w) {
|
|
1888
|
+
switch (_w.label) {
|
|
1889
|
+
case 0:
|
|
1890
|
+
limits = this.buildLimitQuery(options);
|
|
1891
|
+
_k = (_j = this.productRepository)
|
|
1892
|
+
.findCatalog;
|
|
1893
|
+
_m = (_l = Object).assign;
|
|
1894
|
+
_p = (_o = Object).assign;
|
|
1895
|
+
_q = {};
|
|
1896
|
+
_s = (_r = Object).assign;
|
|
1897
|
+
_u = (_t = Object).assign;
|
|
1898
|
+
_v = [{}];
|
|
1899
|
+
return [4 /*yield*/, this.categoryStructureAdapter.buildProductFilterByCategory(category)];
|
|
1900
|
+
case 1: return [4 /*yield*/, _k.apply(_j, [_m.apply(_l, [_p.apply(_o, [(_q.filters = _s.apply(_r, [_u.apply(_t, _v.concat([(_w.sent())])), this.buildFilterQuery((options === null || options === void 0 ? void 0 : options.filters) || {})]), _q), ((options === null || options === void 0 ? void 0 : options.sort) ? { orderBy: this.buildSortQuery(options === null || options === void 0 ? void 0 : options.sort) } : {})]), { limits: limits, options: { minimal: ['price'], maximum: ['price'] } }]), (options === null || options === void 0 ? void 0 : options.mainGender) || this.shop === i1.Shops.MENSMARKET ? 'male' : 'female'])
|
|
1901
|
+
.then(function (_j) {
|
|
1902
|
+
var data = _j.data, total = _j.count, maximum = _j.maximum, minimal = _j.minimal;
|
|
1903
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1904
|
+
return ({
|
|
1905
|
+
products: { data: data.map(function (product) { return i1.RoundProductPricesHelper.roundProductPrices(product); }), total: total },
|
|
1906
|
+
pages: Math.ceil(total / limits.limit),
|
|
1907
|
+
prices: {
|
|
1908
|
+
price: { min: +((_b = (_a = minimal === null || minimal === void 0 ? void 0 : minimal.price) === null || _a === void 0 ? void 0 : _a.price) === null || _b === void 0 ? void 0 : _b.toFixed(2)), max: +((_d = (_c = maximum === null || maximum === void 0 ? void 0 : maximum.price) === null || _c === void 0 ? void 0 : _c.price) === null || _d === void 0 ? void 0 : _d.toFixed(2)) },
|
|
1909
|
+
subscriberPrice: {
|
|
1910
|
+
min: +((_f = (_e = minimal === null || minimal === void 0 ? void 0 : minimal.price) === null || _e === void 0 ? void 0 : _e.subscriberPrice) === null || _f === void 0 ? void 0 : _f.toFixed(2)),
|
|
1911
|
+
max: +((_h = (_g = maximum === null || maximum === void 0 ? void 0 : maximum.price) === null || _g === void 0 ? void 0 : _g.subscriberPrice) === null || _h === void 0 ? void 0 : _h.toFixed(2)),
|
|
1912
|
+
},
|
|
1913
|
+
},
|
|
1914
|
+
});
|
|
1915
|
+
})];
|
|
1916
|
+
case 2: return [2 /*return*/, _w.sent()];
|
|
1917
|
+
}
|
|
1918
|
+
});
|
|
1919
|
+
});
|
|
1920
|
+
};
|
|
1921
|
+
return CatalogService;
|
|
1922
|
+
}());
|
|
1923
|
+
CatalogService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CatalogService, deps: [{ token: 'ProductRepository' }, { token: CATEGORY_STRUCTURE }, { token: DEFAULT_SHOP }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
1924
|
+
CatalogService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CatalogService });
|
|
1925
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CatalogService, decorators: [{
|
|
1926
|
+
type: i0.Injectable
|
|
1927
|
+
}], ctorParameters: function () {
|
|
1928
|
+
return [{ type: undefined, decorators: [{
|
|
1929
|
+
type: i0.Inject,
|
|
1930
|
+
args: ['ProductRepository']
|
|
1931
|
+
}] }, { type: undefined, decorators: [{
|
|
1932
|
+
type: i0.Inject,
|
|
1933
|
+
args: [CATEGORY_STRUCTURE]
|
|
1934
|
+
}] }, { type: i1__namespace$1.Shops, decorators: [{
|
|
1935
|
+
type: i0.Inject,
|
|
1936
|
+
args: [DEFAULT_SHOP]
|
|
1937
|
+
}] }];
|
|
1938
|
+
} });
|
|
1939
|
+
|
|
1940
|
+
var CategoryService = /** @class */ (function () {
|
|
1941
|
+
function CategoryService(productRepository, categoryRepository, categoryFilterRepository, categoryStructureAdapter, shop) {
|
|
1942
|
+
this.productRepository = productRepository;
|
|
1943
|
+
this.categoryRepository = categoryRepository;
|
|
1944
|
+
this.categoryFilterRepository = categoryFilterRepository;
|
|
1945
|
+
this.categoryStructureAdapter = categoryStructureAdapter;
|
|
1946
|
+
this.shop = shop;
|
|
1947
|
+
}
|
|
1948
|
+
CategoryService.prototype.fetchBrands = function (category, mainGender) {
|
|
1949
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1950
|
+
var brands, _a, _b, _c;
|
|
1951
|
+
return __generator(this, function (_d) {
|
|
1952
|
+
switch (_d.label) {
|
|
1953
|
+
case 0:
|
|
1954
|
+
_b = (_a = this.productRepository)
|
|
1955
|
+
.findCatalog;
|
|
1956
|
+
_c = {};
|
|
1957
|
+
return [4 /*yield*/, this.categoryStructureAdapter.buildProductFilterByCategory(category)];
|
|
1958
|
+
case 1: return [4 /*yield*/, _b.apply(_a, [(_c.filters = _d.sent(),
|
|
1959
|
+
_c.fields = ['brand'],
|
|
1960
|
+
_c), mainGender || this.shop === i1.Shops.MENSMARKET ? 'male' : 'female'])
|
|
1961
|
+
.then(function (_a) {
|
|
1962
|
+
var data = _a.data;
|
|
1963
|
+
return Object.keys(data.map(function (product) { return product.brand; }).reduce(function (brands, brand) {
|
|
1964
|
+
var _a;
|
|
1965
|
+
return (Object.assign(Object.assign({}, brands), (_a = {}, _a[brand] = true, _a)));
|
|
1966
|
+
}, {}));
|
|
1967
|
+
})];
|
|
1968
|
+
case 2:
|
|
1969
|
+
brands = _d.sent();
|
|
1970
|
+
return [2 /*return*/, this.categoryRepository
|
|
1971
|
+
.find({ filters: { brandCategory: true }, orderBy: { name: 'asc' } })
|
|
1972
|
+
.then(function (_a) {
|
|
1973
|
+
var data = _a.data;
|
|
1974
|
+
return data.filter(function (category) { return brands.includes(category.conditions.brand); });
|
|
1975
|
+
})];
|
|
1976
|
+
}
|
|
1977
|
+
});
|
|
1978
|
+
});
|
|
1979
|
+
};
|
|
1980
|
+
CategoryService.prototype.fetchFilterOptions = function (category, filters) {
|
|
1981
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1982
|
+
var categoryFilters, _a;
|
|
1983
|
+
return __generator(this, function (_b) {
|
|
1984
|
+
switch (_b.label) {
|
|
1985
|
+
case 0:
|
|
1986
|
+
if (!(category.filters && category.filters.length)) return [3 /*break*/, 1];
|
|
1987
|
+
_a = category.filters;
|
|
1988
|
+
return [3 /*break*/, 3];
|
|
1989
|
+
case 1: return [4 /*yield*/, this.categoryFilterRepository
|
|
1990
|
+
.find({ filters: { categoryId: +category.id } })
|
|
1991
|
+
.then(function (_a) {
|
|
1992
|
+
var data = _a.data;
|
|
1993
|
+
return data.map(function (categoryFilter) { return categoryFilter.filter; });
|
|
1994
|
+
})];
|
|
1995
|
+
case 2:
|
|
1996
|
+
_a = _b.sent();
|
|
1997
|
+
_b.label = 3;
|
|
1998
|
+
case 3:
|
|
1999
|
+
categoryFilters = _a;
|
|
2000
|
+
return [2 /*return*/, (filters === null || filters === void 0 ? void 0 : filters.length)
|
|
2001
|
+
? categoryFilters.filter(function (categoryFilter) { return !filters || !filters.length || categoryFilter.options.some(function (option) { return filters.includes(option.id); }); })
|
|
2002
|
+
: categoryFilters];
|
|
2003
|
+
}
|
|
2004
|
+
});
|
|
2005
|
+
});
|
|
2006
|
+
};
|
|
2007
|
+
return CategoryService;
|
|
2008
|
+
}());
|
|
2009
|
+
CategoryService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CategoryService, deps: [{ token: 'ProductRepository' }, { token: 'CategoryRepository' }, { token: 'CategoryFilterRepository' }, { token: CATEGORY_STRUCTURE }, { token: DEFAULT_SHOP }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
2010
|
+
CategoryService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CategoryService });
|
|
2011
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CategoryService, decorators: [{
|
|
2012
|
+
type: i0.Injectable
|
|
2013
|
+
}], ctorParameters: function () {
|
|
2014
|
+
return [{ type: undefined, decorators: [{
|
|
2015
|
+
type: i0.Inject,
|
|
2016
|
+
args: ['ProductRepository']
|
|
2017
|
+
}] }, { type: undefined, decorators: [{
|
|
2018
|
+
type: i0.Inject,
|
|
2019
|
+
args: ['CategoryRepository']
|
|
2020
|
+
}] }, { type: undefined, decorators: [{
|
|
2021
|
+
type: i0.Inject,
|
|
2022
|
+
args: ['CategoryFilterRepository']
|
|
2023
|
+
}] }, { type: undefined, decorators: [{
|
|
2024
|
+
type: i0.Inject,
|
|
2025
|
+
args: [CATEGORY_STRUCTURE]
|
|
2026
|
+
}] }, { type: i1__namespace$1.Shops, decorators: [{
|
|
2027
|
+
type: i0.Inject,
|
|
2028
|
+
args: [DEFAULT_SHOP]
|
|
2029
|
+
}] }];
|
|
2030
|
+
} });
|
|
2031
|
+
|
|
2032
|
+
exports.ProductSorts = void 0;
|
|
2033
|
+
(function (ProductSorts) {
|
|
2034
|
+
ProductSorts["MOST_RELEVANT"] = "most-relevant";
|
|
2035
|
+
ProductSorts["BEST_SELLER"] = "best-sellers";
|
|
2036
|
+
ProductSorts["BIGGEST_PRICE"] = "biggest-price";
|
|
2037
|
+
ProductSorts["LOWEST_PRICE"] = "lowest-price";
|
|
2038
|
+
ProductSorts["BIGGEST_DISCOUNT"] = "biggest-discount";
|
|
2039
|
+
ProductSorts["BEST_RATING"] = "best-rating";
|
|
2040
|
+
ProductSorts["NEWS"] = "news";
|
|
2041
|
+
})(exports.ProductSorts || (exports.ProductSorts = {}));
|
|
2042
|
+
|
|
2043
|
+
var CategoryWithTree = /** @class */ (function (_super) {
|
|
2044
|
+
__extends(CategoryWithTree, _super);
|
|
2045
|
+
function CategoryWithTree() {
|
|
2046
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
2047
|
+
}
|
|
2048
|
+
return CategoryWithTree;
|
|
2049
|
+
}(i1.Category));
|
|
2050
|
+
__decorate([
|
|
2051
|
+
classTransformer.Type(function () { return CategoryWithTree; }),
|
|
2052
|
+
__metadata("design:type", Array)
|
|
2053
|
+
], CategoryWithTree.prototype, "children", void 0);
|
|
2054
|
+
|
|
2055
|
+
var CheckoutSubscriptionService = /** @class */ (function () {
|
|
2056
|
+
function CheckoutSubscriptionService(checkoutSubscriptionRepository, subscriptionRepository, couponService) {
|
|
2057
|
+
this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
|
|
2058
|
+
this.subscriptionRepository = subscriptionRepository;
|
|
2059
|
+
this.couponService = couponService;
|
|
2060
|
+
}
|
|
2061
|
+
CheckoutSubscriptionService.prototype.getCheckoutSubscription = function (checkoutData) {
|
|
2062
|
+
var checkoutId = cookie__default["default"].get('checkoutSubscriptionId');
|
|
2063
|
+
if (!i1.isNil(checkoutId))
|
|
2064
|
+
return rxjs.from(this.checkoutSubscriptionRepository.get({ id: checkoutId }));
|
|
2065
|
+
return rxjs.from(this.createCheckoutSubscription(checkoutData));
|
|
2066
|
+
};
|
|
2067
|
+
CheckoutSubscriptionService.prototype.createCheckoutSubscription = function (checkoutData) {
|
|
2068
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2069
|
+
var checkout;
|
|
2070
|
+
return __generator(this, function (_a) {
|
|
2071
|
+
switch (_a.label) {
|
|
2072
|
+
case 0: return [4 /*yield*/, this.checkoutSubscriptionRepository.create(Object.assign({ createdAt: new Date() }, i1.CheckoutSubscription.toInstance(i1.pick(checkoutData, ['user', 'shop'])).toPlain()))];
|
|
2073
|
+
case 1:
|
|
2074
|
+
checkout = _a.sent();
|
|
2075
|
+
cookie__default["default"].set('checkoutSubscriptionId', checkout.id);
|
|
2076
|
+
return [2 /*return*/, checkout];
|
|
2077
|
+
}
|
|
2078
|
+
});
|
|
2079
|
+
});
|
|
2080
|
+
};
|
|
2081
|
+
CheckoutSubscriptionService.prototype.clearCheckoutSubscriptionFromSession = function () {
|
|
2082
|
+
cookie__default["default"].remove('checkoutSubscriptionId');
|
|
2083
|
+
return rxjs.of();
|
|
2084
|
+
};
|
|
2085
|
+
CheckoutSubscriptionService.prototype.checkCoupon = function (nickname, userEmail) {
|
|
2086
|
+
var _this = this;
|
|
2087
|
+
return this.getCheckoutSubscription().pipe(operators.concatMap(function (checkout) { return _this.couponService
|
|
2088
|
+
.checkCoupon(nickname, i1.CheckoutTypes.SUBSCRIPTION, checkout, checkout.subscriptionPlan.name)
|
|
2089
|
+
.pipe(); }));
|
|
2090
|
+
};
|
|
2091
|
+
CheckoutSubscriptionService.prototype.calcDiscountSubscription = function (coupon) {
|
|
2092
|
+
var _this = this;
|
|
2093
|
+
return this.getCheckoutSubscription().pipe(operators.concatMap(function (checkout) { return _this.couponService.calcDiscountSubscription(coupon, checkout).pipe(); }));
|
|
2094
|
+
};
|
|
2095
|
+
return CheckoutSubscriptionService;
|
|
2096
|
+
}());
|
|
2097
|
+
CheckoutSubscriptionService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutSubscriptionService, deps: [{ token: 'CheckoutSubscriptionRepository' }, { token: 'SubscriptionRepository' }, { token: CouponService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
2098
|
+
CheckoutSubscriptionService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutSubscriptionService });
|
|
2099
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutSubscriptionService, decorators: [{
|
|
2100
|
+
type: i0.Injectable
|
|
2101
|
+
}], ctorParameters: function () {
|
|
2102
|
+
return [{ type: undefined, decorators: [{
|
|
2103
|
+
type: i0.Inject,
|
|
2104
|
+
args: ['CheckoutSubscriptionRepository']
|
|
2105
|
+
}] }, { type: undefined, decorators: [{
|
|
2106
|
+
type: i0.Inject,
|
|
2107
|
+
args: ['SubscriptionRepository']
|
|
2108
|
+
}] }, { type: CouponService }];
|
|
2109
|
+
} });
|
|
2110
|
+
|
|
2111
|
+
var HomeShopService = /** @class */ (function () {
|
|
2112
|
+
function HomeShopService(categoryRepository, homeRepository, productRepository, defaultShop) {
|
|
2113
|
+
this.categoryRepository = categoryRepository;
|
|
2114
|
+
this.homeRepository = homeRepository;
|
|
2115
|
+
this.productRepository = productRepository;
|
|
2116
|
+
this.defaultShop = defaultShop;
|
|
2117
|
+
this.buildCategoryGroupWithRequiredData = function (group) {
|
|
2118
|
+
var _a, _b;
|
|
2119
|
+
return ({
|
|
2120
|
+
category: i1.Category.toInstance(i1.pick(((_a = group === null || group === void 0 ? void 0 : group.category) === null || _a === void 0 ? void 0 : _a.toPlain()) || {}, ['id', 'name', 'slug', 'conditions'])),
|
|
2121
|
+
products: ((_b = group === null || group === void 0 ? void 0 : group.products) === null || _b === void 0 ? void 0 : _b.map(function (product) { return i1.Product.toInstance(i1.pick((product === null || product === void 0 ? void 0 : product.toPlain()) || {}, [
|
|
2122
|
+
'id',
|
|
2123
|
+
'price',
|
|
2124
|
+
'reviews',
|
|
2125
|
+
'hasVariants',
|
|
2126
|
+
'slug',
|
|
2127
|
+
'sku',
|
|
2128
|
+
'stock',
|
|
2129
|
+
'costPrice',
|
|
2130
|
+
'images',
|
|
2131
|
+
'miniatures',
|
|
2132
|
+
'name',
|
|
2133
|
+
'weight',
|
|
2134
|
+
'rate',
|
|
2135
|
+
'type',
|
|
2136
|
+
])); })) || [],
|
|
2137
|
+
});
|
|
2138
|
+
};
|
|
2139
|
+
}
|
|
2140
|
+
Object.defineProperty(HomeShopService.prototype, "homeId", {
|
|
2141
|
+
get: function () {
|
|
2142
|
+
if (this.defaultShop === i1.Shops.GLAMSHOP)
|
|
2143
|
+
return 'glamshop';
|
|
2144
|
+
if (this.defaultShop === i1.Shops.MENSMARKET)
|
|
2145
|
+
return 'mens_market';
|
|
2146
|
+
return null;
|
|
2147
|
+
},
|
|
2148
|
+
enumerable: false,
|
|
2149
|
+
configurable: true
|
|
2150
|
+
});
|
|
2151
|
+
HomeShopService.prototype.getHomeData = function () {
|
|
2152
|
+
var _this = this;
|
|
2153
|
+
return this.getHomeConfiguration().pipe(operators.map(function (home) { var _a; return (((_a = home === null || home === void 0 ? void 0 : home.data) === null || _a === void 0 ? void 0 : _a.expiresAt) > new Date() ? home : null); }), operators.concatMap(function (home) { return home
|
|
2154
|
+
? rxjs.of(home)
|
|
2155
|
+
: rxjs.forkJoin([_this.getDiscoverProducts(), _this.getFeaturedProducts(), _this.getVerticalProducts()]).pipe(operators.map(function (_c) {
|
|
2156
|
+
var _d = __read(_c, 3), discoverProducts = _d[0], featuredProducts = _d[1], verticalProducts = _d[2];
|
|
2157
|
+
return ({
|
|
2158
|
+
discoverProducts: discoverProducts,
|
|
2159
|
+
featuredProducts: featuredProducts,
|
|
2160
|
+
verticalProducts: verticalProducts,
|
|
2161
|
+
});
|
|
2162
|
+
}), operators.concatMap(function (data) { return _this.saveHomeData(data); })); }));
|
|
2163
|
+
};
|
|
2164
|
+
HomeShopService.prototype.getBanners = function (type) {
|
|
2165
|
+
return this.getHomeConfiguration().pipe(operators.map(function (home) {
|
|
2166
|
+
if (type === 'brand')
|
|
2167
|
+
return home.brandsCarousel;
|
|
2168
|
+
if (type === 'buyToWin')
|
|
2169
|
+
return [home.buyToWinBanner];
|
|
2170
|
+
if (type === 'block')
|
|
2171
|
+
return home.blockBanners;
|
|
2172
|
+
if (type === 'blog')
|
|
2173
|
+
return [home.blogBanner];
|
|
2174
|
+
}));
|
|
2175
|
+
};
|
|
2176
|
+
HomeShopService.prototype.getMinValueForFreeShipping = function () {
|
|
2177
|
+
return this.getHomeConfiguration().pipe(operators.map(function (home) { return home.minValueForFreeShipping; }));
|
|
2178
|
+
};
|
|
2179
|
+
HomeShopService.prototype.getDiscoverProducts = function () {
|
|
2180
|
+
var _this = this;
|
|
2181
|
+
return this.getHomeConfiguration().pipe(operators.concatMap(function (home) { return rxjs.from(_this.categoryRepository.getCategoriesForHome(home.discoverCategories)).pipe(operators.map(function (groups) { return groups.map(_this.buildCategoryGroupWithRequiredData); })); }));
|
|
2182
|
+
};
|
|
2183
|
+
HomeShopService.prototype.getFeaturedProducts = function () {
|
|
2184
|
+
var _this = this;
|
|
2185
|
+
return this.getHomeConfiguration().pipe(operators.concatMap(function (home) { return rxjs.from(_this.categoryRepository.getCategoriesForHome(home.featuredCategories)).pipe(operators.map(function (groups) { return groups.map(_this.buildCategoryGroupWithRequiredData); })); }));
|
|
2186
|
+
};
|
|
2187
|
+
HomeShopService.prototype.getVerticalProducts = function () {
|
|
2188
|
+
var _this = this;
|
|
2189
|
+
return this.getHomeConfiguration().pipe(operators.concatMap(function (home) { return rxjs.forkJoin(home.verticalCarousels.filter(Boolean).map(function (id) { return rxjs.from(_this.categoryRepository.get({ id: id })).pipe(operators.concatMap(function (category) { return rxjs.from(_this.productRepository.find({
|
|
2190
|
+
filters: { categories: { operator: i1.Where.IN, value: [category.id] } },
|
|
2191
|
+
limits: { limit: 12 },
|
|
2192
|
+
})).pipe(operators.map(function (products) { return ({ category: category, products: products }); })); }), operators.map(function (_c) {
|
|
2193
|
+
var category = _c.category, products = _c.products;
|
|
2194
|
+
return ({ category: category, products: products.data });
|
|
2195
|
+
}), operators.map(_this.buildCategoryGroupWithRequiredData)); })); }));
|
|
2196
|
+
};
|
|
2197
|
+
HomeShopService.prototype.getHomeConfiguration = function () {
|
|
2198
|
+
var _this = this;
|
|
2199
|
+
return rxjs.of(this.homeConfiguration).pipe(operators.concatMap(function (home) { return home
|
|
2200
|
+
? rxjs.of(home)
|
|
2201
|
+
: !_this.homeId
|
|
2202
|
+
? rxjs.throwError(new i1.RequiredArgumentError(['homeId']))
|
|
2203
|
+
: rxjs.from(_this.homeRepository.get({ id: _this.homeId })).pipe(operators.tap(function (homeLoaded) { return (_this.homeConfiguration = homeLoaded); })); }));
|
|
2204
|
+
};
|
|
2205
|
+
HomeShopService.prototype.saveHomeData = function (homeData) {
|
|
2206
|
+
var _this = this;
|
|
2207
|
+
var data = {
|
|
2208
|
+
createdAt: new Date(),
|
|
2209
|
+
expiresAt: i1.add(new Date(), { hours: 1 }),
|
|
2210
|
+
data: homeData,
|
|
2211
|
+
};
|
|
2212
|
+
return rxjs.from(this.homeRepository.update({
|
|
2213
|
+
id: this.homeId,
|
|
2214
|
+
data: data,
|
|
2215
|
+
})).pipe(operators.tap(function () { return (_this.homeConfiguration.data = data); }), operators.map(function () { return _this.homeConfiguration; }));
|
|
2216
|
+
};
|
|
2217
|
+
return HomeShopService;
|
|
2218
|
+
}());
|
|
2219
|
+
HomeShopService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: HomeShopService, deps: [{ token: 'CategoryRepository' }, { token: 'HomeRepository' }, { token: 'ProductRepository' }, { token: DEFAULT_SHOP }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
2220
|
+
HomeShopService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: HomeShopService });
|
|
2221
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: HomeShopService, decorators: [{
|
|
2222
|
+
type: i0.Injectable
|
|
2223
|
+
}], ctorParameters: function () {
|
|
2224
|
+
return [{ type: undefined, decorators: [{
|
|
2225
|
+
type: i0.Inject,
|
|
2226
|
+
args: ['CategoryRepository']
|
|
2227
|
+
}] }, { type: undefined, decorators: [{
|
|
2228
|
+
type: i0.Inject,
|
|
2229
|
+
args: ['HomeRepository']
|
|
2230
|
+
}] }, { type: undefined, decorators: [{
|
|
2231
|
+
type: i0.Inject,
|
|
2232
|
+
args: ['ProductRepository']
|
|
2233
|
+
}] }, { type: i1__namespace$1.Shops, decorators: [{
|
|
2234
|
+
type: i0.Inject,
|
|
2235
|
+
args: [DEFAULT_SHOP]
|
|
2236
|
+
}] }];
|
|
2237
|
+
} });
|
|
2238
|
+
|
|
2239
|
+
var OrderService = /** @class */ (function () {
|
|
2240
|
+
function OrderService(angularFirestore, orderRepository) {
|
|
2241
|
+
this.angularFirestore = angularFirestore;
|
|
2242
|
+
this.orderRepository = orderRepository;
|
|
2243
|
+
this.orderSubject = new rxjs.Subject();
|
|
2244
|
+
}
|
|
2245
|
+
OrderService.prototype.getOrder = function (id) {
|
|
2246
|
+
var _this = this;
|
|
2247
|
+
this.angularFirestore
|
|
2248
|
+
.doc(this.orderRepository.collectionName + "/" + id)
|
|
2249
|
+
.valueChanges()
|
|
2250
|
+
.pipe(operators.map(function (doc) { return i1.Order.toInstance(doc); }))
|
|
2251
|
+
.subscribe(function (doc) { return _this.orderSubject.next(doc); });
|
|
2252
|
+
return this.orderSubject;
|
|
2253
|
+
};
|
|
2254
|
+
return OrderService;
|
|
2255
|
+
}());
|
|
2256
|
+
OrderService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: OrderService, deps: [{ token: i1__namespace$2.AngularFirestore }, { token: 'OrderRepository' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
2257
|
+
OrderService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: OrderService });
|
|
2258
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: OrderService, decorators: [{
|
|
2259
|
+
type: i0.Injectable
|
|
2260
|
+
}], ctorParameters: function () {
|
|
2261
|
+
return [{ type: i1__namespace$2.AngularFirestore }, { type: i1__namespace$1.OrderFirestoreRepository, decorators: [{
|
|
2262
|
+
type: i0.Inject,
|
|
2263
|
+
args: ['OrderRepository']
|
|
2264
|
+
}] }];
|
|
2265
|
+
} });
|
|
2266
|
+
|
|
2267
|
+
var ShippingService = /** @class */ (function () {
|
|
2268
|
+
function ShippingService(http, apiUrl, homeService) {
|
|
2269
|
+
this.http = http;
|
|
2270
|
+
this.apiUrl = apiUrl;
|
|
2271
|
+
this.homeService = homeService;
|
|
2272
|
+
}
|
|
2273
|
+
ShippingService.prototype.getShippingMethods = function (shop, zip, weightGrams, totalPrice, personId, subscriptionPlan) {
|
|
2274
|
+
var _this = this;
|
|
2275
|
+
return rxjs.combineLatest([
|
|
2276
|
+
this.homeService.getHomeData(),
|
|
2277
|
+
this.http.get(this.apiUrl + "open/checkshippingcompany?personId=" + personId + "&postalCode=" + zip + "&weightGrams=" + weightGrams),
|
|
2278
|
+
]).pipe(operators.map(function (_a) {
|
|
2279
|
+
var _b = __read(_a, 2), datas = _b[0], shippingMethodsResponse = _b[1];
|
|
2280
|
+
var shippingMethods = shippingMethodsResponse.result;
|
|
2281
|
+
if (!shippingMethods.length)
|
|
2282
|
+
return [];
|
|
2283
|
+
shippingMethods = shippingMethods.map(function (s) {
|
|
2284
|
+
if (s.ShippingCompanyName == 'Same Day EG')
|
|
2285
|
+
s.ShippingCompanyName = 'Same Day';
|
|
2286
|
+
else
|
|
2287
|
+
return s;
|
|
2288
|
+
});
|
|
2289
|
+
var datasSameDayNotAvaliable = datas.sameDayNotAvaliable;
|
|
2290
|
+
if (_this.isHolidays(datasSameDayNotAvaliable)) {
|
|
2291
|
+
shippingMethods = shippingMethods.filter(function (method) { return method.serviceName !== 'Same Day'; });
|
|
2292
|
+
}
|
|
2293
|
+
if (totalPrice >= 200) {
|
|
2294
|
+
shippingMethods = shippingMethods.map(function (s) {
|
|
2295
|
+
if (s.serviceName !== 'Same Day')
|
|
2296
|
+
return Object.assign(Object.assign({}, s), { totalPrice: 0 });
|
|
2297
|
+
else
|
|
2298
|
+
return s;
|
|
2299
|
+
});
|
|
2300
|
+
}
|
|
2301
|
+
if (shop == i1.Shops.GLAMSHOP)
|
|
2302
|
+
return shippingMethods;
|
|
2303
|
+
if (_this.isFreeShippingBySubscription(shop, subscriptionPlan)) {
|
|
2304
|
+
shippingMethods = shippingMethods.map(function (s) {
|
|
2305
|
+
if (s.serviceName == 'Same Day')
|
|
2306
|
+
return Object.assign(Object.assign({}, s), { totalPrice: s.totalPrice / 2 });
|
|
2307
|
+
else
|
|
2308
|
+
return Object.assign(Object.assign({}, s), { totalPrice: 0 });
|
|
2309
|
+
});
|
|
2310
|
+
}
|
|
2311
|
+
if (_this.isHalfShippingBySubscription(shop, subscriptionPlan)) {
|
|
2312
|
+
shippingMethods = shippingMethods.map(function (s) {
|
|
2313
|
+
return Object.assign(Object.assign({}, s), { totalPrice: s.totalPrice / 2 });
|
|
2314
|
+
});
|
|
2315
|
+
}
|
|
2316
|
+
return shippingMethods;
|
|
2317
|
+
}));
|
|
2318
|
+
};
|
|
2319
|
+
ShippingService.prototype.isFreeShippingBySubscription = function (shop, subscriptionPlan) {
|
|
2320
|
+
if (!subscriptionPlan)
|
|
2321
|
+
return false;
|
|
2322
|
+
if (shop == i1.Shops.MENSMARKET && subscriptionPlan == 'SELECT') {
|
|
2323
|
+
return true;
|
|
2324
|
+
}
|
|
2325
|
+
return false;
|
|
2326
|
+
};
|
|
2327
|
+
ShippingService.prototype.isHalfShippingBySubscription = function (shop, subscriptionPlan) {
|
|
2328
|
+
if (!subscriptionPlan)
|
|
2329
|
+
return false;
|
|
2330
|
+
if (shop == i1.Shops.MENSMARKET && subscriptionPlan == 'PRIME') {
|
|
2331
|
+
return true;
|
|
2332
|
+
}
|
|
2333
|
+
return false;
|
|
2334
|
+
};
|
|
2335
|
+
ShippingService.prototype.isHolidays = function (datas) {
|
|
2336
|
+
var today = new Date();
|
|
2337
|
+
for (var key in datas) {
|
|
2338
|
+
var start = new Date(today.getFullYear() + "-" + datas[key].beginDate);
|
|
2339
|
+
var end = new Date(today.getFullYear() + "-" + datas[key].endDate);
|
|
2340
|
+
if (start > end)
|
|
2341
|
+
end = new Date(today.getFullYear() + 1 + "-" + datas[key].endDate);
|
|
2342
|
+
if (today >= start && today <= end)
|
|
2343
|
+
return true;
|
|
2344
|
+
}
|
|
2345
|
+
return false;
|
|
2346
|
+
};
|
|
2347
|
+
return ShippingService;
|
|
2348
|
+
}());
|
|
2349
|
+
ShippingService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: ShippingService, deps: [{ token: i1__namespace$3.HttpClient }, { token: BACKEND_URL }, { token: HomeShopService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
2350
|
+
ShippingService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: ShippingService });
|
|
2351
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: ShippingService, decorators: [{
|
|
2352
|
+
type: i0.Injectable
|
|
2353
|
+
}], ctorParameters: function () {
|
|
2354
|
+
return [{ type: i1__namespace$3.HttpClient }, { type: undefined, decorators: [{
|
|
2355
|
+
type: i0.Inject,
|
|
2356
|
+
args: [BACKEND_URL]
|
|
2357
|
+
}] }, { type: HomeShopService }];
|
|
2358
|
+
} });
|
|
2359
|
+
|
|
2360
|
+
var NewCategoryStructureAdapter = /** @class */ (function () {
|
|
2361
|
+
function NewCategoryStructureAdapter(categoryRepository, categoryCollectionChildrenRepository) {
|
|
2362
|
+
this.categoryRepository = categoryRepository;
|
|
2363
|
+
this.categoryCollectionChildrenRepository = categoryCollectionChildrenRepository;
|
|
2364
|
+
}
|
|
2365
|
+
NewCategoryStructureAdapter.prototype.buildProductFilterByCategory = function (category) {
|
|
2366
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2367
|
+
var categoriesIds, _a, _b;
|
|
2368
|
+
return __generator(this, function (_c) {
|
|
2369
|
+
switch (_c.label) {
|
|
2370
|
+
case 0: return [4 /*yield*/, this.isCollection(category)];
|
|
2371
|
+
case 1:
|
|
2372
|
+
if (!(_c.sent())) return [3 /*break*/, 3];
|
|
2373
|
+
return [4 /*yield*/, this.getAllCategoriesIdFromCollection(category)];
|
|
2374
|
+
case 2:
|
|
2375
|
+
_a = _c.sent();
|
|
2376
|
+
return [3 /*break*/, 5];
|
|
2377
|
+
case 3:
|
|
2378
|
+
_b = [[]];
|
|
2379
|
+
return [4 /*yield*/, this.getAllCategoriesIdFromCategory(category)];
|
|
2380
|
+
case 4:
|
|
2381
|
+
_a = __spreadArray.apply(void 0, [__spreadArray.apply(void 0, _b.concat([__read.apply(void 0, [(_c.sent())])])), [category.id.toString()]]);
|
|
2382
|
+
_c.label = 5;
|
|
2383
|
+
case 5:
|
|
2384
|
+
categoriesIds = _a;
|
|
2385
|
+
return [2 /*return*/, { category: { id: { operator: i1.Where.IN, value: categoriesIds } } }];
|
|
2386
|
+
}
|
|
2387
|
+
});
|
|
2388
|
+
});
|
|
2389
|
+
};
|
|
2390
|
+
NewCategoryStructureAdapter.prototype.getAllCategoriesIdFromCategory = function (category) {
|
|
2391
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2392
|
+
return __generator(this, function (_a) {
|
|
2393
|
+
return [2 /*return*/, this.categoryRepository
|
|
2394
|
+
.getChildren(+category.id)
|
|
2395
|
+
.then(function (categories) { return categories.map(function (category) { return category.id.toString(); }); })];
|
|
2396
|
+
});
|
|
2397
|
+
});
|
|
2398
|
+
};
|
|
2399
|
+
NewCategoryStructureAdapter.prototype.getAllCategoriesIdFromCollection = function (category) {
|
|
2400
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2401
|
+
return __generator(this, function (_a) {
|
|
2402
|
+
return [2 /*return*/, this.categoryCollectionChildrenRepository
|
|
2403
|
+
.find({ filters: { collectionId: +category.id } })
|
|
2404
|
+
.then(function (_a) {
|
|
2405
|
+
var data = _a.data;
|
|
2406
|
+
return data.map(function (categoryCollection) { return categoryCollection.categoryId.toString(); });
|
|
2407
|
+
})];
|
|
2408
|
+
});
|
|
2409
|
+
});
|
|
2410
|
+
};
|
|
2411
|
+
NewCategoryStructureAdapter.prototype.isCollection = function (category) {
|
|
2412
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2413
|
+
return __generator(this, function (_a) {
|
|
2414
|
+
return [2 /*return*/, !i1.isNil(category.isCollection)
|
|
2415
|
+
? category.isCollection
|
|
2416
|
+
: this.categoryRepository.get({ id: category.id }).then(function (category) { return category.isCollection; })];
|
|
2417
|
+
});
|
|
2418
|
+
});
|
|
2419
|
+
};
|
|
2420
|
+
return NewCategoryStructureAdapter;
|
|
2421
|
+
}());
|
|
2422
|
+
NewCategoryStructureAdapter.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: NewCategoryStructureAdapter, deps: [{ token: 'CategoryRepository' }, { token: 'CategoryCollectionChildrenRepository' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
2423
|
+
NewCategoryStructureAdapter.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: NewCategoryStructureAdapter });
|
|
2424
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: NewCategoryStructureAdapter, decorators: [{
|
|
2425
|
+
type: i0.Injectable
|
|
2426
|
+
}], ctorParameters: function () {
|
|
2427
|
+
return [{ type: undefined, decorators: [{
|
|
2428
|
+
type: i0.Inject,
|
|
2429
|
+
args: ['CategoryRepository']
|
|
2430
|
+
}] }, { type: undefined, decorators: [{
|
|
2431
|
+
type: i0.Inject,
|
|
2432
|
+
args: ['CategoryCollectionChildrenRepository']
|
|
2433
|
+
}] }];
|
|
2434
|
+
} });
|
|
2435
|
+
|
|
2436
|
+
var OldCategoryStructureAdapter = /** @class */ (function () {
|
|
2437
|
+
function OldCategoryStructureAdapter(categoryRepository) {
|
|
2438
|
+
this.categoryRepository = categoryRepository;
|
|
2439
|
+
}
|
|
2440
|
+
OldCategoryStructureAdapter.prototype.buildProductFilterByCategory = function (category) {
|
|
2441
|
+
var _a;
|
|
2442
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2443
|
+
var productsIds, _b;
|
|
2444
|
+
return __generator(this, function (_c) {
|
|
2445
|
+
switch (_c.label) {
|
|
2446
|
+
case 0:
|
|
2447
|
+
if (!((_a = category.products) === null || _a === void 0 ? void 0 : _a.length)) return [3 /*break*/, 1];
|
|
2448
|
+
_b = category.products;
|
|
2449
|
+
return [3 /*break*/, 3];
|
|
2450
|
+
case 1: return [4 /*yield*/, this.categoryRepository.get({ id: category.id }).then(function (categoryFound) { return categoryFound.products; })];
|
|
2451
|
+
case 2:
|
|
2452
|
+
_b = _c.sent();
|
|
2453
|
+
_c.label = 3;
|
|
2454
|
+
case 3:
|
|
2455
|
+
productsIds = _b;
|
|
2456
|
+
return [2 /*return*/, { id: { operator: i1.Where.IN, value: productsIds } }];
|
|
2457
|
+
}
|
|
2458
|
+
});
|
|
2459
|
+
});
|
|
2460
|
+
};
|
|
2461
|
+
return OldCategoryStructureAdapter;
|
|
2462
|
+
}());
|
|
2463
|
+
OldCategoryStructureAdapter.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: OldCategoryStructureAdapter, deps: [{ token: 'CategoryRepository' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
2464
|
+
OldCategoryStructureAdapter.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: OldCategoryStructureAdapter });
|
|
2465
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: OldCategoryStructureAdapter, decorators: [{
|
|
2466
|
+
type: i0.Injectable
|
|
2467
|
+
}], ctorParameters: function () {
|
|
2468
|
+
return [{ type: undefined, decorators: [{
|
|
2469
|
+
type: i0.Inject,
|
|
2470
|
+
args: ['CategoryRepository']
|
|
2471
|
+
}] }];
|
|
2472
|
+
} });
|
|
2473
|
+
|
|
2474
|
+
var AngularConnectModule = /** @class */ (function () {
|
|
2475
|
+
function AngularConnectModule() {
|
|
2476
|
+
}
|
|
2477
|
+
AngularConnectModule.initializeApp = function (defaultShop, options, nameOrConfig) {
|
|
2478
|
+
return {
|
|
2479
|
+
ngModule: AngularConnectModule,
|
|
2480
|
+
providers: __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([
|
|
2481
|
+
{
|
|
2482
|
+
provide: CATEGORY_STRUCTURE,
|
|
2483
|
+
useClass: i1.isNil(options === null || options === void 0 ? void 0 : options.oldCategoryStructure) || (options === null || options === void 0 ? void 0 : options.oldCategoryStructure)
|
|
2484
|
+
? OldCategoryStructureAdapter
|
|
2485
|
+
: NewCategoryStructureAdapter,
|
|
2486
|
+
}
|
|
2487
|
+
], __read((i1.isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]))), __read((i1.isNil(options === null || options === void 0 ? void 0 : options.firebase) ? [] : [{ provide: fire.FIREBASE_OPTIONS, useValue: options === null || options === void 0 ? void 0 : options.firebase }]))), __read((i1.isNil(options === null || options === void 0 ? void 0 : options.firebase) ? [] : [{ provide: fire.FIREBASE_APP_NAME, useValue: nameOrConfig }]))), __read((i1.isNil(options === null || options === void 0 ? void 0 : options.elasticSearch) ? [] : [{ provide: ES_CONFIG, useValue: options.elasticSearch }]))), __read((i1.isNil(options === null || options === void 0 ? void 0 : options.hasura) ? [] : [{ provide: HASURA_OPTIONS, useValue: options.hasura }]))), __read((i1.isNil(options === null || options === void 0 ? void 0 : options.backendUrl) ? [] : [{ provide: BACKEND_URL, useValue: options.backendUrl }]))),
|
|
2488
|
+
};
|
|
2489
|
+
};
|
|
2490
|
+
return AngularConnectModule;
|
|
2491
|
+
}());
|
|
2492
|
+
AngularConnectModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
|
|
2493
|
+
AngularConnectModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, imports: [fire.AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule] });
|
|
2494
|
+
AngularConnectModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, providers: [
|
|
2495
|
+
AuthService,
|
|
2496
|
+
CartService,
|
|
2497
|
+
CatalogService,
|
|
2498
|
+
CategoryService,
|
|
2499
|
+
CheckoutService,
|
|
2500
|
+
CheckoutSubscriptionService,
|
|
2501
|
+
CouponService,
|
|
2502
|
+
HomeShopService,
|
|
2503
|
+
OrderService,
|
|
2504
|
+
ShippingService,
|
|
2505
|
+
], imports: [[fire.AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule]] });
|
|
2506
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, decorators: [{
|
|
2507
|
+
type: i0.NgModule,
|
|
2508
|
+
args: [{
|
|
2509
|
+
imports: [fire.AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule],
|
|
2510
|
+
providers: [
|
|
2511
|
+
AuthService,
|
|
2512
|
+
CartService,
|
|
2513
|
+
CatalogService,
|
|
2514
|
+
CategoryService,
|
|
2515
|
+
CheckoutService,
|
|
2516
|
+
CheckoutSubscriptionService,
|
|
2517
|
+
CouponService,
|
|
2518
|
+
HomeShopService,
|
|
2519
|
+
OrderService,
|
|
2520
|
+
ShippingService,
|
|
2074
2521
|
],
|
|
2075
2522
|
}]
|
|
2076
2523
|
}] });
|
|
2077
2524
|
|
|
2078
|
-
var
|
|
2079
|
-
function
|
|
2525
|
+
var AngularFirebaseAuthModule = /** @class */ (function () {
|
|
2526
|
+
function AngularFirebaseAuthModule() {
|
|
2080
2527
|
}
|
|
2081
|
-
|
|
2528
|
+
AngularFirebaseAuthModule.initializeApp = function (options, nameOrConfig) {
|
|
2082
2529
|
return {
|
|
2083
|
-
ngModule:
|
|
2084
|
-
providers: [
|
|
2530
|
+
ngModule: AngularFirebaseAuthModule,
|
|
2531
|
+
providers: [
|
|
2532
|
+
{ provide: fire.FIREBASE_OPTIONS, useValue: options },
|
|
2533
|
+
{ provide: fire.FIREBASE_APP_NAME, useValue: nameOrConfig },
|
|
2534
|
+
],
|
|
2085
2535
|
};
|
|
2086
2536
|
};
|
|
2087
|
-
return
|
|
2537
|
+
return AngularFirebaseAuthModule;
|
|
2088
2538
|
}());
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
{
|
|
2093
|
-
provide: 'CategoryRepository',
|
|
2094
|
-
useExisting: i3.CategoryHasuraGraphQLRepository,
|
|
2095
|
-
},
|
|
2539
|
+
AngularFirebaseAuthModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
|
|
2540
|
+
AngularFirebaseAuthModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, imports: [fire.AngularFireModule] });
|
|
2541
|
+
AngularFirebaseAuthModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, providers: [
|
|
2096
2542
|
{
|
|
2097
|
-
provide:
|
|
2098
|
-
useFactory: function (
|
|
2099
|
-
return new
|
|
2543
|
+
provide: 'Authentication',
|
|
2544
|
+
useFactory: function (authenticationService, userRepository) {
|
|
2545
|
+
return new i1.Authentication(authenticationService, userRepository);
|
|
2100
2546
|
},
|
|
2101
|
-
deps: [
|
|
2102
|
-
},
|
|
2103
|
-
{
|
|
2104
|
-
provide: 'ProductRepository',
|
|
2105
|
-
useExisting: i3.ProductHasuraGraphQLRepository,
|
|
2547
|
+
deps: ['AuthenticationService', 'UserRepository'],
|
|
2106
2548
|
},
|
|
2107
2549
|
{
|
|
2108
|
-
provide:
|
|
2109
|
-
useFactory: function (
|
|
2110
|
-
return new
|
|
2550
|
+
provide: 'AuthenticationService',
|
|
2551
|
+
useFactory: function (angularFireAuth) {
|
|
2552
|
+
return new i1.AuthenticationFirebaseAuthService(angularFireAuth);
|
|
2111
2553
|
},
|
|
2112
|
-
deps: [
|
|
2113
|
-
},
|
|
2114
|
-
{
|
|
2115
|
-
provide: 'VariantRepository',
|
|
2116
|
-
useExisting: i3.VariantHasuraGraphQLRepository,
|
|
2554
|
+
deps: [i1$2.AngularFireAuth],
|
|
2117
2555
|
},
|
|
2118
2556
|
{
|
|
2119
|
-
provide:
|
|
2120
|
-
useFactory: function (
|
|
2121
|
-
return new
|
|
2557
|
+
provide: 'Register',
|
|
2558
|
+
useFactory: function (registerService, userRepository) {
|
|
2559
|
+
return new i1.Register(registerService, userRepository);
|
|
2122
2560
|
},
|
|
2123
|
-
deps: [
|
|
2124
|
-
},
|
|
2125
|
-
{
|
|
2126
|
-
provide: 'CategoryFilterRepository',
|
|
2127
|
-
useExisting: i3.CategoryFilterHasuraGraphQLRepository,
|
|
2561
|
+
deps: ['RegisterService', 'UserRepository'],
|
|
2128
2562
|
},
|
|
2129
2563
|
{
|
|
2130
|
-
provide:
|
|
2131
|
-
useFactory: function (
|
|
2132
|
-
return new
|
|
2564
|
+
provide: 'RegisterService',
|
|
2565
|
+
useFactory: function (angularFireAuth) {
|
|
2566
|
+
return new i1.RegisterFirebaseAuthService(angularFireAuth);
|
|
2133
2567
|
},
|
|
2134
|
-
deps: [
|
|
2135
|
-
},
|
|
2136
|
-
{
|
|
2137
|
-
provide: 'FilterOptionRepository',
|
|
2138
|
-
useExisting: i3.FilterOptionHasuraGraphQLRepository,
|
|
2568
|
+
deps: [i1$2.AngularFireAuth],
|
|
2139
2569
|
},
|
|
2140
2570
|
{
|
|
2141
|
-
provide:
|
|
2142
|
-
useFactory: function (
|
|
2143
|
-
return new
|
|
2571
|
+
provide: 'SignOut',
|
|
2572
|
+
useFactory: function (authenticationService) {
|
|
2573
|
+
return new i1.SignOut(authenticationService);
|
|
2144
2574
|
},
|
|
2145
|
-
deps: [
|
|
2146
|
-
},
|
|
2147
|
-
{
|
|
2148
|
-
provide: 'FilterRepository',
|
|
2149
|
-
useExisting: i3.FilterHasuraGraphQLRepository,
|
|
2575
|
+
deps: ['AuthenticationService'],
|
|
2150
2576
|
},
|
|
2151
2577
|
{
|
|
2152
|
-
provide:
|
|
2153
|
-
useFactory: function (
|
|
2154
|
-
return new
|
|
2578
|
+
provide: 'RecoveryPassword',
|
|
2579
|
+
useFactory: function (authenticationService) {
|
|
2580
|
+
return new i1.RecoveryPassword(authenticationService);
|
|
2155
2581
|
},
|
|
2156
|
-
deps: [
|
|
2582
|
+
deps: ['AuthenticationService'],
|
|
2157
2583
|
},
|
|
2158
|
-
] });
|
|
2159
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type:
|
|
2584
|
+
], imports: [[fire.AngularFireModule]] });
|
|
2585
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, decorators: [{
|
|
2160
2586
|
type: i0.NgModule,
|
|
2161
2587
|
args: [{
|
|
2588
|
+
imports: [fire.AngularFireModule],
|
|
2162
2589
|
providers: [
|
|
2163
2590
|
{
|
|
2164
|
-
provide: '
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
{
|
|
2168
|
-
provide: i3.CategoryHasuraGraphQLRepository,
|
|
2169
|
-
useFactory: function (options, productRepository, categoryFilterRepository) {
|
|
2170
|
-
return new i3.CategoryHasuraGraphQLRepository(options.endpoint, options.credentials, productRepository, categoryFilterRepository);
|
|
2591
|
+
provide: 'Authentication',
|
|
2592
|
+
useFactory: function (authenticationService, userRepository) {
|
|
2593
|
+
return new i1.Authentication(authenticationService, userRepository);
|
|
2171
2594
|
},
|
|
2172
|
-
deps: [
|
|
2173
|
-
},
|
|
2174
|
-
{
|
|
2175
|
-
provide: 'ProductRepository',
|
|
2176
|
-
useExisting: i3.ProductHasuraGraphQLRepository,
|
|
2595
|
+
deps: ['AuthenticationService', 'UserRepository'],
|
|
2177
2596
|
},
|
|
2178
2597
|
{
|
|
2179
|
-
provide:
|
|
2180
|
-
useFactory: function (
|
|
2181
|
-
return new
|
|
2598
|
+
provide: 'AuthenticationService',
|
|
2599
|
+
useFactory: function (angularFireAuth) {
|
|
2600
|
+
return new i1.AuthenticationFirebaseAuthService(angularFireAuth);
|
|
2182
2601
|
},
|
|
2183
|
-
deps: [
|
|
2184
|
-
},
|
|
2185
|
-
{
|
|
2186
|
-
provide: 'VariantRepository',
|
|
2187
|
-
useExisting: i3.VariantHasuraGraphQLRepository,
|
|
2602
|
+
deps: [i1$2.AngularFireAuth],
|
|
2188
2603
|
},
|
|
2189
2604
|
{
|
|
2190
|
-
provide:
|
|
2191
|
-
useFactory: function (
|
|
2192
|
-
return new
|
|
2605
|
+
provide: 'Register',
|
|
2606
|
+
useFactory: function (registerService, userRepository) {
|
|
2607
|
+
return new i1.Register(registerService, userRepository);
|
|
2193
2608
|
},
|
|
2194
|
-
deps: [
|
|
2195
|
-
},
|
|
2196
|
-
{
|
|
2197
|
-
provide: 'CategoryFilterRepository',
|
|
2198
|
-
useExisting: i3.CategoryFilterHasuraGraphQLRepository,
|
|
2609
|
+
deps: ['RegisterService', 'UserRepository'],
|
|
2199
2610
|
},
|
|
2200
2611
|
{
|
|
2201
|
-
provide:
|
|
2202
|
-
useFactory: function (
|
|
2203
|
-
return new
|
|
2612
|
+
provide: 'RegisterService',
|
|
2613
|
+
useFactory: function (angularFireAuth) {
|
|
2614
|
+
return new i1.RegisterFirebaseAuthService(angularFireAuth);
|
|
2204
2615
|
},
|
|
2205
|
-
deps: [
|
|
2206
|
-
},
|
|
2207
|
-
{
|
|
2208
|
-
provide: 'FilterOptionRepository',
|
|
2209
|
-
useExisting: i3.FilterOptionHasuraGraphQLRepository,
|
|
2616
|
+
deps: [i1$2.AngularFireAuth],
|
|
2210
2617
|
},
|
|
2211
2618
|
{
|
|
2212
|
-
provide:
|
|
2213
|
-
useFactory: function (
|
|
2214
|
-
return new
|
|
2619
|
+
provide: 'SignOut',
|
|
2620
|
+
useFactory: function (authenticationService) {
|
|
2621
|
+
return new i1.SignOut(authenticationService);
|
|
2215
2622
|
},
|
|
2216
|
-
deps: [
|
|
2217
|
-
},
|
|
2218
|
-
{
|
|
2219
|
-
provide: 'FilterRepository',
|
|
2220
|
-
useExisting: i3.FilterHasuraGraphQLRepository,
|
|
2623
|
+
deps: ['AuthenticationService'],
|
|
2221
2624
|
},
|
|
2222
2625
|
{
|
|
2223
|
-
provide:
|
|
2224
|
-
useFactory: function (
|
|
2225
|
-
return new
|
|
2626
|
+
provide: 'RecoveryPassword',
|
|
2627
|
+
useFactory: function (authenticationService) {
|
|
2628
|
+
return new i1.RecoveryPassword(authenticationService);
|
|
2226
2629
|
},
|
|
2227
|
-
deps: [
|
|
2630
|
+
deps: ['AuthenticationService'],
|
|
2228
2631
|
},
|
|
2229
2632
|
],
|
|
2230
2633
|
}]
|
|
2231
2634
|
}] });
|
|
2232
2635
|
|
|
2233
|
-
var AngularConnectModule = /** @class */ (function () {
|
|
2234
|
-
function AngularConnectModule() {
|
|
2235
|
-
}
|
|
2236
|
-
AngularConnectModule.initializeApp = function (defaultShop, options, nameOrConfig) {
|
|
2237
|
-
return {
|
|
2238
|
-
ngModule: AngularConnectModule,
|
|
2239
|
-
providers: __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read((i3.isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]))), __read((i3.isNil(options === null || options === void 0 ? void 0 : options.firebase) ? [] : [{ provide: fire.FIREBASE_OPTIONS, useValue: options === null || options === void 0 ? void 0 : options.firebase }]))), __read((i3.isNil(options === null || options === void 0 ? void 0 : options.firebase) ? [] : [{ provide: fire.FIREBASE_APP_NAME, useValue: nameOrConfig }]))), __read((i3.isNil(options === null || options === void 0 ? void 0 : options.elasticSearch) ? [] : [{ provide: ES_CONFIG, useValue: options.elasticSearch }]))), __read((i3.isNil(options === null || options === void 0 ? void 0 : options.hasura) ? [] : [{ provide: HASURA_OPTIONS, useValue: options.hasura }]))), __read((i3.isNil(options === null || options === void 0 ? void 0 : options.backendUrl) ? [] : [{ provide: BACKEND_URL, useValue: options.backendUrl }]))),
|
|
2240
|
-
};
|
|
2241
|
-
};
|
|
2242
|
-
return AngularConnectModule;
|
|
2243
|
-
}());
|
|
2244
|
-
AngularConnectModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
|
|
2245
|
-
AngularConnectModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, imports: [fire.AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule] });
|
|
2246
|
-
AngularConnectModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, providers: [
|
|
2247
|
-
AuthService,
|
|
2248
|
-
CartService,
|
|
2249
|
-
CheckoutService,
|
|
2250
|
-
CheckoutSubscriptionService,
|
|
2251
|
-
CouponService,
|
|
2252
|
-
HomeShopService,
|
|
2253
|
-
OrderService,
|
|
2254
|
-
ShippingService,
|
|
2255
|
-
], imports: [[fire.AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule]] });
|
|
2256
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, decorators: [{
|
|
2257
|
-
type: i0.NgModule,
|
|
2258
|
-
args: [{
|
|
2259
|
-
imports: [fire.AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule],
|
|
2260
|
-
providers: [
|
|
2261
|
-
AuthService,
|
|
2262
|
-
CartService,
|
|
2263
|
-
CheckoutService,
|
|
2264
|
-
CheckoutSubscriptionService,
|
|
2265
|
-
CouponService,
|
|
2266
|
-
HomeShopService,
|
|
2267
|
-
OrderService,
|
|
2268
|
-
ShippingService,
|
|
2269
|
-
],
|
|
2270
|
-
}]
|
|
2271
|
-
}] });
|
|
2272
|
-
|
|
2273
2636
|
/**
|
|
2274
2637
|
* Generated bundle index. Do not edit.
|
|
2275
2638
|
*/
|
|
@@ -2280,6 +2643,9 @@
|
|
|
2280
2643
|
exports.AngularHasuraGraphQLModule = AngularHasuraGraphQLModule;
|
|
2281
2644
|
exports.AuthService = AuthService;
|
|
2282
2645
|
exports.CartService = CartService;
|
|
2646
|
+
exports.CatalogService = CatalogService;
|
|
2647
|
+
exports.CategoryService = CategoryService;
|
|
2648
|
+
exports.CategoryWithTree = CategoryWithTree;
|
|
2283
2649
|
exports.CheckoutService = CheckoutService;
|
|
2284
2650
|
exports.CheckoutSubscriptionService = CheckoutSubscriptionService;
|
|
2285
2651
|
exports.CouponService = CouponService;
|