@infrab4a/connect-angular 3.9.1-beta4 → 3.9.2-beta2
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 +0 -1
- package/bundles/infrab4a-connect-angular.umd.js +1160 -1586
- package/bundles/infrab4a-connect-angular.umd.js.map +1 -1
- package/consts/index.d.ts +0 -1
- package/esm2015/angular-connect.module.js +3 -14
- package/esm2015/angular-firestore.module.js +3 -17
- package/esm2015/angular-hasura-graphql.module.js +2 -18
- package/esm2015/consts/index.js +1 -2
- package/esm2015/index.js +3 -3
- package/esm2015/services/cart.service.js +13 -26
- package/esm2015/services/checkout-subscription.service.js +2 -2
- package/esm2015/services/checkout.service.js +7 -2
- package/esm2015/services/coupon.service.js +159 -154
- package/esm2015/services/errors/group-invalid-coupon.error.js +8 -0
- package/esm2015/services/errors/index.js +3 -0
- package/esm2015/services/errors/invalid-coupon.error.js +8 -0
- package/esm2015/services/index.js +1 -2
- package/fesm2015/infrab4a-connect-angular.js +1025 -1285
- 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 +2 -3
- package/services/coupon.service.d.ts +8 -11
- package/services/errors/group-invalid-coupon.error.d.ts +6 -0
- package/services/errors/index.d.ts +2 -0
- package/services/errors/invalid-coupon.error.d.ts +5 -0
- package/services/index.d.ts +0 -1
- package/consts/category-structure.d.ts +0 -1
- package/esm2015/consts/category-structure.js +0 -2
- package/esm2015/services/catalog/adapters/category-structure.adapter.js +0 -2
- package/esm2015/services/catalog/adapters/index.js +0 -4
- package/esm2015/services/catalog/adapters/new-category-structure.adapter.js +0 -51
- package/esm2015/services/catalog/adapters/old-category-structure.adapter.js +0 -27
- package/esm2015/services/catalog/catalog.service.js +0 -96
- package/esm2015/services/catalog/category.service.js +0 -56
- package/esm2015/services/catalog/enums/index.js +0 -2
- package/esm2015/services/catalog/enums/product-sorts.enum.js +0 -11
- package/esm2015/services/catalog/index.js +0 -6
- package/esm2015/services/catalog/models/category-with-tree.model.js +0 -10
- package/esm2015/services/catalog/models/index.js +0 -2
- package/esm2015/services/catalog/types/index.js +0 -2
- package/esm2015/services/catalog/types/product-sort.type.js +0 -2
- package/services/catalog/adapters/category-structure.adapter.d.ts +0 -4
- package/services/catalog/adapters/index.d.ts +0 -3
- package/services/catalog/adapters/new-category-structure.adapter.d.ts +0 -14
- package/services/catalog/adapters/old-category-structure.adapter.d.ts +0 -10
- package/services/catalog/catalog.service.d.ts +0 -54
- package/services/catalog/category.service.d.ts +0 -15
- package/services/catalog/enums/index.d.ts +0 -1
- package/services/catalog/enums/product-sorts.enum.d.ts +0 -9
- package/services/catalog/index.d.ts +0 -5
- package/services/catalog/models/category-with-tree.model.d.ts +0 -4
- package/services/catalog/models/index.d.ts +0 -1
- package/services/catalog/types/index.d.ts +0 -1
- package/services/catalog/types/product-sort.type.d.ts +0 -2
|
@@ -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.
|
|
5
|
-
})(this, (function (exports, i0,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs'), require('rxjs/operators'), require('@angular/fire/auth'), require('@infrab4a/connect'), require('js-cookie'), require('ts-custom-error'), require('@angular/fire/firestore'), require('@angular/common/http'), require('@angular/fire')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define('@infrab4a/connect-angular', ['exports', '@angular/core', 'rxjs', 'rxjs/operators', '@angular/fire/auth', '@infrab4a/connect', 'js-cookie', 'ts-custom-error', '@angular/fire/firestore', '@angular/common/http', '@angular/fire'], factory) :
|
|
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["@infrab4a/connect"], global["js-cookie"], global["ts-custom-error"], global.ng.fire.firestore, global.ng.common.http, global.ng.fire));
|
|
5
|
+
})(this, (function (exports, i0, rxjs, operators, i1, i3, cookie, tsCustomError, i1$1, i1$2, fire) { '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
|
|
29
|
-
var
|
|
30
|
-
var i1__namespace = /*#__PURE__*/_interopNamespace(i1$2);
|
|
28
|
+
var i1__namespace = /*#__PURE__*/_interopNamespace(i1);
|
|
29
|
+
var i3__namespace = /*#__PURE__*/_interopNamespace(i3);
|
|
31
30
|
var cookie__default = /*#__PURE__*/_interopDefaultLegacy(cookie);
|
|
32
|
-
var i1__namespace$
|
|
31
|
+
var i1__namespace$1 = /*#__PURE__*/_interopNamespace(i1$1);
|
|
32
|
+
var i1__namespace$2 = /*#__PURE__*/_interopNamespace(i1$2);
|
|
33
33
|
|
|
34
34
|
/*! *****************************************************************************
|
|
35
35
|
Copyright (c) Microsoft Corporation.
|
|
@@ -349,1004 +349,393 @@
|
|
|
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
|
+
|
|
352
397
|
var ES_CONFIG = 'ES_CONFIG';
|
|
353
398
|
|
|
354
|
-
var
|
|
355
|
-
|
|
399
|
+
var HASURA_OPTIONS = 'HASURA_OPTIONS';
|
|
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;
|
|
356
407
|
}
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
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
|
+
}); };
|
|
447
|
+
}
|
|
448
|
+
CouponService.prototype.checkCoupon = function (nickname, userEmail, checkoutType, plan, checkout, isSubscription) {
|
|
449
|
+
var _this = this;
|
|
450
|
+
return rxjs.from(this.couponRepository.find({
|
|
451
|
+
filters: {
|
|
452
|
+
nickname: { operator: i3.Where.EQUALS, value: nickname },
|
|
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; }));
|
|
362
456
|
};
|
|
363
|
-
|
|
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
|
+
});
|
|
690
|
+
};
|
|
691
|
+
return CouponService;
|
|
364
692
|
}());
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
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,
|
|
693
|
+
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 });
|
|
694
|
+
CouponService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CouponService, providedIn: 'root' });
|
|
695
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CouponService, decorators: [{
|
|
696
|
+
type: i0.Injectable,
|
|
376
697
|
args: [{
|
|
377
|
-
|
|
378
|
-
{
|
|
379
|
-
provide: i1.ProductsIndex,
|
|
380
|
-
useFactory: function (configuration) { return new i1.ProductsIndex(new i1.AxiosAdapter(configuration)); },
|
|
381
|
-
deps: [ES_CONFIG],
|
|
382
|
-
},
|
|
383
|
-
],
|
|
698
|
+
providedIn: 'root',
|
|
384
699
|
}]
|
|
385
|
-
}]
|
|
700
|
+
}], ctorParameters: function () {
|
|
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
|
+
} });
|
|
386
715
|
|
|
387
|
-
var
|
|
388
|
-
function
|
|
716
|
+
var CheckoutService = /** @class */ (function () {
|
|
717
|
+
function CheckoutService(couponService, checkoutRepository, orderRepository, userRepository, defaultShop) {
|
|
718
|
+
this.couponService = couponService;
|
|
719
|
+
this.checkoutRepository = checkoutRepository;
|
|
720
|
+
this.orderRepository = orderRepository;
|
|
721
|
+
this.userRepository = userRepository;
|
|
722
|
+
this.defaultShop = defaultShop;
|
|
389
723
|
}
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
{ provide: fire.FIREBASE_APP_NAME, useValue: nameOrConfig },
|
|
396
|
-
{ provide: ES_CONFIG, useValue: options.elasticSearch },
|
|
397
|
-
],
|
|
398
|
-
};
|
|
399
|
-
};
|
|
400
|
-
return AngularFirestoreModule;
|
|
401
|
-
}());
|
|
402
|
-
AngularFirestoreModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
|
|
403
|
-
AngularFirestoreModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, imports: [fire.AngularFireModule, AngularElasticSeachModule] });
|
|
404
|
-
AngularFirestoreModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, providers: [
|
|
405
|
-
{
|
|
406
|
-
provide: 'BeautyProfileRepository',
|
|
407
|
-
useFactory: function (firestore, userRepository) {
|
|
408
|
-
return new i1.UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
|
|
409
|
-
},
|
|
410
|
-
deps: [i1$1.AngularFirestore, 'UserRepository'],
|
|
411
|
-
},
|
|
412
|
-
{
|
|
413
|
-
provide: 'Buy2WinRepository',
|
|
414
|
-
useFactory: function (firestore) {
|
|
415
|
-
return new i1.Buy2WinFirestoreRepository(firestore.firestore);
|
|
416
|
-
},
|
|
417
|
-
deps: [i1$1.AngularFirestore],
|
|
418
|
-
},
|
|
419
|
-
{
|
|
420
|
-
provide: i1.CategoryFirestoreRepository,
|
|
421
|
-
useFactory: function (firestore) {
|
|
422
|
-
return new i1.CategoryFirestoreRepository(firestore.firestore);
|
|
423
|
-
},
|
|
424
|
-
deps: [i1$1.AngularFirestore],
|
|
425
|
-
},
|
|
426
|
-
{
|
|
427
|
-
provide: 'CheckoutRepository',
|
|
428
|
-
useFactory: function (firestore) {
|
|
429
|
-
return new i1.CheckoutFirestoreRepository(firestore.firestore);
|
|
430
|
-
},
|
|
431
|
-
deps: [i1$1.AngularFirestore],
|
|
432
|
-
},
|
|
433
|
-
{
|
|
434
|
-
provide: 'CheckoutSubscriptionRepository',
|
|
435
|
-
useFactory: function (firestore) {
|
|
436
|
-
return new i1.CheckoutSubscriptionFirestoreRepository(firestore.firestore);
|
|
437
|
-
},
|
|
438
|
-
deps: [i1$1.AngularFirestore],
|
|
439
|
-
},
|
|
440
|
-
{
|
|
441
|
-
provide: 'CouponRepository',
|
|
442
|
-
useFactory: function (firestore) {
|
|
443
|
-
return new i1.CouponFirestoreRepository(firestore.firestore);
|
|
444
|
-
},
|
|
445
|
-
deps: [i1$1.AngularFirestore],
|
|
446
|
-
},
|
|
447
|
-
{
|
|
448
|
-
provide: 'CampaignHashtagRepository',
|
|
449
|
-
useFactory: function (firestore) {
|
|
450
|
-
return new i1.CampaignHashtagFirestoreRepository(firestore.firestore);
|
|
451
|
-
},
|
|
452
|
-
deps: [i1$1.AngularFirestore],
|
|
453
|
-
},
|
|
454
|
-
{
|
|
455
|
-
provide: 'CampaignDashboardRepository',
|
|
456
|
-
useFactory: function (firestore) {
|
|
457
|
-
return new i1.CampaignDashboardFirestoreRepository(firestore.firestore);
|
|
458
|
-
},
|
|
459
|
-
deps: [i1$1.AngularFirestore],
|
|
460
|
-
},
|
|
461
|
-
{
|
|
462
|
-
provide: 'EditionRepository',
|
|
463
|
-
useFactory: function (firestore, subscriptionRepository) {
|
|
464
|
-
return new i1.SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
|
|
465
|
-
},
|
|
466
|
-
deps: [i1$1.AngularFirestore, 'SubscriptionRepository'],
|
|
467
|
-
},
|
|
468
|
-
{
|
|
469
|
-
provide: 'HomeRepository',
|
|
470
|
-
useFactory: function (firestore) {
|
|
471
|
-
return new i1.HomeFirestoreRepository(firestore.firestore);
|
|
472
|
-
},
|
|
473
|
-
deps: [i1$1.AngularFirestore],
|
|
474
|
-
},
|
|
475
|
-
{
|
|
476
|
-
provide: 'LeadRepository',
|
|
477
|
-
useFactory: function (firestore) {
|
|
478
|
-
return new i1.LeadFirestoreRepository(firestore.firestore);
|
|
479
|
-
},
|
|
480
|
-
deps: [i1$1.AngularFirestore],
|
|
481
|
-
},
|
|
482
|
-
{
|
|
483
|
-
provide: 'LegacyOrderRepository',
|
|
484
|
-
useFactory: function (firestore) {
|
|
485
|
-
return new i1.LegacyOrderFirestoreRepository(firestore.firestore);
|
|
486
|
-
},
|
|
487
|
-
deps: [i1$1.AngularFirestore],
|
|
488
|
-
},
|
|
489
|
-
{
|
|
490
|
-
provide: 'ShopMenuRepository',
|
|
491
|
-
useFactory: function (firestore) {
|
|
492
|
-
return new i1.ShopMenuFirestoreRepository(firestore.firestore);
|
|
493
|
-
},
|
|
494
|
-
deps: [i1$1.AngularFirestore],
|
|
495
|
-
},
|
|
496
|
-
{
|
|
497
|
-
provide: 'OrderRepository',
|
|
498
|
-
useFactory: function (firestore) {
|
|
499
|
-
return new i1.OrderFirestoreRepository(firestore.firestore);
|
|
500
|
-
},
|
|
501
|
-
deps: [i1$1.AngularFirestore],
|
|
502
|
-
},
|
|
503
|
-
{
|
|
504
|
-
provide: 'PaymentRepository',
|
|
505
|
-
useFactory: function (firestore) {
|
|
506
|
-
return new i1.PaymentFirestoreRepository(firestore.firestore);
|
|
507
|
-
},
|
|
508
|
-
deps: [i1$1.AngularFirestore],
|
|
509
|
-
},
|
|
510
|
-
{
|
|
511
|
-
provide: i1.ProductFirestoreRepository,
|
|
512
|
-
useFactory: function (firestore) {
|
|
513
|
-
return new i1.ProductFirestoreRepository(firestore.firestore);
|
|
514
|
-
},
|
|
515
|
-
deps: [i1$1.AngularFirestore],
|
|
516
|
-
},
|
|
517
|
-
{
|
|
518
|
-
provide: 'ShopSettingsRepository',
|
|
519
|
-
useFactory: function (firestore) {
|
|
520
|
-
return new i1.ShopSettingsFirestoreRepository(firestore.firestore);
|
|
521
|
-
},
|
|
522
|
-
deps: [i1$1.AngularFirestore],
|
|
523
|
-
},
|
|
524
|
-
{
|
|
525
|
-
provide: 'SubscriptionPaymentRepository',
|
|
526
|
-
useFactory: function (firestore, subscriptionRepository) {
|
|
527
|
-
return new i1.SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
|
|
528
|
-
},
|
|
529
|
-
deps: [i1$1.AngularFirestore, 'SubscriptionRepository'],
|
|
530
|
-
},
|
|
531
|
-
{
|
|
532
|
-
provide: 'SubscriptionPlanRepository',
|
|
533
|
-
useFactory: function (firestore) {
|
|
534
|
-
return new i1.SubscriptionPlanFirestoreRepository(firestore.firestore);
|
|
535
|
-
},
|
|
536
|
-
deps: [i1$1.AngularFirestore],
|
|
537
|
-
},
|
|
538
|
-
{
|
|
539
|
-
provide: 'SubscriptionProductRepository',
|
|
540
|
-
useFactory: function (firestore) {
|
|
541
|
-
return new i1.SubscriptionProductFirestoreRepository(firestore.firestore);
|
|
542
|
-
},
|
|
543
|
-
deps: [i1$1.AngularFirestore],
|
|
544
|
-
},
|
|
545
|
-
{
|
|
546
|
-
provide: 'SubscriptionRepository',
|
|
547
|
-
useFactory: function (firestore) {
|
|
548
|
-
return new i1.SubscriptionFirestoreRepository(firestore.firestore);
|
|
549
|
-
},
|
|
550
|
-
deps: [i1$1.AngularFirestore],
|
|
551
|
-
},
|
|
552
|
-
{
|
|
553
|
-
provide: 'UserRepository',
|
|
554
|
-
useFactory: function (firestore) {
|
|
555
|
-
return new i1.UserFirestoreRepository(firestore.firestore);
|
|
556
|
-
},
|
|
557
|
-
deps: [i1$1.AngularFirestore],
|
|
558
|
-
},
|
|
559
|
-
{
|
|
560
|
-
provide: 'UserAddressRepository',
|
|
561
|
-
useFactory: function (firestore, userRepository) {
|
|
562
|
-
return new i1.UserAddressFirestoreRepository(firestore.firestore, userRepository);
|
|
563
|
-
},
|
|
564
|
-
deps: [i1$1.AngularFirestore, 'UserRepository'],
|
|
565
|
-
},
|
|
566
|
-
{
|
|
567
|
-
provide: 'UserPaymentMethodRepository',
|
|
568
|
-
useFactory: function (firestore, userRepository) {
|
|
569
|
-
return new i1.UserPaymentMethodFirestoreRepository(firestore.firestore, userRepository);
|
|
570
|
-
},
|
|
571
|
-
deps: [i1$1.AngularFirestore, 'UserRepository'],
|
|
572
|
-
},
|
|
573
|
-
{
|
|
574
|
-
provide: 'SubscriptionMaterializationRepository',
|
|
575
|
-
useFactory: function (firestore) {
|
|
576
|
-
return new i1.SubscriptionMaterializationFirestoreRepository(firestore.firestore);
|
|
577
|
-
},
|
|
578
|
-
deps: [i1$1.AngularFirestore],
|
|
579
|
-
},
|
|
580
|
-
{
|
|
581
|
-
provide: i1.ProductVariantFirestoreRepository,
|
|
582
|
-
useFactory: function (firestore, productRepository) {
|
|
583
|
-
return new i1.ProductVariantFirestoreRepository(firestore.firestore, productRepository);
|
|
584
|
-
},
|
|
585
|
-
deps: [i1$1.AngularFirestore, i1.ProductFirestoreRepository],
|
|
586
|
-
},
|
|
587
|
-
{
|
|
588
|
-
provide: i0.APP_INITIALIZER,
|
|
589
|
-
useFactory: function (firestore) { return function () { return firestore.firestore.settings({ ignoreUndefinedProperties: true }); }; },
|
|
590
|
-
deps: [i1$1.AngularFirestore],
|
|
591
|
-
multi: true,
|
|
592
|
-
},
|
|
593
|
-
], imports: [[fire.AngularFireModule, AngularElasticSeachModule]] });
|
|
594
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, decorators: [{
|
|
595
|
-
type: i0.NgModule,
|
|
596
|
-
args: [{
|
|
597
|
-
imports: [fire.AngularFireModule, AngularElasticSeachModule],
|
|
598
|
-
providers: [
|
|
599
|
-
{
|
|
600
|
-
provide: 'BeautyProfileRepository',
|
|
601
|
-
useFactory: function (firestore, userRepository) {
|
|
602
|
-
return new i1.UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
|
|
603
|
-
},
|
|
604
|
-
deps: [i1$1.AngularFirestore, 'UserRepository'],
|
|
605
|
-
},
|
|
606
|
-
{
|
|
607
|
-
provide: 'Buy2WinRepository',
|
|
608
|
-
useFactory: function (firestore) {
|
|
609
|
-
return new i1.Buy2WinFirestoreRepository(firestore.firestore);
|
|
610
|
-
},
|
|
611
|
-
deps: [i1$1.AngularFirestore],
|
|
612
|
-
},
|
|
613
|
-
{
|
|
614
|
-
provide: i1.CategoryFirestoreRepository,
|
|
615
|
-
useFactory: function (firestore) {
|
|
616
|
-
return new i1.CategoryFirestoreRepository(firestore.firestore);
|
|
617
|
-
},
|
|
618
|
-
deps: [i1$1.AngularFirestore],
|
|
619
|
-
},
|
|
620
|
-
{
|
|
621
|
-
provide: 'CheckoutRepository',
|
|
622
|
-
useFactory: function (firestore) {
|
|
623
|
-
return new i1.CheckoutFirestoreRepository(firestore.firestore);
|
|
624
|
-
},
|
|
625
|
-
deps: [i1$1.AngularFirestore],
|
|
626
|
-
},
|
|
627
|
-
{
|
|
628
|
-
provide: 'CheckoutSubscriptionRepository',
|
|
629
|
-
useFactory: function (firestore) {
|
|
630
|
-
return new i1.CheckoutSubscriptionFirestoreRepository(firestore.firestore);
|
|
631
|
-
},
|
|
632
|
-
deps: [i1$1.AngularFirestore],
|
|
633
|
-
},
|
|
634
|
-
{
|
|
635
|
-
provide: 'CouponRepository',
|
|
636
|
-
useFactory: function (firestore) {
|
|
637
|
-
return new i1.CouponFirestoreRepository(firestore.firestore);
|
|
638
|
-
},
|
|
639
|
-
deps: [i1$1.AngularFirestore],
|
|
640
|
-
},
|
|
641
|
-
{
|
|
642
|
-
provide: 'CampaignHashtagRepository',
|
|
643
|
-
useFactory: function (firestore) {
|
|
644
|
-
return new i1.CampaignHashtagFirestoreRepository(firestore.firestore);
|
|
645
|
-
},
|
|
646
|
-
deps: [i1$1.AngularFirestore],
|
|
647
|
-
},
|
|
648
|
-
{
|
|
649
|
-
provide: 'CampaignDashboardRepository',
|
|
650
|
-
useFactory: function (firestore) {
|
|
651
|
-
return new i1.CampaignDashboardFirestoreRepository(firestore.firestore);
|
|
652
|
-
},
|
|
653
|
-
deps: [i1$1.AngularFirestore],
|
|
654
|
-
},
|
|
655
|
-
{
|
|
656
|
-
provide: 'EditionRepository',
|
|
657
|
-
useFactory: function (firestore, subscriptionRepository) {
|
|
658
|
-
return new i1.SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
|
|
659
|
-
},
|
|
660
|
-
deps: [i1$1.AngularFirestore, 'SubscriptionRepository'],
|
|
661
|
-
},
|
|
662
|
-
{
|
|
663
|
-
provide: 'HomeRepository',
|
|
664
|
-
useFactory: function (firestore) {
|
|
665
|
-
return new i1.HomeFirestoreRepository(firestore.firestore);
|
|
666
|
-
},
|
|
667
|
-
deps: [i1$1.AngularFirestore],
|
|
668
|
-
},
|
|
669
|
-
{
|
|
670
|
-
provide: 'LeadRepository',
|
|
671
|
-
useFactory: function (firestore) {
|
|
672
|
-
return new i1.LeadFirestoreRepository(firestore.firestore);
|
|
673
|
-
},
|
|
674
|
-
deps: [i1$1.AngularFirestore],
|
|
675
|
-
},
|
|
676
|
-
{
|
|
677
|
-
provide: 'LegacyOrderRepository',
|
|
678
|
-
useFactory: function (firestore) {
|
|
679
|
-
return new i1.LegacyOrderFirestoreRepository(firestore.firestore);
|
|
680
|
-
},
|
|
681
|
-
deps: [i1$1.AngularFirestore],
|
|
682
|
-
},
|
|
683
|
-
{
|
|
684
|
-
provide: 'ShopMenuRepository',
|
|
685
|
-
useFactory: function (firestore) {
|
|
686
|
-
return new i1.ShopMenuFirestoreRepository(firestore.firestore);
|
|
687
|
-
},
|
|
688
|
-
deps: [i1$1.AngularFirestore],
|
|
689
|
-
},
|
|
690
|
-
{
|
|
691
|
-
provide: 'OrderRepository',
|
|
692
|
-
useFactory: function (firestore) {
|
|
693
|
-
return new i1.OrderFirestoreRepository(firestore.firestore);
|
|
694
|
-
},
|
|
695
|
-
deps: [i1$1.AngularFirestore],
|
|
696
|
-
},
|
|
697
|
-
{
|
|
698
|
-
provide: 'PaymentRepository',
|
|
699
|
-
useFactory: function (firestore) {
|
|
700
|
-
return new i1.PaymentFirestoreRepository(firestore.firestore);
|
|
701
|
-
},
|
|
702
|
-
deps: [i1$1.AngularFirestore],
|
|
703
|
-
},
|
|
704
|
-
{
|
|
705
|
-
provide: i1.ProductFirestoreRepository,
|
|
706
|
-
useFactory: function (firestore) {
|
|
707
|
-
return new i1.ProductFirestoreRepository(firestore.firestore);
|
|
708
|
-
},
|
|
709
|
-
deps: [i1$1.AngularFirestore],
|
|
710
|
-
},
|
|
711
|
-
{
|
|
712
|
-
provide: 'ShopSettingsRepository',
|
|
713
|
-
useFactory: function (firestore) {
|
|
714
|
-
return new i1.ShopSettingsFirestoreRepository(firestore.firestore);
|
|
715
|
-
},
|
|
716
|
-
deps: [i1$1.AngularFirestore],
|
|
717
|
-
},
|
|
718
|
-
{
|
|
719
|
-
provide: 'SubscriptionPaymentRepository',
|
|
720
|
-
useFactory: function (firestore, subscriptionRepository) {
|
|
721
|
-
return new i1.SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
|
|
722
|
-
},
|
|
723
|
-
deps: [i1$1.AngularFirestore, 'SubscriptionRepository'],
|
|
724
|
-
},
|
|
725
|
-
{
|
|
726
|
-
provide: 'SubscriptionPlanRepository',
|
|
727
|
-
useFactory: function (firestore) {
|
|
728
|
-
return new i1.SubscriptionPlanFirestoreRepository(firestore.firestore);
|
|
729
|
-
},
|
|
730
|
-
deps: [i1$1.AngularFirestore],
|
|
731
|
-
},
|
|
732
|
-
{
|
|
733
|
-
provide: 'SubscriptionProductRepository',
|
|
734
|
-
useFactory: function (firestore) {
|
|
735
|
-
return new i1.SubscriptionProductFirestoreRepository(firestore.firestore);
|
|
736
|
-
},
|
|
737
|
-
deps: [i1$1.AngularFirestore],
|
|
738
|
-
},
|
|
739
|
-
{
|
|
740
|
-
provide: 'SubscriptionRepository',
|
|
741
|
-
useFactory: function (firestore) {
|
|
742
|
-
return new i1.SubscriptionFirestoreRepository(firestore.firestore);
|
|
743
|
-
},
|
|
744
|
-
deps: [i1$1.AngularFirestore],
|
|
745
|
-
},
|
|
746
|
-
{
|
|
747
|
-
provide: 'UserRepository',
|
|
748
|
-
useFactory: function (firestore) {
|
|
749
|
-
return new i1.UserFirestoreRepository(firestore.firestore);
|
|
750
|
-
},
|
|
751
|
-
deps: [i1$1.AngularFirestore],
|
|
752
|
-
},
|
|
753
|
-
{
|
|
754
|
-
provide: 'UserAddressRepository',
|
|
755
|
-
useFactory: function (firestore, userRepository) {
|
|
756
|
-
return new i1.UserAddressFirestoreRepository(firestore.firestore, userRepository);
|
|
757
|
-
},
|
|
758
|
-
deps: [i1$1.AngularFirestore, 'UserRepository'],
|
|
759
|
-
},
|
|
760
|
-
{
|
|
761
|
-
provide: 'UserPaymentMethodRepository',
|
|
762
|
-
useFactory: function (firestore, userRepository) {
|
|
763
|
-
return new i1.UserPaymentMethodFirestoreRepository(firestore.firestore, userRepository);
|
|
764
|
-
},
|
|
765
|
-
deps: [i1$1.AngularFirestore, 'UserRepository'],
|
|
766
|
-
},
|
|
767
|
-
{
|
|
768
|
-
provide: 'SubscriptionMaterializationRepository',
|
|
769
|
-
useFactory: function (firestore) {
|
|
770
|
-
return new i1.SubscriptionMaterializationFirestoreRepository(firestore.firestore);
|
|
771
|
-
},
|
|
772
|
-
deps: [i1$1.AngularFirestore],
|
|
773
|
-
},
|
|
774
|
-
{
|
|
775
|
-
provide: i1.ProductVariantFirestoreRepository,
|
|
776
|
-
useFactory: function (firestore, productRepository) {
|
|
777
|
-
return new i1.ProductVariantFirestoreRepository(firestore.firestore, productRepository);
|
|
778
|
-
},
|
|
779
|
-
deps: [i1$1.AngularFirestore, i1.ProductFirestoreRepository],
|
|
780
|
-
},
|
|
781
|
-
{
|
|
782
|
-
provide: i0.APP_INITIALIZER,
|
|
783
|
-
useFactory: function (firestore) { return function () { return firestore.firestore.settings({ ignoreUndefinedProperties: true }); }; },
|
|
784
|
-
deps: [i1$1.AngularFirestore],
|
|
785
|
-
multi: true,
|
|
786
|
-
},
|
|
787
|
-
],
|
|
788
|
-
}]
|
|
789
|
-
}] });
|
|
790
|
-
|
|
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));
|
|
724
|
+
CheckoutService.prototype.getCheckout = function (checkoutData) {
|
|
725
|
+
var checkoutId = cookie__default["default"].get('checkoutId');
|
|
726
|
+
if (!i3.isNil(checkoutId))
|
|
727
|
+
return rxjs.from(this.checkoutRepository.get({ id: checkoutId }));
|
|
728
|
+
return rxjs.from(this.createCheckout(checkoutData));
|
|
1340
729
|
};
|
|
1341
730
|
CheckoutService.prototype.getUserByCheckout = function (checkoutId) {
|
|
1342
731
|
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
|
|
732
|
+
return rxjs.from(this.checkoutRepository.get({ id: checkoutId })).pipe(operators.concatMap(function (checkout) { var _a; return ((_a = checkout === null || checkout === void 0 ? void 0 : checkout.user) === null || _a === void 0 ? void 0 : _a.id) ? rxjs.of(checkout.user) : rxjs.from(_this.userRepository.get({ id: checkout.user.id })); }), operators.concatMap(function (user) { return rxjs.of(user) || rxjs.throwError(function () { return new i3.NotFoundError('User is not found'); }); }));
|
|
1344
733
|
};
|
|
1345
734
|
CheckoutService.prototype.updateCheckoutLineItems = function (checkout) {
|
|
1346
|
-
return rxjs.from(this.checkoutRepository.update(
|
|
735
|
+
return rxjs.from(this.checkoutRepository.update(i3.Checkout.toInstance({ id: checkout.id, lineItems: checkout.lineItems })));
|
|
1347
736
|
};
|
|
1348
737
|
CheckoutService.prototype.updateCheckoutUser = function (checkout) {
|
|
1349
|
-
return rxjs.from(this.checkoutRepository.update(
|
|
738
|
+
return rxjs.from(this.checkoutRepository.update(i3.Checkout.toInstance({ id: checkout.id, user: checkout.user })));
|
|
1350
739
|
};
|
|
1351
740
|
CheckoutService.prototype.clearCheckoutFromSession = function () {
|
|
1352
741
|
cookie__default["default"].remove('checkoutId');
|
|
@@ -1363,14 +752,19 @@
|
|
|
1363
752
|
};
|
|
1364
753
|
CheckoutService.prototype.checkCoupon = function (nickname, checkoutType) {
|
|
1365
754
|
var _this = this;
|
|
1366
|
-
return this.getCheckout().pipe(operators.concatMap(function (checkout) {
|
|
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
|
+
}));
|
|
1367
761
|
};
|
|
1368
762
|
CheckoutService.prototype.createCheckout = function (checkoutData) {
|
|
1369
763
|
return __awaiter(this, void 0, void 0, function () {
|
|
1370
764
|
var checkout;
|
|
1371
765
|
return __generator(this, function (_b) {
|
|
1372
766
|
switch (_b.label) {
|
|
1373
|
-
case 0: return [4 /*yield*/, this.checkoutRepository.create(Object.assign(Object.assign({ createdAt: new Date() },
|
|
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 }))];
|
|
1374
768
|
case 1:
|
|
1375
769
|
checkout = _b.sent();
|
|
1376
770
|
cookie__default["default"].set('checkoutId', checkout.id);
|
|
@@ -1395,24 +789,23 @@
|
|
|
1395
789
|
}] }, { type: undefined, decorators: [{
|
|
1396
790
|
type: i0.Inject,
|
|
1397
791
|
args: ['UserRepository']
|
|
1398
|
-
}] }, { type:
|
|
792
|
+
}] }, { type: i3__namespace.Shops, decorators: [{
|
|
1399
793
|
type: i0.Inject,
|
|
1400
794
|
args: [DEFAULT_SHOP]
|
|
1401
795
|
}] }];
|
|
1402
796
|
} });
|
|
1403
797
|
|
|
1404
798
|
var CartService = /** @class */ (function () {
|
|
1405
|
-
function CartService(authService, checkoutService, defaultShop, productRepository,
|
|
799
|
+
function CartService(authService, checkoutService, defaultShop, productRepository, variantRepository, buy2WinRepository) {
|
|
1406
800
|
var _this = this;
|
|
1407
801
|
this.authService = authService;
|
|
1408
802
|
this.checkoutService = checkoutService;
|
|
1409
803
|
this.defaultShop = defaultShop;
|
|
1410
804
|
this.productRepository = productRepository;
|
|
1411
|
-
this.categoryRepository = categoryRepository;
|
|
1412
805
|
this.variantRepository = variantRepository;
|
|
1413
806
|
this.buy2WinRepository = buy2WinRepository;
|
|
1414
807
|
this.cartSubject = new rxjs.Subject();
|
|
1415
|
-
this.updateLineItemInCart = function (lineItem, quantity, checkout) { return (
|
|
808
|
+
this.updateLineItemInCart = function (lineItem, quantity, checkout) { return (i3.isNil(checkout) ? _this.checkoutService.getCheckout() : rxjs.of(checkout)).pipe(operators.concatMap(function (checkoutLoaded) {
|
|
1416
809
|
var _a;
|
|
1417
810
|
var items = [];
|
|
1418
811
|
var index = (_a = checkoutLoaded.lineItems) === null || _a === void 0 ? void 0 : _a.map(function (checkoutItem) { return checkoutItem.id; }).indexOf(lineItem.id);
|
|
@@ -1430,7 +823,7 @@
|
|
|
1430
823
|
? items.reduce(function (cart, item) {
|
|
1431
824
|
var _h;
|
|
1432
825
|
var _a;
|
|
1433
|
-
return (Object.assign(Object.assign({}, cart), (_h = {}, _h[item.id] =
|
|
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)));
|
|
1434
827
|
}, {})
|
|
1435
828
|
: []; };
|
|
1436
829
|
this.buildLineItem = function (_h) {
|
|
@@ -1453,10 +846,9 @@
|
|
|
1453
846
|
shop: checkout.shop || this.defaultShop,
|
|
1454
847
|
isSubscriber: (_e = checkout.user) === null || _e === void 0 ? void 0 : _e.isSubscriber,
|
|
1455
848
|
});
|
|
1456
|
-
i1.RoundProductPricesHelper.roundProductPrices(item);
|
|
1457
849
|
return [2 /*return*/, {
|
|
1458
850
|
checkout: checkout,
|
|
1459
|
-
lineItem:
|
|
851
|
+
lineItem: i3.LineItem.toInstance({
|
|
1460
852
|
id: id,
|
|
1461
853
|
name: name !== null && name !== void 0 ? name : product.name,
|
|
1462
854
|
EAN: EAN !== null && EAN !== void 0 ? EAN : product.EAN,
|
|
@@ -1513,7 +905,7 @@
|
|
|
1513
905
|
return this.checkoutService.getCheckout().pipe(operators.map(function (checkout) {
|
|
1514
906
|
var _a;
|
|
1515
907
|
var checkoutItem = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.find(function (lineItem) { return lineItem.id === item.id; });
|
|
1516
|
-
if (!
|
|
908
|
+
if (!i3.isNil(checkoutItem))
|
|
1517
909
|
checkoutItem.quantity -= checkoutItem.quantity > 1 ? 1 : 0;
|
|
1518
910
|
return checkout;
|
|
1519
911
|
}), 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,7 +932,7 @@
|
|
|
1540
932
|
};
|
|
1541
933
|
CartService.prototype.updateUserCart = function (user) {
|
|
1542
934
|
var _this = this;
|
|
1543
|
-
return this.checkoutService.getCheckout().pipe(operators.concatMap(function (checkout) { return _this.checkoutService.updateCheckoutUser(
|
|
935
|
+
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 () {
|
|
1544
936
|
var _a, _b, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
1545
937
|
var _this = this;
|
|
1546
938
|
return __generator(this, function (_s) {
|
|
@@ -1548,7 +940,7 @@
|
|
|
1548
940
|
case 0:
|
|
1549
941
|
_j = (_h = this.checkoutService)
|
|
1550
942
|
.updateCheckoutLineItems;
|
|
1551
|
-
_l = (_k =
|
|
943
|
+
_l = (_k = i3.Checkout).toInstance;
|
|
1552
944
|
_o = (_m = Object).assign;
|
|
1553
945
|
_p = [Object.assign({}, checkout.toPlain())];
|
|
1554
946
|
_q = {};
|
|
@@ -1583,12 +975,13 @@
|
|
|
1583
975
|
return this.checkoutService.getCheckout(checkoutData).pipe(operators.map(function (checkout) { return checkout.lineItems; }), operators.concatMap(function (lineItems) { return rxjs.of(_this.generateCartObject(lineItems)); }));
|
|
1584
976
|
};
|
|
1585
977
|
CartService.prototype.roundPrice = function (productPrice) {
|
|
1586
|
-
var price = productPrice.price, fullPrice = productPrice.fullPrice
|
|
1587
|
-
|
|
978
|
+
var price = productPrice.price, fullPrice = productPrice.fullPrice;
|
|
979
|
+
var round = function (value) { return Math.round((value + Number.EPSILON) * 100) / 100; };
|
|
980
|
+
return Object.assign(Object.assign(Object.assign({}, productPrice), { price: Number(price.toFixed(2)), fullPrice: Number(fullPrice.toFixed(2)) }), (productPrice.subscriberPrice && { subscriberPrice: Number(productPrice.subscriberPrice.toFixed(2)) }));
|
|
1588
981
|
};
|
|
1589
982
|
CartService.prototype.getProductData = function (productId) {
|
|
1590
983
|
return __awaiter(this, void 0, void 0, function () {
|
|
1591
|
-
var product, variant, error_1
|
|
984
|
+
var product, variant, error_1;
|
|
1592
985
|
return __generator(this, function (_h) {
|
|
1593
986
|
switch (_h.label) {
|
|
1594
987
|
case 0:
|
|
@@ -1599,14 +992,11 @@
|
|
|
1599
992
|
return [3 /*break*/, 5];
|
|
1600
993
|
case 2:
|
|
1601
994
|
error_1 = _h.sent();
|
|
1602
|
-
if (!(error_1 instanceof
|
|
995
|
+
if (!(error_1 instanceof i3.NotFoundError))
|
|
1603
996
|
throw error_1;
|
|
1604
|
-
return [4 /*yield*/, this.variantRepository.
|
|
997
|
+
return [4 /*yield*/, this.variantRepository.get({ id: productId })];
|
|
1605
998
|
case 3:
|
|
1606
|
-
|
|
1607
|
-
variant = variants.shift();
|
|
1608
|
-
if (!variant)
|
|
1609
|
-
throw error_1;
|
|
999
|
+
variant = _h.sent();
|
|
1610
1000
|
return [4 /*yield*/, this.productRepository.get({ id: variant.productId })];
|
|
1611
1001
|
case 4:
|
|
1612
1002
|
product = _h.sent();
|
|
@@ -1619,8 +1009,8 @@
|
|
|
1619
1009
|
CartService.prototype.getGifts = function () {
|
|
1620
1010
|
var _this = this;
|
|
1621
1011
|
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,
|
|
1623
|
-
var
|
|
1012
|
+
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;
|
|
1013
|
+
var e_3, _k, e_2, _l, e_1, _m;
|
|
1624
1014
|
return __generator(this, function (_o) {
|
|
1625
1015
|
switch (_o.label) {
|
|
1626
1016
|
case 0:
|
|
@@ -1631,8 +1021,8 @@
|
|
|
1631
1021
|
return [4 /*yield*/, this.buy2WinRepository
|
|
1632
1022
|
.find({
|
|
1633
1023
|
filters: {
|
|
1634
|
-
active: { operator:
|
|
1635
|
-
shop: { operator:
|
|
1024
|
+
active: { operator: i3.Where.EQUALS, value: true },
|
|
1025
|
+
shop: { operator: i3.Where.EQUALS, value: this.defaultShop },
|
|
1636
1026
|
},
|
|
1637
1027
|
})
|
|
1638
1028
|
.then(function (data) { return data.data; })];
|
|
@@ -1642,158 +1032,105 @@
|
|
|
1642
1032
|
return [2 /*return*/, Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems })];
|
|
1643
1033
|
elegibleCampaigns = [];
|
|
1644
1034
|
_loop_1 = function (campaign) {
|
|
1645
|
-
var today
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
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*/];
|
|
1035
|
+
var today = new Date();
|
|
1036
|
+
if (!(campaign.startDate <= today) && !(campaign.endDate >= today))
|
|
1037
|
+
return "continue";
|
|
1038
|
+
if (campaign.activeCategory) {
|
|
1039
|
+
var categoriesCampaing_1 = campaign.categories.map(function (c) { return c.id; });
|
|
1040
|
+
var filterProductsCategories = checkout.lineItems.filter(function (l) {
|
|
1041
|
+
var _a;
|
|
1042
|
+
if (!l.categories || !((_a = l.categories) === null || _a === void 0 ? void 0 : _a.length))
|
|
1043
|
+
return true;
|
|
1044
|
+
return l.categories.some(function (c) { return categoriesCampaing_1.some(function (cat) { return cat == c; }); });
|
|
1045
|
+
});
|
|
1046
|
+
if (filterProductsCategories.length) {
|
|
1047
|
+
var cartTotalCategories = filterProductsCategories.reduce(function (a, b) { return a + b.pricePaid * b.quantity; }, 0);
|
|
1048
|
+
if (cartTotalCategories >= campaign.cartValueMin)
|
|
1049
|
+
elegibleCampaigns.push(campaign);
|
|
1704
1050
|
}
|
|
1705
|
-
}
|
|
1051
|
+
}
|
|
1052
|
+
else {
|
|
1053
|
+
if (campaign.cartValue && campaign.cartValue > 0) {
|
|
1054
|
+
if (campaign.cartValue <= cartTotal)
|
|
1055
|
+
elegibleCampaigns.push(campaign);
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1706
1058
|
};
|
|
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
1059
|
try {
|
|
1730
|
-
|
|
1060
|
+
for (campaigns_1 = __values(campaigns), campaigns_1_1 = campaigns_1.next(); !campaigns_1_1.done; campaigns_1_1 = campaigns_1.next()) {
|
|
1061
|
+
campaign = campaigns_1_1.value;
|
|
1062
|
+
_loop_1(campaign);
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
1066
|
+
finally {
|
|
1067
|
+
try {
|
|
1068
|
+
if (campaigns_1_1 && !campaigns_1_1.done && (_k = campaigns_1.return)) _k.call(campaigns_1);
|
|
1069
|
+
}
|
|
1070
|
+
finally { if (e_3) throw e_3.error; }
|
|
1731
1071
|
}
|
|
1732
|
-
finally { if (e_1) throw e_1.error; }
|
|
1733
|
-
return [7 /*endfinally*/];
|
|
1734
|
-
case 9:
|
|
1735
1072
|
if (!elegibleCampaigns.length)
|
|
1736
1073
|
return [2 /*return*/, Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems })];
|
|
1737
1074
|
campaingnProducts = [];
|
|
1738
|
-
_o.label =
|
|
1739
|
-
case
|
|
1740
|
-
_o.trys.push([
|
|
1075
|
+
_o.label = 2;
|
|
1076
|
+
case 2:
|
|
1077
|
+
_o.trys.push([2, 14, 15, 16]);
|
|
1741
1078
|
elegibleCampaigns_1 = __values(elegibleCampaigns), elegibleCampaigns_1_1 = elegibleCampaigns_1.next();
|
|
1742
|
-
_o.label =
|
|
1743
|
-
case
|
|
1744
|
-
if (!!elegibleCampaigns_1_1.done) return [3 /*break*/,
|
|
1079
|
+
_o.label = 3;
|
|
1080
|
+
case 3:
|
|
1081
|
+
if (!!elegibleCampaigns_1_1.done) return [3 /*break*/, 13];
|
|
1745
1082
|
campaign = elegibleCampaigns_1_1.value;
|
|
1746
1083
|
elegibleProducts = [];
|
|
1747
|
-
_o.label =
|
|
1748
|
-
case
|
|
1749
|
-
_o.trys.push([
|
|
1750
|
-
_h = (
|
|
1751
|
-
_o.label =
|
|
1752
|
-
case
|
|
1753
|
-
if (!!_j.done) return [3 /*break*/,
|
|
1084
|
+
_o.label = 4;
|
|
1085
|
+
case 4:
|
|
1086
|
+
_o.trys.push([4, 9, 10, 11]);
|
|
1087
|
+
_h = (e_1 = void 0, __values(campaign.products)), _j = _h.next();
|
|
1088
|
+
_o.label = 5;
|
|
1089
|
+
case 5:
|
|
1090
|
+
if (!!_j.done) return [3 /*break*/, 8];
|
|
1754
1091
|
product = _j.value;
|
|
1755
1092
|
return [4 /*yield*/, this.productRepository.find({ filters: { sku: product } })];
|
|
1756
|
-
case
|
|
1093
|
+
case 6:
|
|
1757
1094
|
productData = (_o.sent()).data;
|
|
1758
1095
|
if (!productData.length)
|
|
1759
|
-
return [3 /*break*/,
|
|
1096
|
+
return [3 /*break*/, 7];
|
|
1760
1097
|
gift = productData.shift();
|
|
1761
1098
|
if (gift.stock.quantity < 1)
|
|
1762
|
-
return [3 /*break*/,
|
|
1099
|
+
return [3 /*break*/, 7];
|
|
1763
1100
|
elegibleProducts.push(gift);
|
|
1764
|
-
_o.label =
|
|
1765
|
-
case
|
|
1101
|
+
_o.label = 7;
|
|
1102
|
+
case 7:
|
|
1766
1103
|
_j = _h.next();
|
|
1767
|
-
return [3 /*break*/,
|
|
1768
|
-
case
|
|
1769
|
-
case
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
return [3 /*break*/,
|
|
1773
|
-
case
|
|
1104
|
+
return [3 /*break*/, 5];
|
|
1105
|
+
case 8: return [3 /*break*/, 11];
|
|
1106
|
+
case 9:
|
|
1107
|
+
e_1_1 = _o.sent();
|
|
1108
|
+
e_1 = { error: e_1_1 };
|
|
1109
|
+
return [3 /*break*/, 11];
|
|
1110
|
+
case 10:
|
|
1774
1111
|
try {
|
|
1775
1112
|
if (_j && !_j.done && (_m = _h.return)) _m.call(_h);
|
|
1776
1113
|
}
|
|
1777
|
-
finally { if (
|
|
1114
|
+
finally { if (e_1) throw e_1.error; }
|
|
1778
1115
|
return [7 /*endfinally*/];
|
|
1779
|
-
case
|
|
1116
|
+
case 11:
|
|
1780
1117
|
campaingnProducts.push(elegibleProducts);
|
|
1781
|
-
_o.label =
|
|
1782
|
-
case
|
|
1118
|
+
_o.label = 12;
|
|
1119
|
+
case 12:
|
|
1783
1120
|
elegibleCampaigns_1_1 = elegibleCampaigns_1.next();
|
|
1784
|
-
return [3 /*break*/,
|
|
1785
|
-
case
|
|
1786
|
-
case
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
return [3 /*break*/,
|
|
1790
|
-
case
|
|
1121
|
+
return [3 /*break*/, 3];
|
|
1122
|
+
case 13: return [3 /*break*/, 16];
|
|
1123
|
+
case 14:
|
|
1124
|
+
e_2_1 = _o.sent();
|
|
1125
|
+
e_2 = { error: e_2_1 };
|
|
1126
|
+
return [3 /*break*/, 16];
|
|
1127
|
+
case 15:
|
|
1791
1128
|
try {
|
|
1792
1129
|
if (elegibleCampaigns_1_1 && !elegibleCampaigns_1_1.done && (_l = elegibleCampaigns_1.return)) _l.call(elegibleCampaigns_1);
|
|
1793
1130
|
}
|
|
1794
|
-
finally { if (
|
|
1131
|
+
finally { if (e_2) throw e_2.error; }
|
|
1795
1132
|
return [7 /*endfinally*/];
|
|
1796
|
-
case
|
|
1133
|
+
case 16:
|
|
1797
1134
|
if (!campaingnProducts.length)
|
|
1798
1135
|
return [2 /*return*/, Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems })];
|
|
1799
1136
|
gifts = this.giftToLineItems([].concat.apply([], __spreadArray([], __read(campaingnProducts))));
|
|
@@ -1807,7 +1144,7 @@
|
|
|
1807
1144
|
var _a;
|
|
1808
1145
|
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
1146
|
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
|
|
1147
|
+
return i3.LineItem.toInstance({
|
|
1811
1148
|
brand: brand,
|
|
1812
1149
|
categories: categories,
|
|
1813
1150
|
id: id.toString(),
|
|
@@ -1827,239 +1164,26 @@
|
|
|
1827
1164
|
};
|
|
1828
1165
|
return CartService;
|
|
1829
1166
|
}());
|
|
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: '
|
|
1167
|
+
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 });
|
|
1831
1168
|
CartService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CartService });
|
|
1832
1169
|
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CartService, decorators: [{
|
|
1833
1170
|
type: i0.Injectable
|
|
1834
1171
|
}], ctorParameters: function () {
|
|
1835
|
-
return [{ type: AuthService }, { type: CheckoutService }, { type:
|
|
1172
|
+
return [{ type: AuthService }, { type: CheckoutService }, { type: i3__namespace.Shops, decorators: [{
|
|
1836
1173
|
type: i0.Inject,
|
|
1837
1174
|
args: [DEFAULT_SHOP]
|
|
1838
1175
|
}] }, { type: undefined, decorators: [{
|
|
1839
1176
|
type: i0.Inject,
|
|
1840
1177
|
args: ['ProductRepository']
|
|
1841
|
-
}] }, { type: undefined, decorators: [{
|
|
1842
|
-
type: i0.Inject,
|
|
1843
|
-
args: ['CategoryRepository']
|
|
1844
1178
|
}] }, { type: undefined, decorators: [{
|
|
1845
1179
|
type: i0.Inject,
|
|
1846
1180
|
args: ['VariantRepository']
|
|
1847
|
-
}] }, { type:
|
|
1181
|
+
}] }, { type: i3__namespace.Buy2WinFirestoreRepository, decorators: [{
|
|
1848
1182
|
type: i0.Inject,
|
|
1849
1183
|
args: ['Buy2WinRepository']
|
|
1850
1184
|
}] }];
|
|
1851
1185
|
} });
|
|
1852
1186
|
|
|
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
1187
|
var CheckoutSubscriptionService = /** @class */ (function () {
|
|
2064
1188
|
function CheckoutSubscriptionService(checkoutSubscriptionRepository, subscriptionRepository, couponService) {
|
|
2065
1189
|
this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
|
|
@@ -2068,7 +1192,7 @@
|
|
|
2068
1192
|
}
|
|
2069
1193
|
CheckoutSubscriptionService.prototype.getCheckoutSubscription = function (checkoutData) {
|
|
2070
1194
|
var checkoutId = cookie__default["default"].get('checkoutSubscriptionId');
|
|
2071
|
-
if (!
|
|
1195
|
+
if (!i3.isNil(checkoutId))
|
|
2072
1196
|
return rxjs.from(this.checkoutSubscriptionRepository.get({ id: checkoutId }));
|
|
2073
1197
|
return rxjs.from(this.createCheckoutSubscription(checkoutData));
|
|
2074
1198
|
};
|
|
@@ -2077,7 +1201,7 @@
|
|
|
2077
1201
|
var checkout;
|
|
2078
1202
|
return __generator(this, function (_a) {
|
|
2079
1203
|
switch (_a.label) {
|
|
2080
|
-
case 0: return [4 /*yield*/, this.checkoutSubscriptionRepository.create(Object.assign({ createdAt: new Date() },
|
|
1204
|
+
case 0: return [4 /*yield*/, this.checkoutSubscriptionRepository.create(Object.assign({ createdAt: new Date() }, i3.CheckoutSubscription.toInstance(i3.pick(checkoutData, ['user', 'shop'])).toPlain()))];
|
|
2081
1205
|
case 1:
|
|
2082
1206
|
checkout = _a.sent();
|
|
2083
1207
|
cookie__default["default"].set('checkoutSubscriptionId', checkout.id);
|
|
@@ -2093,7 +1217,7 @@
|
|
|
2093
1217
|
CheckoutSubscriptionService.prototype.checkCoupon = function (nickname, userEmail) {
|
|
2094
1218
|
var _this = this;
|
|
2095
1219
|
return this.getCheckoutSubscription().pipe(operators.concatMap(function (checkout) { return _this.couponService
|
|
2096
|
-
.checkCoupon(nickname,
|
|
1220
|
+
.checkCoupon(nickname, userEmail, i3.CheckoutTypes.SUBSCRIPTION, checkout.subscriptionPlan.name, checkout, true)
|
|
2097
1221
|
.pipe(); }));
|
|
2098
1222
|
};
|
|
2099
1223
|
CheckoutSubscriptionService.prototype.calcDiscountSubscription = function (coupon) {
|
|
@@ -2125,8 +1249,8 @@
|
|
|
2125
1249
|
this.buildCategoryGroupWithRequiredData = function (group) {
|
|
2126
1250
|
var _a, _b;
|
|
2127
1251
|
return ({
|
|
2128
|
-
category:
|
|
2129
|
-
products: ((_b = group === null || group === void 0 ? void 0 : group.products) === null || _b === void 0 ? void 0 : _b.map(function (product) { return
|
|
1252
|
+
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'])),
|
|
1253
|
+
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()) || {}, [
|
|
2130
1254
|
'id',
|
|
2131
1255
|
'price',
|
|
2132
1256
|
'reviews',
|
|
@@ -2147,9 +1271,9 @@
|
|
|
2147
1271
|
}
|
|
2148
1272
|
Object.defineProperty(HomeShopService.prototype, "homeId", {
|
|
2149
1273
|
get: function () {
|
|
2150
|
-
if (this.defaultShop ===
|
|
1274
|
+
if (this.defaultShop === i3.Shops.GLAMSHOP)
|
|
2151
1275
|
return 'glamshop';
|
|
2152
|
-
if (this.defaultShop ===
|
|
1276
|
+
if (this.defaultShop === i3.Shops.MENSMARKET)
|
|
2153
1277
|
return 'mens_market';
|
|
2154
1278
|
return null;
|
|
2155
1279
|
},
|
|
@@ -2195,7 +1319,7 @@
|
|
|
2195
1319
|
HomeShopService.prototype.getVerticalProducts = function () {
|
|
2196
1320
|
var _this = this;
|
|
2197
1321
|
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:
|
|
1322
|
+
filters: { categories: { operator: i3.Where.IN, value: [category.id] } },
|
|
2199
1323
|
limits: { limit: 12 },
|
|
2200
1324
|
})).pipe(operators.map(function (products) { return ({ category: category, products: products }); })); }), operators.map(function (_c) {
|
|
2201
1325
|
var category = _c.category, products = _c.products;
|
|
@@ -2207,14 +1331,14 @@
|
|
|
2207
1331
|
return rxjs.of(this.homeConfiguration).pipe(operators.concatMap(function (home) { return home
|
|
2208
1332
|
? rxjs.of(home)
|
|
2209
1333
|
: !_this.homeId
|
|
2210
|
-
? rxjs.throwError(new
|
|
1334
|
+
? rxjs.throwError(new i3.RequiredArgumentError(['homeId']))
|
|
2211
1335
|
: rxjs.from(_this.homeRepository.get({ id: _this.homeId })).pipe(operators.tap(function (homeLoaded) { return (_this.homeConfiguration = homeLoaded); })); }));
|
|
2212
1336
|
};
|
|
2213
1337
|
HomeShopService.prototype.saveHomeData = function (homeData) {
|
|
2214
1338
|
var _this = this;
|
|
2215
1339
|
var data = {
|
|
2216
1340
|
createdAt: new Date(),
|
|
2217
|
-
expiresAt:
|
|
1341
|
+
expiresAt: i3.add(new Date(), { hours: 1 }),
|
|
2218
1342
|
data: homeData,
|
|
2219
1343
|
};
|
|
2220
1344
|
return rxjs.from(this.homeRepository.update({
|
|
@@ -2238,7 +1362,7 @@
|
|
|
2238
1362
|
}] }, { type: undefined, decorators: [{
|
|
2239
1363
|
type: i0.Inject,
|
|
2240
1364
|
args: ['ProductRepository']
|
|
2241
|
-
}] }, { type:
|
|
1365
|
+
}] }, { type: i3__namespace.Shops, decorators: [{
|
|
2242
1366
|
type: i0.Inject,
|
|
2243
1367
|
args: [DEFAULT_SHOP]
|
|
2244
1368
|
}] }];
|
|
@@ -2255,18 +1379,18 @@
|
|
|
2255
1379
|
this.angularFirestore
|
|
2256
1380
|
.doc(this.orderRepository.collectionName + "/" + id)
|
|
2257
1381
|
.valueChanges()
|
|
2258
|
-
.pipe(operators.map(function (doc) { return
|
|
1382
|
+
.pipe(operators.map(function (doc) { return i3.Order.toInstance(doc); }))
|
|
2259
1383
|
.subscribe(function (doc) { return _this.orderSubject.next(doc); });
|
|
2260
1384
|
return this.orderSubject;
|
|
2261
1385
|
};
|
|
2262
1386
|
return OrderService;
|
|
2263
1387
|
}());
|
|
2264
|
-
OrderService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: OrderService, deps: [{ token: i1__namespace$
|
|
1388
|
+
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 });
|
|
2265
1389
|
OrderService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: OrderService });
|
|
2266
1390
|
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: OrderService, decorators: [{
|
|
2267
1391
|
type: i0.Injectable
|
|
2268
1392
|
}], ctorParameters: function () {
|
|
2269
|
-
return [{ type: i1__namespace$
|
|
1393
|
+
return [{ type: i1__namespace$1.AngularFirestore }, { type: i3__namespace.OrderFirestoreRepository, decorators: [{
|
|
2270
1394
|
type: i0.Inject,
|
|
2271
1395
|
args: ['OrderRepository']
|
|
2272
1396
|
}] }];
|
|
@@ -2306,7 +1430,7 @@
|
|
|
2306
1430
|
return s;
|
|
2307
1431
|
});
|
|
2308
1432
|
}
|
|
2309
|
-
if (shop ==
|
|
1433
|
+
if (shop == i3.Shops.GLAMSHOP)
|
|
2310
1434
|
return shippingMethods;
|
|
2311
1435
|
if (_this.isFreeShippingBySubscription(shop, subscriptionPlan)) {
|
|
2312
1436
|
shippingMethods = shippingMethods.map(function (s) {
|
|
@@ -2327,7 +1451,7 @@
|
|
|
2327
1451
|
ShippingService.prototype.isFreeShippingBySubscription = function (shop, subscriptionPlan) {
|
|
2328
1452
|
if (!subscriptionPlan)
|
|
2329
1453
|
return false;
|
|
2330
|
-
if (shop ==
|
|
1454
|
+
if (shop == i3.Shops.MENSMARKET && subscriptionPlan == 'SELECT') {
|
|
2331
1455
|
return true;
|
|
2332
1456
|
}
|
|
2333
1457
|
return false;
|
|
@@ -2335,7 +1459,7 @@
|
|
|
2335
1459
|
ShippingService.prototype.isHalfShippingBySubscription = function (shop, subscriptionPlan) {
|
|
2336
1460
|
if (!subscriptionPlan)
|
|
2337
1461
|
return false;
|
|
2338
|
-
if (shop ==
|
|
1462
|
+
if (shop == i3.Shops.MENSMARKET && subscriptionPlan == 'PRIME') {
|
|
2339
1463
|
return true;
|
|
2340
1464
|
}
|
|
2341
1465
|
return false;
|
|
@@ -2354,293 +1478,746 @@
|
|
|
2354
1478
|
};
|
|
2355
1479
|
return ShippingService;
|
|
2356
1480
|
}());
|
|
2357
|
-
ShippingService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: ShippingService, deps: [{ token: i1__namespace$
|
|
1481
|
+
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 });
|
|
2358
1482
|
ShippingService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: ShippingService });
|
|
2359
1483
|
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: ShippingService, decorators: [{
|
|
2360
1484
|
type: i0.Injectable
|
|
2361
1485
|
}], ctorParameters: function () {
|
|
2362
|
-
return [{ type: i1__namespace$
|
|
1486
|
+
return [{ type: i1__namespace$2.HttpClient }, { type: undefined, decorators: [{
|
|
2363
1487
|
type: i0.Inject,
|
|
2364
1488
|
args: [BACKEND_URL]
|
|
2365
1489
|
}] }, { type: HomeShopService }];
|
|
2366
1490
|
} });
|
|
2367
1491
|
|
|
2368
|
-
var
|
|
2369
|
-
function
|
|
2370
|
-
this.categoryRepository = categoryRepository;
|
|
2371
|
-
this.categoryCollectionChildrenRepository = categoryCollectionChildrenRepository;
|
|
1492
|
+
var AngularFirebaseAuthModule = /** @class */ (function () {
|
|
1493
|
+
function AngularFirebaseAuthModule() {
|
|
2372
1494
|
}
|
|
2373
|
-
|
|
2374
|
-
return
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
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
|
-
});
|
|
1495
|
+
AngularFirebaseAuthModule.initializeApp = function (options, nameOrConfig) {
|
|
1496
|
+
return {
|
|
1497
|
+
ngModule: AngularFirebaseAuthModule,
|
|
1498
|
+
providers: [
|
|
1499
|
+
{ provide: fire.FIREBASE_OPTIONS, useValue: options },
|
|
1500
|
+
{ provide: fire.FIREBASE_APP_NAME, useValue: nameOrConfig },
|
|
1501
|
+
],
|
|
1502
|
+
};
|
|
2427
1503
|
};
|
|
2428
|
-
return
|
|
1504
|
+
return AngularFirebaseAuthModule;
|
|
2429
1505
|
}());
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
i0__namespace.ɵɵ
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
1506
|
+
AngularFirebaseAuthModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
|
|
1507
|
+
AngularFirebaseAuthModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, imports: [fire.AngularFireModule] });
|
|
1508
|
+
AngularFirebaseAuthModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, providers: [
|
|
1509
|
+
{
|
|
1510
|
+
provide: 'Authentication',
|
|
1511
|
+
useFactory: function (authenticationService, userRepository) {
|
|
1512
|
+
return new i3.Authentication(authenticationService, userRepository);
|
|
1513
|
+
},
|
|
1514
|
+
deps: ['AuthenticationService', 'UserRepository'],
|
|
1515
|
+
},
|
|
1516
|
+
{
|
|
1517
|
+
provide: 'AuthenticationService',
|
|
1518
|
+
useFactory: function (angularFireAuth) {
|
|
1519
|
+
return new i3.AuthenticationFirebaseAuthService(angularFireAuth);
|
|
1520
|
+
},
|
|
1521
|
+
deps: [i1.AngularFireAuth],
|
|
1522
|
+
},
|
|
1523
|
+
{
|
|
1524
|
+
provide: 'Register',
|
|
1525
|
+
useFactory: function (registerService, userRepository) {
|
|
1526
|
+
return new i3.Register(registerService, userRepository);
|
|
1527
|
+
},
|
|
1528
|
+
deps: ['RegisterService', 'UserRepository'],
|
|
1529
|
+
},
|
|
1530
|
+
{
|
|
1531
|
+
provide: 'RegisterService',
|
|
1532
|
+
useFactory: function (angularFireAuth) {
|
|
1533
|
+
return new i3.RegisterFirebaseAuthService(angularFireAuth);
|
|
1534
|
+
},
|
|
1535
|
+
deps: [i1.AngularFireAuth],
|
|
1536
|
+
},
|
|
1537
|
+
{
|
|
1538
|
+
provide: 'SignOut',
|
|
1539
|
+
useFactory: function (authenticationService) {
|
|
1540
|
+
return new i3.SignOut(authenticationService);
|
|
1541
|
+
},
|
|
1542
|
+
deps: ['AuthenticationService'],
|
|
1543
|
+
},
|
|
1544
|
+
{
|
|
1545
|
+
provide: 'RecoveryPassword',
|
|
1546
|
+
useFactory: function (authenticationService) {
|
|
1547
|
+
return new i3.RecoveryPassword(authenticationService);
|
|
1548
|
+
},
|
|
1549
|
+
deps: ['AuthenticationService'],
|
|
1550
|
+
},
|
|
1551
|
+
], imports: [[fire.AngularFireModule]] });
|
|
1552
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, decorators: [{
|
|
1553
|
+
type: i0.NgModule,
|
|
1554
|
+
args: [{
|
|
1555
|
+
imports: [fire.AngularFireModule],
|
|
1556
|
+
providers: [
|
|
1557
|
+
{
|
|
1558
|
+
provide: 'Authentication',
|
|
1559
|
+
useFactory: function (authenticationService, userRepository) {
|
|
1560
|
+
return new i3.Authentication(authenticationService, userRepository);
|
|
1561
|
+
},
|
|
1562
|
+
deps: ['AuthenticationService', 'UserRepository'],
|
|
1563
|
+
},
|
|
1564
|
+
{
|
|
1565
|
+
provide: 'AuthenticationService',
|
|
1566
|
+
useFactory: function (angularFireAuth) {
|
|
1567
|
+
return new i3.AuthenticationFirebaseAuthService(angularFireAuth);
|
|
1568
|
+
},
|
|
1569
|
+
deps: [i1.AngularFireAuth],
|
|
1570
|
+
},
|
|
1571
|
+
{
|
|
1572
|
+
provide: 'Register',
|
|
1573
|
+
useFactory: function (registerService, userRepository) {
|
|
1574
|
+
return new i3.Register(registerService, userRepository);
|
|
1575
|
+
},
|
|
1576
|
+
deps: ['RegisterService', 'UserRepository'],
|
|
1577
|
+
},
|
|
1578
|
+
{
|
|
1579
|
+
provide: 'RegisterService',
|
|
1580
|
+
useFactory: function (angularFireAuth) {
|
|
1581
|
+
return new i3.RegisterFirebaseAuthService(angularFireAuth);
|
|
1582
|
+
},
|
|
1583
|
+
deps: [i1.AngularFireAuth],
|
|
1584
|
+
},
|
|
1585
|
+
{
|
|
1586
|
+
provide: 'SignOut',
|
|
1587
|
+
useFactory: function (authenticationService) {
|
|
1588
|
+
return new i3.SignOut(authenticationService);
|
|
1589
|
+
},
|
|
1590
|
+
deps: ['AuthenticationService'],
|
|
1591
|
+
},
|
|
1592
|
+
{
|
|
1593
|
+
provide: 'RecoveryPassword',
|
|
1594
|
+
useFactory: function (authenticationService) {
|
|
1595
|
+
return new i3.RecoveryPassword(authenticationService);
|
|
1596
|
+
},
|
|
1597
|
+
deps: ['AuthenticationService'],
|
|
1598
|
+
},
|
|
1599
|
+
],
|
|
1600
|
+
}]
|
|
1601
|
+
}] });
|
|
2443
1602
|
|
|
2444
|
-
var
|
|
2445
|
-
function
|
|
2446
|
-
this.categoryRepository = categoryRepository;
|
|
1603
|
+
var AngularElasticSeachModule = /** @class */ (function () {
|
|
1604
|
+
function AngularElasticSeachModule() {
|
|
2447
1605
|
}
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
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
|
-
});
|
|
1606
|
+
AngularElasticSeachModule.initializeApp = function (options) {
|
|
1607
|
+
return {
|
|
1608
|
+
ngModule: AngularElasticSeachModule,
|
|
1609
|
+
providers: [{ provide: ES_CONFIG, useValue: options }],
|
|
1610
|
+
};
|
|
2468
1611
|
};
|
|
2469
|
-
return
|
|
1612
|
+
return AngularElasticSeachModule;
|
|
2470
1613
|
}());
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
i0__namespace.ɵɵ
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
1614
|
+
AngularElasticSeachModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularElasticSeachModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
|
|
1615
|
+
AngularElasticSeachModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularElasticSeachModule });
|
|
1616
|
+
AngularElasticSeachModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularElasticSeachModule, providers: [
|
|
1617
|
+
{
|
|
1618
|
+
provide: i3.ProductsIndex,
|
|
1619
|
+
useFactory: function (configuration) { return new i3.ProductsIndex(new i3.AxiosAdapter(configuration)); },
|
|
1620
|
+
deps: [ES_CONFIG],
|
|
1621
|
+
},
|
|
1622
|
+
] });
|
|
1623
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularElasticSeachModule, decorators: [{
|
|
1624
|
+
type: i0.NgModule,
|
|
1625
|
+
args: [{
|
|
1626
|
+
providers: [
|
|
1627
|
+
{
|
|
1628
|
+
provide: i3.ProductsIndex,
|
|
1629
|
+
useFactory: function (configuration) { return new i3.ProductsIndex(new i3.AxiosAdapter(configuration)); },
|
|
1630
|
+
deps: [ES_CONFIG],
|
|
1631
|
+
},
|
|
1632
|
+
],
|
|
1633
|
+
}]
|
|
1634
|
+
}] });
|
|
2481
1635
|
|
|
2482
|
-
var
|
|
2483
|
-
function
|
|
1636
|
+
var AngularFirestoreModule = /** @class */ (function () {
|
|
1637
|
+
function AngularFirestoreModule() {
|
|
2484
1638
|
}
|
|
2485
|
-
|
|
1639
|
+
AngularFirestoreModule.initializeApp = function (options, nameOrConfig) {
|
|
2486
1640
|
return {
|
|
2487
|
-
ngModule:
|
|
2488
|
-
providers:
|
|
2489
|
-
{
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
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 }]))),
|
|
1641
|
+
ngModule: AngularFirestoreModule,
|
|
1642
|
+
providers: [
|
|
1643
|
+
{ provide: fire.FIREBASE_OPTIONS, useValue: options.firebase },
|
|
1644
|
+
{ provide: fire.FIREBASE_APP_NAME, useValue: nameOrConfig },
|
|
1645
|
+
{ provide: ES_CONFIG, useValue: options.elasticSearch },
|
|
1646
|
+
],
|
|
2496
1647
|
};
|
|
2497
1648
|
};
|
|
2498
|
-
return
|
|
1649
|
+
return AngularFirestoreModule;
|
|
2499
1650
|
}());
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
1651
|
+
AngularFirestoreModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
|
|
1652
|
+
AngularFirestoreModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, imports: [fire.AngularFireModule, AngularElasticSeachModule] });
|
|
1653
|
+
AngularFirestoreModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, providers: [
|
|
1654
|
+
{
|
|
1655
|
+
provide: 'BeautyProfileRepository',
|
|
1656
|
+
useFactory: function (firestore, userRepository) {
|
|
1657
|
+
return new i3.UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
|
|
1658
|
+
},
|
|
1659
|
+
deps: [i1$1.AngularFirestore, 'UserRepository'],
|
|
1660
|
+
},
|
|
1661
|
+
{
|
|
1662
|
+
provide: 'Buy2WinRepository',
|
|
1663
|
+
useFactory: function (firestore) {
|
|
1664
|
+
return new i3.Buy2WinFirestoreRepository(firestore.firestore);
|
|
1665
|
+
},
|
|
1666
|
+
deps: [i1$1.AngularFirestore],
|
|
1667
|
+
},
|
|
1668
|
+
{
|
|
1669
|
+
provide: i3.CategoryFirestoreRepository,
|
|
1670
|
+
useFactory: function (firestore) {
|
|
1671
|
+
return new i3.CategoryFirestoreRepository(firestore.firestore);
|
|
1672
|
+
},
|
|
1673
|
+
deps: [i1$1.AngularFirestore],
|
|
1674
|
+
},
|
|
1675
|
+
{
|
|
1676
|
+
provide: 'CheckoutRepository',
|
|
1677
|
+
useFactory: function (firestore) {
|
|
1678
|
+
return new i3.CheckoutFirestoreRepository(firestore.firestore);
|
|
1679
|
+
},
|
|
1680
|
+
deps: [i1$1.AngularFirestore],
|
|
1681
|
+
},
|
|
1682
|
+
{
|
|
1683
|
+
provide: 'CheckoutSubscriptionRepository',
|
|
1684
|
+
useFactory: function (firestore) {
|
|
1685
|
+
return new i3.CheckoutSubscriptionFirestoreRepository(firestore.firestore);
|
|
1686
|
+
},
|
|
1687
|
+
deps: [i1$1.AngularFirestore],
|
|
1688
|
+
},
|
|
1689
|
+
{
|
|
1690
|
+
provide: 'CouponRepository',
|
|
1691
|
+
useFactory: function (firestore) {
|
|
1692
|
+
return new i3.CouponFirestoreRepository(firestore.firestore);
|
|
1693
|
+
},
|
|
1694
|
+
deps: [i1$1.AngularFirestore],
|
|
1695
|
+
},
|
|
1696
|
+
{
|
|
1697
|
+
provide: 'CampaignHashtagRepository',
|
|
1698
|
+
useFactory: function (firestore) {
|
|
1699
|
+
return new i3.CampaignHashtagFirestoreRepository(firestore.firestore);
|
|
1700
|
+
},
|
|
1701
|
+
deps: [i1$1.AngularFirestore],
|
|
1702
|
+
},
|
|
1703
|
+
{
|
|
1704
|
+
provide: 'CampaignDashboardRepository',
|
|
1705
|
+
useFactory: function (firestore) {
|
|
1706
|
+
return new i3.CampaignDashboardFirestoreRepository(firestore.firestore);
|
|
1707
|
+
},
|
|
1708
|
+
deps: [i1$1.AngularFirestore],
|
|
1709
|
+
},
|
|
1710
|
+
{
|
|
1711
|
+
provide: 'EditionRepository',
|
|
1712
|
+
useFactory: function (firestore, subscriptionRepository) {
|
|
1713
|
+
return new i3.SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
|
|
1714
|
+
},
|
|
1715
|
+
deps: [i1$1.AngularFirestore, 'SubscriptionRepository'],
|
|
1716
|
+
},
|
|
1717
|
+
{
|
|
1718
|
+
provide: 'HomeRepository',
|
|
1719
|
+
useFactory: function (firestore) {
|
|
1720
|
+
return new i3.HomeFirestoreRepository(firestore.firestore);
|
|
1721
|
+
},
|
|
1722
|
+
deps: [i1$1.AngularFirestore],
|
|
1723
|
+
},
|
|
1724
|
+
{
|
|
1725
|
+
provide: 'LeadRepository',
|
|
1726
|
+
useFactory: function (firestore) {
|
|
1727
|
+
return new i3.LeadFirestoreRepository(firestore.firestore);
|
|
1728
|
+
},
|
|
1729
|
+
deps: [i1$1.AngularFirestore],
|
|
1730
|
+
},
|
|
1731
|
+
{
|
|
1732
|
+
provide: 'LegacyOrderRepository',
|
|
1733
|
+
useFactory: function (firestore) {
|
|
1734
|
+
return new i3.LegacyOrderFirestoreRepository(firestore.firestore);
|
|
1735
|
+
},
|
|
1736
|
+
deps: [i1$1.AngularFirestore],
|
|
1737
|
+
},
|
|
1738
|
+
{
|
|
1739
|
+
provide: 'ShopMenuRepository',
|
|
1740
|
+
useFactory: function (firestore) {
|
|
1741
|
+
return new i3.ShopMenuFirestoreRepository(firestore.firestore);
|
|
1742
|
+
},
|
|
1743
|
+
deps: [i1$1.AngularFirestore],
|
|
1744
|
+
},
|
|
1745
|
+
{
|
|
1746
|
+
provide: 'OrderRepository',
|
|
1747
|
+
useFactory: function (firestore) {
|
|
1748
|
+
return new i3.OrderFirestoreRepository(firestore.firestore);
|
|
1749
|
+
},
|
|
1750
|
+
deps: [i1$1.AngularFirestore],
|
|
1751
|
+
},
|
|
1752
|
+
{
|
|
1753
|
+
provide: 'PaymentRepository',
|
|
1754
|
+
useFactory: function (firestore) {
|
|
1755
|
+
return new i3.PaymentFirestoreRepository(firestore.firestore);
|
|
1756
|
+
},
|
|
1757
|
+
deps: [i1$1.AngularFirestore],
|
|
1758
|
+
},
|
|
1759
|
+
{
|
|
1760
|
+
provide: i3.ProductFirestoreRepository,
|
|
1761
|
+
useFactory: function (firestore) {
|
|
1762
|
+
return new i3.ProductFirestoreRepository(firestore.firestore);
|
|
1763
|
+
},
|
|
1764
|
+
deps: [i1$1.AngularFirestore],
|
|
1765
|
+
},
|
|
1766
|
+
{
|
|
1767
|
+
provide: 'ShopSettingsRepository',
|
|
1768
|
+
useFactory: function (firestore) {
|
|
1769
|
+
return new i3.ShopSettingsFirestoreRepository(firestore.firestore);
|
|
1770
|
+
},
|
|
1771
|
+
deps: [i1$1.AngularFirestore],
|
|
1772
|
+
},
|
|
1773
|
+
{
|
|
1774
|
+
provide: 'SubscriptionPaymentRepository',
|
|
1775
|
+
useFactory: function (firestore, subscriptionRepository) {
|
|
1776
|
+
return new i3.SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
|
|
1777
|
+
},
|
|
1778
|
+
deps: [i1$1.AngularFirestore, 'SubscriptionRepository'],
|
|
1779
|
+
},
|
|
1780
|
+
{
|
|
1781
|
+
provide: 'SubscriptionPlanRepository',
|
|
1782
|
+
useFactory: function (firestore) {
|
|
1783
|
+
return new i3.SubscriptionPlanFirestoreRepository(firestore.firestore);
|
|
1784
|
+
},
|
|
1785
|
+
deps: [i1$1.AngularFirestore],
|
|
1786
|
+
},
|
|
1787
|
+
{
|
|
1788
|
+
provide: 'SubscriptionProductRepository',
|
|
1789
|
+
useFactory: function (firestore) {
|
|
1790
|
+
return new i3.SubscriptionProductFirestoreRepository(firestore.firestore);
|
|
1791
|
+
},
|
|
1792
|
+
deps: [i1$1.AngularFirestore],
|
|
1793
|
+
},
|
|
1794
|
+
{
|
|
1795
|
+
provide: 'SubscriptionRepository',
|
|
1796
|
+
useFactory: function (firestore) {
|
|
1797
|
+
return new i3.SubscriptionFirestoreRepository(firestore.firestore);
|
|
1798
|
+
},
|
|
1799
|
+
deps: [i1$1.AngularFirestore],
|
|
1800
|
+
},
|
|
1801
|
+
{
|
|
1802
|
+
provide: 'UserRepository',
|
|
1803
|
+
useFactory: function (firestore) {
|
|
1804
|
+
return new i3.UserFirestoreRepository(firestore.firestore);
|
|
1805
|
+
},
|
|
1806
|
+
deps: [i1$1.AngularFirestore],
|
|
1807
|
+
},
|
|
1808
|
+
{
|
|
1809
|
+
provide: 'UserAddressRepository',
|
|
1810
|
+
useFactory: function (firestore, userRepository) {
|
|
1811
|
+
return new i3.UserAddressFirestoreRepository(firestore.firestore, userRepository);
|
|
1812
|
+
},
|
|
1813
|
+
deps: [i1$1.AngularFirestore, 'UserRepository'],
|
|
1814
|
+
},
|
|
1815
|
+
{
|
|
1816
|
+
provide: 'UserPaymentMethodRepository',
|
|
1817
|
+
useFactory: function (firestore, userRepository) {
|
|
1818
|
+
return new i3.UserPaymentMethodFirestoreRepository(firestore.firestore, userRepository);
|
|
1819
|
+
},
|
|
1820
|
+
deps: [i1$1.AngularFirestore, 'UserRepository'],
|
|
1821
|
+
},
|
|
1822
|
+
{
|
|
1823
|
+
provide: i3.ProductVariantFirestoreRepository,
|
|
1824
|
+
useFactory: function (firestore, productRepository) {
|
|
1825
|
+
return new i3.ProductVariantFirestoreRepository(firestore.firestore, productRepository);
|
|
1826
|
+
},
|
|
1827
|
+
deps: [i1$1.AngularFirestore, i3.ProductFirestoreRepository],
|
|
1828
|
+
},
|
|
1829
|
+
{
|
|
1830
|
+
provide: i0.APP_INITIALIZER,
|
|
1831
|
+
useFactory: function (firestore) { return function () { return firestore.firestore.settings({ ignoreUndefinedProperties: true }); }; },
|
|
1832
|
+
deps: [i1$1.AngularFirestore],
|
|
1833
|
+
multi: true,
|
|
1834
|
+
},
|
|
1835
|
+
], imports: [[fire.AngularFireModule, AngularElasticSeachModule]] });
|
|
1836
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, decorators: [{
|
|
2515
1837
|
type: i0.NgModule,
|
|
2516
1838
|
args: [{
|
|
2517
|
-
imports: [fire.AngularFireModule,
|
|
1839
|
+
imports: [fire.AngularFireModule, AngularElasticSeachModule],
|
|
2518
1840
|
providers: [
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
1841
|
+
{
|
|
1842
|
+
provide: 'BeautyProfileRepository',
|
|
1843
|
+
useFactory: function (firestore, userRepository) {
|
|
1844
|
+
return new i3.UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
|
|
1845
|
+
},
|
|
1846
|
+
deps: [i1$1.AngularFirestore, 'UserRepository'],
|
|
1847
|
+
},
|
|
1848
|
+
{
|
|
1849
|
+
provide: 'Buy2WinRepository',
|
|
1850
|
+
useFactory: function (firestore) {
|
|
1851
|
+
return new i3.Buy2WinFirestoreRepository(firestore.firestore);
|
|
1852
|
+
},
|
|
1853
|
+
deps: [i1$1.AngularFirestore],
|
|
1854
|
+
},
|
|
1855
|
+
{
|
|
1856
|
+
provide: i3.CategoryFirestoreRepository,
|
|
1857
|
+
useFactory: function (firestore) {
|
|
1858
|
+
return new i3.CategoryFirestoreRepository(firestore.firestore);
|
|
1859
|
+
},
|
|
1860
|
+
deps: [i1$1.AngularFirestore],
|
|
1861
|
+
},
|
|
1862
|
+
{
|
|
1863
|
+
provide: 'CheckoutRepository',
|
|
1864
|
+
useFactory: function (firestore) {
|
|
1865
|
+
return new i3.CheckoutFirestoreRepository(firestore.firestore);
|
|
1866
|
+
},
|
|
1867
|
+
deps: [i1$1.AngularFirestore],
|
|
1868
|
+
},
|
|
1869
|
+
{
|
|
1870
|
+
provide: 'CheckoutSubscriptionRepository',
|
|
1871
|
+
useFactory: function (firestore) {
|
|
1872
|
+
return new i3.CheckoutSubscriptionFirestoreRepository(firestore.firestore);
|
|
1873
|
+
},
|
|
1874
|
+
deps: [i1$1.AngularFirestore],
|
|
1875
|
+
},
|
|
1876
|
+
{
|
|
1877
|
+
provide: 'CouponRepository',
|
|
1878
|
+
useFactory: function (firestore) {
|
|
1879
|
+
return new i3.CouponFirestoreRepository(firestore.firestore);
|
|
1880
|
+
},
|
|
1881
|
+
deps: [i1$1.AngularFirestore],
|
|
1882
|
+
},
|
|
1883
|
+
{
|
|
1884
|
+
provide: 'CampaignHashtagRepository',
|
|
1885
|
+
useFactory: function (firestore) {
|
|
1886
|
+
return new i3.CampaignHashtagFirestoreRepository(firestore.firestore);
|
|
1887
|
+
},
|
|
1888
|
+
deps: [i1$1.AngularFirestore],
|
|
1889
|
+
},
|
|
1890
|
+
{
|
|
1891
|
+
provide: 'CampaignDashboardRepository',
|
|
1892
|
+
useFactory: function (firestore) {
|
|
1893
|
+
return new i3.CampaignDashboardFirestoreRepository(firestore.firestore);
|
|
1894
|
+
},
|
|
1895
|
+
deps: [i1$1.AngularFirestore],
|
|
1896
|
+
},
|
|
1897
|
+
{
|
|
1898
|
+
provide: 'EditionRepository',
|
|
1899
|
+
useFactory: function (firestore, subscriptionRepository) {
|
|
1900
|
+
return new i3.SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
|
|
1901
|
+
},
|
|
1902
|
+
deps: [i1$1.AngularFirestore, 'SubscriptionRepository'],
|
|
1903
|
+
},
|
|
1904
|
+
{
|
|
1905
|
+
provide: 'HomeRepository',
|
|
1906
|
+
useFactory: function (firestore) {
|
|
1907
|
+
return new i3.HomeFirestoreRepository(firestore.firestore);
|
|
1908
|
+
},
|
|
1909
|
+
deps: [i1$1.AngularFirestore],
|
|
1910
|
+
},
|
|
1911
|
+
{
|
|
1912
|
+
provide: 'LeadRepository',
|
|
1913
|
+
useFactory: function (firestore) {
|
|
1914
|
+
return new i3.LeadFirestoreRepository(firestore.firestore);
|
|
1915
|
+
},
|
|
1916
|
+
deps: [i1$1.AngularFirestore],
|
|
1917
|
+
},
|
|
1918
|
+
{
|
|
1919
|
+
provide: 'LegacyOrderRepository',
|
|
1920
|
+
useFactory: function (firestore) {
|
|
1921
|
+
return new i3.LegacyOrderFirestoreRepository(firestore.firestore);
|
|
1922
|
+
},
|
|
1923
|
+
deps: [i1$1.AngularFirestore],
|
|
1924
|
+
},
|
|
1925
|
+
{
|
|
1926
|
+
provide: 'ShopMenuRepository',
|
|
1927
|
+
useFactory: function (firestore) {
|
|
1928
|
+
return new i3.ShopMenuFirestoreRepository(firestore.firestore);
|
|
1929
|
+
},
|
|
1930
|
+
deps: [i1$1.AngularFirestore],
|
|
1931
|
+
},
|
|
1932
|
+
{
|
|
1933
|
+
provide: 'OrderRepository',
|
|
1934
|
+
useFactory: function (firestore) {
|
|
1935
|
+
return new i3.OrderFirestoreRepository(firestore.firestore);
|
|
1936
|
+
},
|
|
1937
|
+
deps: [i1$1.AngularFirestore],
|
|
1938
|
+
},
|
|
1939
|
+
{
|
|
1940
|
+
provide: 'PaymentRepository',
|
|
1941
|
+
useFactory: function (firestore) {
|
|
1942
|
+
return new i3.PaymentFirestoreRepository(firestore.firestore);
|
|
1943
|
+
},
|
|
1944
|
+
deps: [i1$1.AngularFirestore],
|
|
1945
|
+
},
|
|
1946
|
+
{
|
|
1947
|
+
provide: i3.ProductFirestoreRepository,
|
|
1948
|
+
useFactory: function (firestore) {
|
|
1949
|
+
return new i3.ProductFirestoreRepository(firestore.firestore);
|
|
1950
|
+
},
|
|
1951
|
+
deps: [i1$1.AngularFirestore],
|
|
1952
|
+
},
|
|
1953
|
+
{
|
|
1954
|
+
provide: 'ShopSettingsRepository',
|
|
1955
|
+
useFactory: function (firestore) {
|
|
1956
|
+
return new i3.ShopSettingsFirestoreRepository(firestore.firestore);
|
|
1957
|
+
},
|
|
1958
|
+
deps: [i1$1.AngularFirestore],
|
|
1959
|
+
},
|
|
1960
|
+
{
|
|
1961
|
+
provide: 'SubscriptionPaymentRepository',
|
|
1962
|
+
useFactory: function (firestore, subscriptionRepository) {
|
|
1963
|
+
return new i3.SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
|
|
1964
|
+
},
|
|
1965
|
+
deps: [i1$1.AngularFirestore, 'SubscriptionRepository'],
|
|
1966
|
+
},
|
|
1967
|
+
{
|
|
1968
|
+
provide: 'SubscriptionPlanRepository',
|
|
1969
|
+
useFactory: function (firestore) {
|
|
1970
|
+
return new i3.SubscriptionPlanFirestoreRepository(firestore.firestore);
|
|
1971
|
+
},
|
|
1972
|
+
deps: [i1$1.AngularFirestore],
|
|
1973
|
+
},
|
|
1974
|
+
{
|
|
1975
|
+
provide: 'SubscriptionProductRepository',
|
|
1976
|
+
useFactory: function (firestore) {
|
|
1977
|
+
return new i3.SubscriptionProductFirestoreRepository(firestore.firestore);
|
|
1978
|
+
},
|
|
1979
|
+
deps: [i1$1.AngularFirestore],
|
|
1980
|
+
},
|
|
1981
|
+
{
|
|
1982
|
+
provide: 'SubscriptionRepository',
|
|
1983
|
+
useFactory: function (firestore) {
|
|
1984
|
+
return new i3.SubscriptionFirestoreRepository(firestore.firestore);
|
|
1985
|
+
},
|
|
1986
|
+
deps: [i1$1.AngularFirestore],
|
|
1987
|
+
},
|
|
1988
|
+
{
|
|
1989
|
+
provide: 'UserRepository',
|
|
1990
|
+
useFactory: function (firestore) {
|
|
1991
|
+
return new i3.UserFirestoreRepository(firestore.firestore);
|
|
1992
|
+
},
|
|
1993
|
+
deps: [i1$1.AngularFirestore],
|
|
1994
|
+
},
|
|
1995
|
+
{
|
|
1996
|
+
provide: 'UserAddressRepository',
|
|
1997
|
+
useFactory: function (firestore, userRepository) {
|
|
1998
|
+
return new i3.UserAddressFirestoreRepository(firestore.firestore, userRepository);
|
|
1999
|
+
},
|
|
2000
|
+
deps: [i1$1.AngularFirestore, 'UserRepository'],
|
|
2001
|
+
},
|
|
2002
|
+
{
|
|
2003
|
+
provide: 'UserPaymentMethodRepository',
|
|
2004
|
+
useFactory: function (firestore, userRepository) {
|
|
2005
|
+
return new i3.UserPaymentMethodFirestoreRepository(firestore.firestore, userRepository);
|
|
2006
|
+
},
|
|
2007
|
+
deps: [i1$1.AngularFirestore, 'UserRepository'],
|
|
2008
|
+
},
|
|
2009
|
+
{
|
|
2010
|
+
provide: i3.ProductVariantFirestoreRepository,
|
|
2011
|
+
useFactory: function (firestore, productRepository) {
|
|
2012
|
+
return new i3.ProductVariantFirestoreRepository(firestore.firestore, productRepository);
|
|
2013
|
+
},
|
|
2014
|
+
deps: [i1$1.AngularFirestore, i3.ProductFirestoreRepository],
|
|
2015
|
+
},
|
|
2016
|
+
{
|
|
2017
|
+
provide: i0.APP_INITIALIZER,
|
|
2018
|
+
useFactory: function (firestore) { return function () { return firestore.firestore.settings({ ignoreUndefinedProperties: true }); }; },
|
|
2019
|
+
deps: [i1$1.AngularFirestore],
|
|
2020
|
+
multi: true,
|
|
2021
|
+
},
|
|
2529
2022
|
],
|
|
2530
2023
|
}]
|
|
2531
2024
|
}] });
|
|
2532
2025
|
|
|
2533
|
-
var
|
|
2534
|
-
function
|
|
2026
|
+
var AngularHasuraGraphQLModule = /** @class */ (function () {
|
|
2027
|
+
function AngularHasuraGraphQLModule() {
|
|
2535
2028
|
}
|
|
2536
|
-
|
|
2029
|
+
AngularHasuraGraphQLModule.initializeApp = function (options) {
|
|
2537
2030
|
return {
|
|
2538
|
-
ngModule:
|
|
2539
|
-
providers: [
|
|
2540
|
-
{ provide: fire.FIREBASE_OPTIONS, useValue: options },
|
|
2541
|
-
{ provide: fire.FIREBASE_APP_NAME, useValue: nameOrConfig },
|
|
2542
|
-
],
|
|
2031
|
+
ngModule: AngularHasuraGraphQLModule,
|
|
2032
|
+
providers: [{ provide: HASURA_OPTIONS, useValue: options }],
|
|
2543
2033
|
};
|
|
2544
2034
|
};
|
|
2545
|
-
return
|
|
2035
|
+
return AngularHasuraGraphQLModule;
|
|
2546
2036
|
}());
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2037
|
+
AngularHasuraGraphQLModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularHasuraGraphQLModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
|
|
2038
|
+
AngularHasuraGraphQLModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularHasuraGraphQLModule });
|
|
2039
|
+
AngularHasuraGraphQLModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularHasuraGraphQLModule, providers: [
|
|
2550
2040
|
{
|
|
2551
|
-
provide: '
|
|
2552
|
-
|
|
2553
|
-
|
|
2041
|
+
provide: 'CategoryRepository',
|
|
2042
|
+
useExisting: i3.CategoryHasuraGraphQLRepository,
|
|
2043
|
+
},
|
|
2044
|
+
{
|
|
2045
|
+
provide: i3.CategoryHasuraGraphQLRepository,
|
|
2046
|
+
useFactory: function (options, productRepository, categoryFilterRepository) {
|
|
2047
|
+
return new i3.CategoryHasuraGraphQLRepository(options.endpoint, options.credentials, productRepository, categoryFilterRepository);
|
|
2554
2048
|
},
|
|
2555
|
-
deps: [
|
|
2049
|
+
deps: [HASURA_OPTIONS, i3.ProductHasuraGraphQLRepository, i3.CategoryFilterHasuraGraphQLRepository],
|
|
2556
2050
|
},
|
|
2557
2051
|
{
|
|
2558
|
-
provide: '
|
|
2559
|
-
|
|
2560
|
-
|
|
2052
|
+
provide: 'ProductRepository',
|
|
2053
|
+
useExisting: i3.ProductHasuraGraphQLRepository,
|
|
2054
|
+
},
|
|
2055
|
+
{
|
|
2056
|
+
provide: i3.ProductHasuraGraphQLRepository,
|
|
2057
|
+
useFactory: function (options) {
|
|
2058
|
+
return new i3.ProductHasuraGraphQLRepository(options.endpoint, options.credentials);
|
|
2561
2059
|
},
|
|
2562
|
-
deps: [
|
|
2060
|
+
deps: [HASURA_OPTIONS],
|
|
2563
2061
|
},
|
|
2564
2062
|
{
|
|
2565
|
-
provide: '
|
|
2566
|
-
|
|
2567
|
-
|
|
2063
|
+
provide: 'VariantRepository',
|
|
2064
|
+
useExisting: i3.VariantHasuraGraphQLRepository,
|
|
2065
|
+
},
|
|
2066
|
+
{
|
|
2067
|
+
provide: i3.VariantHasuraGraphQLRepository,
|
|
2068
|
+
useFactory: function (options) {
|
|
2069
|
+
return new i3.VariantHasuraGraphQLRepository(options.endpoint, options.credentials);
|
|
2568
2070
|
},
|
|
2569
|
-
deps: [
|
|
2071
|
+
deps: [HASURA_OPTIONS],
|
|
2570
2072
|
},
|
|
2571
2073
|
{
|
|
2572
|
-
provide: '
|
|
2573
|
-
|
|
2574
|
-
|
|
2074
|
+
provide: 'CategoryFilterRepository',
|
|
2075
|
+
useExisting: i3.CategoryFilterHasuraGraphQLRepository,
|
|
2076
|
+
},
|
|
2077
|
+
{
|
|
2078
|
+
provide: i3.CategoryFilterHasuraGraphQLRepository,
|
|
2079
|
+
useFactory: function (options) {
|
|
2080
|
+
return new i3.CategoryFilterHasuraGraphQLRepository(options.endpoint, options.credentials);
|
|
2575
2081
|
},
|
|
2576
|
-
deps: [
|
|
2082
|
+
deps: [HASURA_OPTIONS],
|
|
2577
2083
|
},
|
|
2578
2084
|
{
|
|
2579
|
-
provide: '
|
|
2580
|
-
|
|
2581
|
-
|
|
2085
|
+
provide: 'FilterOptionRepository',
|
|
2086
|
+
useExisting: i3.FilterOptionHasuraGraphQLRepository,
|
|
2087
|
+
},
|
|
2088
|
+
{
|
|
2089
|
+
provide: i3.FilterOptionHasuraGraphQLRepository,
|
|
2090
|
+
useFactory: function (options) {
|
|
2091
|
+
return new i3.FilterOptionHasuraGraphQLRepository(options.endpoint, options.credentials);
|
|
2582
2092
|
},
|
|
2583
|
-
deps: [
|
|
2093
|
+
deps: [HASURA_OPTIONS],
|
|
2584
2094
|
},
|
|
2585
2095
|
{
|
|
2586
|
-
provide: '
|
|
2587
|
-
|
|
2588
|
-
|
|
2096
|
+
provide: 'FilterRepository',
|
|
2097
|
+
useExisting: i3.FilterHasuraGraphQLRepository,
|
|
2098
|
+
},
|
|
2099
|
+
{
|
|
2100
|
+
provide: i3.FilterHasuraGraphQLRepository,
|
|
2101
|
+
useFactory: function (options, filterOptionRepository, categoryFilterRepository) {
|
|
2102
|
+
return new i3.FilterHasuraGraphQLRepository(options.endpoint, options.credentials, filterOptionRepository, categoryFilterRepository);
|
|
2589
2103
|
},
|
|
2590
|
-
deps: [
|
|
2104
|
+
deps: [HASURA_OPTIONS, i3.FilterOptionHasuraGraphQLRepository, i3.CategoryFilterHasuraGraphQLRepository],
|
|
2591
2105
|
},
|
|
2592
|
-
]
|
|
2593
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type:
|
|
2106
|
+
] });
|
|
2107
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularHasuraGraphQLModule, decorators: [{
|
|
2594
2108
|
type: i0.NgModule,
|
|
2595
2109
|
args: [{
|
|
2596
|
-
imports: [fire.AngularFireModule],
|
|
2597
2110
|
providers: [
|
|
2598
2111
|
{
|
|
2599
|
-
provide: '
|
|
2600
|
-
|
|
2601
|
-
|
|
2112
|
+
provide: 'CategoryRepository',
|
|
2113
|
+
useExisting: i3.CategoryHasuraGraphQLRepository,
|
|
2114
|
+
},
|
|
2115
|
+
{
|
|
2116
|
+
provide: i3.CategoryHasuraGraphQLRepository,
|
|
2117
|
+
useFactory: function (options, productRepository, categoryFilterRepository) {
|
|
2118
|
+
return new i3.CategoryHasuraGraphQLRepository(options.endpoint, options.credentials, productRepository, categoryFilterRepository);
|
|
2602
2119
|
},
|
|
2603
|
-
deps: [
|
|
2120
|
+
deps: [HASURA_OPTIONS, i3.ProductHasuraGraphQLRepository, i3.CategoryFilterHasuraGraphQLRepository],
|
|
2604
2121
|
},
|
|
2605
2122
|
{
|
|
2606
|
-
provide: '
|
|
2607
|
-
|
|
2608
|
-
|
|
2123
|
+
provide: 'ProductRepository',
|
|
2124
|
+
useExisting: i3.ProductHasuraGraphQLRepository,
|
|
2125
|
+
},
|
|
2126
|
+
{
|
|
2127
|
+
provide: i3.ProductHasuraGraphQLRepository,
|
|
2128
|
+
useFactory: function (options) {
|
|
2129
|
+
return new i3.ProductHasuraGraphQLRepository(options.endpoint, options.credentials);
|
|
2609
2130
|
},
|
|
2610
|
-
deps: [
|
|
2131
|
+
deps: [HASURA_OPTIONS],
|
|
2611
2132
|
},
|
|
2612
2133
|
{
|
|
2613
|
-
provide: '
|
|
2614
|
-
|
|
2615
|
-
|
|
2134
|
+
provide: 'VariantRepository',
|
|
2135
|
+
useExisting: i3.VariantHasuraGraphQLRepository,
|
|
2136
|
+
},
|
|
2137
|
+
{
|
|
2138
|
+
provide: i3.VariantHasuraGraphQLRepository,
|
|
2139
|
+
useFactory: function (options) {
|
|
2140
|
+
return new i3.VariantHasuraGraphQLRepository(options.endpoint, options.credentials);
|
|
2616
2141
|
},
|
|
2617
|
-
deps: [
|
|
2142
|
+
deps: [HASURA_OPTIONS],
|
|
2618
2143
|
},
|
|
2619
2144
|
{
|
|
2620
|
-
provide: '
|
|
2621
|
-
|
|
2622
|
-
|
|
2145
|
+
provide: 'CategoryFilterRepository',
|
|
2146
|
+
useExisting: i3.CategoryFilterHasuraGraphQLRepository,
|
|
2147
|
+
},
|
|
2148
|
+
{
|
|
2149
|
+
provide: i3.CategoryFilterHasuraGraphQLRepository,
|
|
2150
|
+
useFactory: function (options) {
|
|
2151
|
+
return new i3.CategoryFilterHasuraGraphQLRepository(options.endpoint, options.credentials);
|
|
2623
2152
|
},
|
|
2624
|
-
deps: [
|
|
2153
|
+
deps: [HASURA_OPTIONS],
|
|
2625
2154
|
},
|
|
2626
2155
|
{
|
|
2627
|
-
provide: '
|
|
2628
|
-
|
|
2629
|
-
|
|
2156
|
+
provide: 'FilterOptionRepository',
|
|
2157
|
+
useExisting: i3.FilterOptionHasuraGraphQLRepository,
|
|
2158
|
+
},
|
|
2159
|
+
{
|
|
2160
|
+
provide: i3.FilterOptionHasuraGraphQLRepository,
|
|
2161
|
+
useFactory: function (options) {
|
|
2162
|
+
return new i3.FilterOptionHasuraGraphQLRepository(options.endpoint, options.credentials);
|
|
2630
2163
|
},
|
|
2631
|
-
deps: [
|
|
2164
|
+
deps: [HASURA_OPTIONS],
|
|
2632
2165
|
},
|
|
2633
2166
|
{
|
|
2634
|
-
provide: '
|
|
2635
|
-
|
|
2636
|
-
|
|
2167
|
+
provide: 'FilterRepository',
|
|
2168
|
+
useExisting: i3.FilterHasuraGraphQLRepository,
|
|
2169
|
+
},
|
|
2170
|
+
{
|
|
2171
|
+
provide: i3.FilterHasuraGraphQLRepository,
|
|
2172
|
+
useFactory: function (options, filterOptionRepository, categoryFilterRepository) {
|
|
2173
|
+
return new i3.FilterHasuraGraphQLRepository(options.endpoint, options.credentials, filterOptionRepository, categoryFilterRepository);
|
|
2637
2174
|
},
|
|
2638
|
-
deps: [
|
|
2175
|
+
deps: [HASURA_OPTIONS, i3.FilterOptionHasuraGraphQLRepository, i3.CategoryFilterHasuraGraphQLRepository],
|
|
2639
2176
|
},
|
|
2640
2177
|
],
|
|
2641
2178
|
}]
|
|
2642
2179
|
}] });
|
|
2643
2180
|
|
|
2181
|
+
var AngularConnectModule = /** @class */ (function () {
|
|
2182
|
+
function AngularConnectModule() {
|
|
2183
|
+
}
|
|
2184
|
+
AngularConnectModule.initializeApp = function (defaultShop, options, nameOrConfig) {
|
|
2185
|
+
return {
|
|
2186
|
+
ngModule: AngularConnectModule,
|
|
2187
|
+
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 }]))),
|
|
2188
|
+
};
|
|
2189
|
+
};
|
|
2190
|
+
return AngularConnectModule;
|
|
2191
|
+
}());
|
|
2192
|
+
AngularConnectModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
|
|
2193
|
+
AngularConnectModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, imports: [fire.AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule] });
|
|
2194
|
+
AngularConnectModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, providers: [
|
|
2195
|
+
AuthService,
|
|
2196
|
+
CartService,
|
|
2197
|
+
CheckoutService,
|
|
2198
|
+
CheckoutSubscriptionService,
|
|
2199
|
+
CouponService,
|
|
2200
|
+
HomeShopService,
|
|
2201
|
+
OrderService,
|
|
2202
|
+
ShippingService,
|
|
2203
|
+
], imports: [[fire.AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule]] });
|
|
2204
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, decorators: [{
|
|
2205
|
+
type: i0.NgModule,
|
|
2206
|
+
args: [{
|
|
2207
|
+
imports: [fire.AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule],
|
|
2208
|
+
providers: [
|
|
2209
|
+
AuthService,
|
|
2210
|
+
CartService,
|
|
2211
|
+
CheckoutService,
|
|
2212
|
+
CheckoutSubscriptionService,
|
|
2213
|
+
CouponService,
|
|
2214
|
+
HomeShopService,
|
|
2215
|
+
OrderService,
|
|
2216
|
+
ShippingService,
|
|
2217
|
+
],
|
|
2218
|
+
}]
|
|
2219
|
+
}] });
|
|
2220
|
+
|
|
2644
2221
|
/**
|
|
2645
2222
|
* Generated bundle index. Do not edit.
|
|
2646
2223
|
*/
|
|
@@ -2651,9 +2228,6 @@
|
|
|
2651
2228
|
exports.AngularHasuraGraphQLModule = AngularHasuraGraphQLModule;
|
|
2652
2229
|
exports.AuthService = AuthService;
|
|
2653
2230
|
exports.CartService = CartService;
|
|
2654
|
-
exports.CatalogService = CatalogService;
|
|
2655
|
-
exports.CategoryService = CategoryService;
|
|
2656
|
-
exports.CategoryWithTree = CategoryWithTree;
|
|
2657
2231
|
exports.CheckoutService = CheckoutService;
|
|
2658
2232
|
exports.CheckoutSubscriptionService = CheckoutSubscriptionService;
|
|
2659
2233
|
exports.CouponService = CouponService;
|