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