@infrab4a/connect-angular 3.6.0-beta.15 → 3.6.0-beta.2

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.
@@ -5,13 +5,13 @@ import { AngularFireAuth } from '@angular/fire/auth';
5
5
  import { of, combineLatest, from, throwError, Subject, iif, forkJoin } from 'rxjs';
6
6
  import { catchError, map, mergeMap, concatMap, tap } from 'rxjs/operators';
7
7
  import { __awaiter } from 'tslib';
8
- import * as i3 from '@infrab4a/connect';
9
- import { Coupon, Where, Shops, CheckoutTypes, CouponTypes, Exclusivities, isNil, NotFoundError, Checkout, pick, LineItem, CheckoutSubscription, Category, Product, RequiredArgumentError, add, Order, Authentication, AuthenticationFirebaseAuthService, Register, RegisterFirebaseAuthService, SignOut, RecoveryPassword, ProductsIndex, AxiosAdapter, UserBeautyProfileFirestoreRepository, Buy2WinFirestoreRepository, CategoryFirestoreRepository, CheckoutFirestoreRepository, CheckoutSubscriptionFirestoreRepository, CouponFirestoreRepository, SubscriptionEditionFirestoreRepository, HomeFirestoreRepository, LeadFirestoreRepository, LegacyOrderFirestoreRepository, ShopMenuFirestoreRepository, OrderFirestoreRepository, PaymentFirestoreRepository, ProductFirestoreRepository, SubscriptionPaymentFirestoreRepository, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionFirestoreRepository, UserFirestoreRepository, UserAddressFirestoreRepository, UserPaymentMethodFirestoreRepository, ProductVariantFirestoreRepository, CategoryHasuraGraphQLRepository, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository, VariantHasuraGraphQLRepository, FilterOptionHasuraGraphQLRepository, FilterHasuraGraphQLRepository } from '@infrab4a/connect';
8
+ import * as i1$1 from '@infrab4a/connect';
9
+ import { Coupon, Where, Shops, CheckoutTypes, CouponTypes, Exclusivities, Status, isNil, NotFoundError, Checkout, pick, LineItem, CheckoutSubscription, Category, Product, RequiredArgumentError, add, Order, Authentication, AuthenticationFirebaseAuthService, Register, RegisterFirebaseAuthService, SignOut, RecoveryPassword, ProductsIndex, AxiosAdapter, UserBeautyProfileFirestoreRepository, Buy2WinFirestoreRepository, CategoryFirestoreRepository, CheckoutFirestoreRepository, CheckoutSubscriptionFirestoreRepository, CouponFirestoreRepository, SubscriptionEditionFirestoreRepository, HomeFirestoreRepository, LeadFirestoreRepository, LegacyOrderFirestoreRepository, ShopMenuFirestoreRepository, OrderFirestoreRepository, PaymentFirestoreRepository, ProductFirestoreRepository, ShopSettingsFirestoreRepository, SubscriptionPaymentFirestoreRepository, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionFirestoreRepository, UserFirestoreRepository, UserAddressFirestoreRepository, UserPaymentMethodFirestoreRepository, ProductVariantFirestoreRepository, CategoryHasuraGraphQLRepository, ProductHasuraGraphQLRepository, VariantHasuraGraphQLRepository } from '@infrab4a/connect';
10
10
  import cookie from 'js-cookie';
11
11
  import { CustomError } from 'ts-custom-error';
12
- import * as i1$1 from '@angular/fire/firestore';
12
+ import * as i1$2 from '@angular/fire/firestore';
13
13
  import { AngularFirestore } from '@angular/fire/firestore';
14
- import * as i1$2 from '@angular/common/http';
14
+ import * as i1$3 from '@angular/common/http';
15
15
  import { FIREBASE_OPTIONS, FIREBASE_APP_NAME, AngularFireModule } from '@angular/fire';
16
16
 
17
17
  class AuthService {
@@ -164,7 +164,7 @@ class CouponService {
164
164
  // Verifica o limite de uso geral por usuario
165
165
  if (coupon.useLimit && orders.data.length >= coupon.useLimit)
166
166
  throw new InvalidCouponError('Limite de uso atingido.');
167
- const validUser = this.userValidationAndSubscriptionStatus(coupon, checkout.user);
167
+ const validUser = yield this.userValidationAndSubscriptionStatus(coupon, userEmail);
168
168
  if (!validUser)
169
169
  throw new InvalidCouponError('Usuário não elegível.');
170
170
  const hasProductCategories = yield this.hasProductCategories(coupon, checkout);
@@ -209,7 +209,7 @@ class CouponService {
209
209
  lineItensDiscount = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.filter((i) => {
210
210
  var _a;
211
211
  if ((_a = i.categories) === null || _a === void 0 ? void 0 : _a.length) {
212
- return i.categories.some((c) => couponCategories.some((cat) => cat.id == c || cat.firestoreId == c));
212
+ return i.categories.some((c) => couponCategories.some(cat => (cat.id == c || cat.firestoreId == c)));
213
213
  }
214
214
  return true;
215
215
  });
@@ -249,41 +249,56 @@ class CouponService {
249
249
  return true;
250
250
  }
251
251
  const couponCategories = yield this.getCouponCategoriesId(coupon);
252
- const hasCategories = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.filter((i) => {
252
+ const hasCategories = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.filter(i => {
253
253
  var _a;
254
254
  if (!i.categories || !((_a = i.categories) === null || _a === void 0 ? void 0 : _a.length))
255
255
  return true;
256
- return i.categories.some((c) => couponCategories.some((cat) => cat.id == c || cat.firestoreId == c));
256
+ return i.categories.some((c) => couponCategories.some(cat => (cat.id == c || cat.firestoreId == c)));
257
257
  });
258
258
  return hasCategories.length ? true : false;
259
259
  });
260
260
  }
261
- userValidationAndSubscriptionStatus(coupon, user) {
262
- if (coupon.exclusivityType === Exclusivities.ALL_USERS)
261
+ userValidationAndSubscriptionStatus(coupon, userEmail) {
262
+ return __awaiter(this, void 0, void 0, function* () {
263
+ // Verifica se o email do usuário é coorporativo
264
+ if (!this.emailIsFromCollaborator(userEmail) && coupon.exclusivityType === Exclusivities.COLLABORATORS)
265
+ throw new InvalidCouponError('Você não é colaborador.');
266
+ // Verifica se o email do usuário é associado ao cupom de uso por usuario
267
+ if (coupon.exclusivityType === Exclusivities.SPECIFIC_USER && coupon.userExclusiveEmail !== userEmail)
268
+ throw new InvalidCouponError('Cupom não é válido para este usuário.');
269
+ const couponRuleSubscription = coupon.exclusivityType === Exclusivities.ACTIVE_SUBSCRIBER ||
270
+ coupon.exclusivityType === Exclusivities.INACTIVE_SUBSCRIBER ||
271
+ coupon.exclusivityType === Exclusivities.NON_SUBSCRIBER;
272
+ if (couponRuleSubscription && userEmail) {
273
+ const sub = yield this.subscriptionRepository
274
+ .find({
275
+ filters: {
276
+ user: {
277
+ email: { operator: Where.EQUALS, value: userEmail },
278
+ },
279
+ },
280
+ })
281
+ .then((sub) => sub.data);
282
+ const activeSubs = sub === null || sub === void 0 ? void 0 : sub.filter((s) => s.status === Status.ACTIVE);
283
+ switch (coupon.exclusivityType) {
284
+ case Exclusivities.ACTIVE_SUBSCRIBER:
285
+ return activeSubs.length > 0;
286
+ case Exclusivities.INACTIVE_SUBSCRIBER:
287
+ return activeSubs.length === 0;
288
+ case Exclusivities.NON_SUBSCRIBER:
289
+ return sub.length === 0;
290
+ default:
291
+ return false;
292
+ }
293
+ }
263
294
  return true;
264
- // Verifica se o email do usuário é coorporativo
265
- if (!this.emailIsFromCollaborator(user.email) && coupon.exclusivityType === Exclusivities.COLLABORATORS)
266
- throw new InvalidCouponError('Você não é colaborador.');
267
- // Verifica se o email do usuário é associado ao cupom de uso por usuario
268
- if (coupon.exclusivityType === Exclusivities.SPECIFIC_USER && coupon.userExclusiveEmail !== user.email)
269
- throw new InvalidCouponError('Cupom não é válido para este usuário.');
270
- switch (coupon.exclusivityType) {
271
- case Exclusivities.ACTIVE_SUBSCRIBER:
272
- return user.isSubscriber ? true : false;
273
- case Exclusivities.INACTIVE_SUBSCRIBER:
274
- return user.isSubscriber ? false : true;
275
- case Exclusivities.NON_SUBSCRIBER:
276
- return user.isSubscriber ? false : true;
277
- }
278
- return true;
295
+ });
279
296
  }
280
297
  getCouponCategoriesId(coupon) {
281
298
  return __awaiter(this, void 0, void 0, function* () {
282
299
  let couponCategories = [];
283
300
  for (let index = 0; index < coupon.productsCategories.length; index++) {
284
- let c = yield this.categoryRepository.get({
285
- id: coupon.productsCategories[index],
286
- });
301
+ let c = yield this.categoryRepository.get({ id: coupon.productsCategories[index] });
287
302
  couponCategories.push({ id: c.id, firestoreId: c.firestoreId });
288
303
  }
289
304
  return couponCategories;
@@ -300,7 +315,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImpo
300
315
  }], ctorParameters: function () { return [{ type: undefined, decorators: [{
301
316
  type: Inject,
302
317
  args: ['CouponRepository']
303
- }] }, { type: i3.Shops, decorators: [{
318
+ }] }, { type: i1$1.Shops, decorators: [{
304
319
  type: Inject,
305
320
  args: [DEFAULT_SHOP]
306
321
  }] }, { type: undefined, decorators: [{
@@ -373,18 +388,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImpo
373
388
  }] }, { type: undefined, decorators: [{
374
389
  type: Inject,
375
390
  args: ['UserRepository']
376
- }] }, { type: i3.Shops, decorators: [{
391
+ }] }, { type: i1$1.Shops, decorators: [{
377
392
  type: Inject,
378
393
  args: [DEFAULT_SHOP]
379
394
  }] }]; } });
380
395
 
381
396
  class CartService {
382
- constructor(authService, checkoutService, defaultShop, productRepository, buy2WinRepository) {
397
+ constructor(authService, checkoutService, defaultShop, productRepository) {
383
398
  this.authService = authService;
384
399
  this.checkoutService = checkoutService;
385
400
  this.defaultShop = defaultShop;
386
401
  this.productRepository = productRepository;
387
- this.buy2WinRepository = buy2WinRepository;
388
402
  this.cartSubject = new Subject();
389
403
  this.updateLineItemInCart = (lineItem, quantity, checkout) => (isNil(checkout) ? this.checkoutService.getCheckout() : of(checkout)).pipe(concatMap((checkoutLoaded) => {
390
404
  var _a;
@@ -490,12 +504,8 @@ class CartService {
490
504
  updateUserCart(user) {
491
505
  return this.checkoutService.getCheckout().pipe(concatMap((checkout) => this.checkoutService.updateCheckoutUser(Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { user })))), concatMap((checkout) => __awaiter(this, void 0, void 0, function* () {
492
506
  var _a, _b;
493
- return this.checkoutService
494
- .updateCheckoutLineItems(Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { lineItems: ((_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.length)
495
- ? yield Promise.all((_b = checkout.lineItems) === null || _b === void 0 ? void 0 : _b.map((item) => __awaiter(this, void 0, void 0, function* () { return (yield this.buildLineItem({ checkout, item })).lineItem; })))
496
- : [] })))
497
- .toPromise();
498
- })), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
507
+ return this.checkoutService.updateCheckoutLineItems(Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { lineItems: ((_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.length) ? yield Promise.all((_b = checkout.lineItems) === null || _b === void 0 ? void 0 : _b.map((item) => __awaiter(this, void 0, void 0, function* () { return (yield this.buildLineItem({ checkout, item })).lineItem; }))) : [] }))).toPromise();
508
+ })), map(checkout => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
499
509
  }
500
510
  clearCart() {
501
511
  return this.checkoutService.getCheckout().pipe(map((checkout) => {
@@ -506,171 +516,17 @@ class CartService {
506
516
  buildCartFromCheckout(checkoutData) {
507
517
  return this.checkoutService.getCheckout(checkoutData).pipe(map((checkout) => checkout.lineItems), concatMap((lineItems) => of(this.generateCartObject(lineItems))));
508
518
  }
509
- checkGifts(checkout) {
510
- return __awaiter(this, void 0, void 0, function* () {
511
- const campaigns = yield this.buy2WinRepository
512
- .find({
513
- filters: {
514
- active: { operator: Where.EQUALS, value: true },
515
- shop: { operator: Where.EQUALS, value: this.defaultShop },
516
- },
517
- })
518
- .then((data) => data.data);
519
- const notGiftItems = checkout.lineItems.filter((item) => !item.isGift);
520
- if (!campaigns.length)
521
- return Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems });
522
- const cartTotal = notGiftItems.reduce((a, b) => a + b.pricePaid * b.quantity, 0);
523
- const elegibleCampaigns = [];
524
- for (const campaign of campaigns) {
525
- // problemas: datas, valorcart e valor cartMin, filtros no código
526
- const today = new Date();
527
- if (!(campaign.startDate <= today) && !(campaign.endDate >= today))
528
- continue;
529
- // Passo 2: Verificar se a campanha é por categorias
530
- if (campaign.activeCategory) {
531
- const categoriesCampaing = campaign.categories.map((c) => c.id);
532
- const filterProductsCategories = checkout.lineItems.filter((l) => {
533
- var _a;
534
- if (!l.categories || !((_a = l.categories) === null || _a === void 0 ? void 0 : _a.length))
535
- return true;
536
- return l.categories.some((c) => categoriesCampaing.some((cat) => cat == c));
537
- });
538
- if (filterProductsCategories.length) {
539
- const cartTotalCategories = filterProductsCategories.reduce((a, b) => a + b.pricePaid * b.quantity, 0);
540
- if (cartTotalCategories >= campaign.cartValueMin)
541
- elegibleCampaigns.push(campaign);
542
- }
543
- }
544
- else {
545
- if (campaign.cartValue && campaign.cartValue > 0) {
546
- if (campaign.cartValue <= cartTotal)
547
- elegibleCampaigns.push(campaign);
548
- }
549
- }
550
- // Passo 2.1: Se não for, apenas valida o preço do carrinho
551
- // Passo 2.2: Se for, filta lineItens pelas categorias da campanha, valida valor minimo da categoria
552
- // Passo 3: Se tiver campanha elegiveis, adiciona os produtos ao carrinho
553
- }
554
- if (!elegibleCampaigns.length)
555
- return Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems });
556
- const campaingnProducts = [];
557
- for (const campaign of elegibleCampaigns) {
558
- let elegibleProducts = [];
559
- for (const product of campaign.products) {
560
- const productData = yield this.productRepository.get({ sku: product });
561
- if (!productData)
562
- continue;
563
- elegibleProducts.push(productData);
564
- }
565
- campaingnProducts.push(elegibleProducts);
566
- }
567
- if (!campaingnProducts.length)
568
- return Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems });
569
- const productArray = campaingnProducts.reduce((acc, curr) => acc.reduce((aAcc, aCurr) => aAcc + aCurr.price.price, 0) >
570
- curr.reduce((cAcc, cCurr) => cAcc + cCurr.price.price, 0)
571
- ? acc
572
- : curr);
573
- const gifts = this.giftToLineItems(productArray);
574
- checkout.lineItems = notGiftItems.concat(gifts);
575
- return checkout;
576
- });
577
- }
578
- getGifts() {
579
- return this.checkoutService.getCheckout().pipe(mergeMap((checkout) => __awaiter(this, void 0, void 0, function* () {
580
- const campaigns = yield this.buy2WinRepository
581
- .find({
582
- filters: {
583
- active: { operator: Where.EQUALS, value: true },
584
- shop: { operator: Where.EQUALS, value: this.defaultShop },
585
- },
586
- })
587
- .then((data) => data.data);
588
- const notGiftItems = checkout.lineItems.filter((item) => !item.isGift);
589
- if (!campaigns.length)
590
- return Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems });
591
- const cartTotal = notGiftItems.reduce((a, b) => a + b.pricePaid * b.quantity, 0);
592
- const elegibleCampaigns = [];
593
- for (const campaign of campaigns) {
594
- const today = new Date();
595
- if (!(campaign.startDate <= today) && !(campaign.endDate >= today))
596
- continue;
597
- if (campaign.activeCategory) {
598
- const categoriesCampaing = campaign.categories.map((c) => c.id);
599
- const filterProductsCategories = checkout.lineItems.filter((l) => {
600
- var _a;
601
- if (!l.categories || !((_a = l.categories) === null || _a === void 0 ? void 0 : _a.length))
602
- return true;
603
- return l.categories.some((c) => categoriesCampaing.some((cat) => cat == c));
604
- });
605
- if (filterProductsCategories.length) {
606
- const cartTotalCategories = filterProductsCategories.reduce((a, b) => a + b.pricePaid * b.quantity, 0);
607
- if (cartTotalCategories >= campaign.cartValueMin)
608
- elegibleCampaigns.push(campaign);
609
- }
610
- }
611
- else {
612
- if (campaign.cartValue && campaign.cartValue > 0) {
613
- if (campaign.cartValue <= cartTotal)
614
- elegibleCampaigns.push(campaign);
615
- }
616
- }
617
- }
618
- if (!elegibleCampaigns.length)
619
- return Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems });
620
- const campaingnProducts = [];
621
- for (const campaign of elegibleCampaigns) {
622
- let elegibleProducts = [];
623
- for (const product of campaign.products) {
624
- const productData = yield this.productRepository.get({ sku: product });
625
- if (!productData)
626
- continue;
627
- elegibleProducts.push(productData);
628
- }
629
- campaingnProducts.push(elegibleProducts);
630
- }
631
- if (!campaingnProducts.length)
632
- return Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems });
633
- const gifts = this.giftToLineItems([].concat(...campaingnProducts));
634
- return Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems.concat(gifts) });
635
- })), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
636
- }
637
- giftToLineItems(items) {
638
- return items.map((item) => {
639
- var _a;
640
- const { brand, categories, id, name, price, sku, slug, stock, weight, EAN } = item;
641
- const 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];
642
- return LineItem.toInstance({
643
- brand,
644
- categories,
645
- id: id.toString(),
646
- name,
647
- price,
648
- sku,
649
- slug,
650
- stock,
651
- weight,
652
- EAN,
653
- image,
654
- pricePaid: 0,
655
- quantity: 1,
656
- isGift: true,
657
- });
658
- });
659
- }
660
519
  }
661
- CartService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CartService, deps: [{ token: AuthService }, { token: CheckoutService }, { token: DEFAULT_SHOP }, { token: 'ProductRepository' }, { token: 'Buy2WinRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
520
+ CartService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CartService, deps: [{ token: AuthService }, { token: CheckoutService }, { token: DEFAULT_SHOP }, { token: 'ProductRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
662
521
  CartService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CartService });
663
522
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CartService, decorators: [{
664
523
  type: Injectable
665
- }], ctorParameters: function () { return [{ type: AuthService }, { type: CheckoutService }, { type: i3.Shops, decorators: [{
524
+ }], ctorParameters: function () { return [{ type: AuthService }, { type: CheckoutService }, { type: i1$1.Shops, decorators: [{
666
525
  type: Inject,
667
526
  args: [DEFAULT_SHOP]
668
527
  }] }, { type: undefined, decorators: [{
669
528
  type: Inject,
670
529
  args: ['ProductRepository']
671
- }] }, { type: i3.Buy2WinFirestoreRepository, decorators: [{
672
- type: Inject,
673
- args: ['Buy2WinRepository']
674
530
  }] }]; } });
675
531
 
676
532
  class CheckoutSubscriptionService {
@@ -819,7 +675,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImpo
819
675
  }] }, { type: undefined, decorators: [{
820
676
  type: Inject,
821
677
  args: ['ProductRepository']
822
- }] }, { type: i3.Shops, decorators: [{
678
+ }] }, { type: i1$1.Shops, decorators: [{
823
679
  type: Inject,
824
680
  args: [DEFAULT_SHOP]
825
681
  }] }]; } });
@@ -839,11 +695,11 @@ class OrderService {
839
695
  return this.orderSubject;
840
696
  }
841
697
  }
842
- OrderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OrderService, deps: [{ token: i1$1.AngularFirestore }, { token: 'OrderRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
698
+ OrderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OrderService, deps: [{ token: i1$2.AngularFirestore }, { token: 'OrderRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
843
699
  OrderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OrderService });
844
700
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OrderService, decorators: [{
845
701
  type: Injectable
846
- }], ctorParameters: function () { return [{ type: i1$1.AngularFirestore }, { type: i3.OrderFirestoreRepository, decorators: [{
702
+ }], ctorParameters: function () { return [{ type: i1$2.AngularFirestore }, { type: i1$1.OrderFirestoreRepository, decorators: [{
847
703
  type: Inject,
848
704
  args: ['OrderRepository']
849
705
  }] }]; } });
@@ -857,12 +713,13 @@ class ShippingService {
857
713
  getShippingMethods(shop, zip, weightGrams, totalPrice, personId, subscriptionPlan) {
858
714
  return combineLatest([
859
715
  this.homeService.getHomeData(),
860
- this.http.get(`${this.apiUrl}open/checkshippingcompany?personId=${personId}&postalCode=${zip}&weightGrams=${weightGrams}`),
861
- ]).pipe(map(([datas, shippingMethodsResponse]) => {
716
+ this.http.get(`${this.apiUrl}open/checkshippingcompany?personId=${personId}&postalCode=${zip}&weightGrams=${weightGrams}`)
717
+ ])
718
+ .pipe(map(([datas, shippingMethodsResponse]) => {
862
719
  let shippingMethods = shippingMethodsResponse.result;
863
720
  if (!shippingMethods.length)
864
721
  return [];
865
- shippingMethods = shippingMethods.map((s) => {
722
+ shippingMethods = shippingMethods.map(s => {
866
723
  if (s.ShippingCompanyName == 'Same Day EG')
867
724
  s.ShippingCompanyName = 'Same Day';
868
725
  else
@@ -873,7 +730,7 @@ class ShippingService {
873
730
  shippingMethods = shippingMethods.filter((method) => method.ShippingCompanyName !== 'Same Day');
874
731
  }
875
732
  if (totalPrice >= 200) {
876
- shippingMethods = shippingMethods.map((s) => {
733
+ shippingMethods = shippingMethods.map(s => {
877
734
  if (s.serviceName !== 'Same Day')
878
735
  return Object.assign(Object.assign({}, s), { totalPrice: 0 });
879
736
  else
@@ -883,7 +740,7 @@ class ShippingService {
883
740
  if (shop == Shops.GLAMSHOP)
884
741
  return shippingMethods;
885
742
  if (this.isFreeShippingBySubscription(shop, subscriptionPlan)) {
886
- shippingMethods = shippingMethods.map((s) => {
743
+ shippingMethods = shippingMethods.map(s => {
887
744
  if (s.serviceName == 'Same Day')
888
745
  return Object.assign(Object.assign({}, s), { totalPrice: s.totalPrice / 2 });
889
746
  else
@@ -891,7 +748,7 @@ class ShippingService {
891
748
  });
892
749
  }
893
750
  if (this.isHalfShippingBySubscription(shop, subscriptionPlan)) {
894
- shippingMethods = shippingMethods.map((s) => {
751
+ shippingMethods = shippingMethods.map(s => {
895
752
  return Object.assign(Object.assign({}, s), { totalPrice: s.totalPrice / 2 });
896
753
  });
897
754
  }
@@ -927,11 +784,11 @@ class ShippingService {
927
784
  return false;
928
785
  }
929
786
  }
930
- ShippingService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: ShippingService, deps: [{ token: i1$2.HttpClient }, { token: BACKEND_URL }, { token: HomeShopService }], target: i0.ɵɵFactoryTarget.Injectable });
787
+ ShippingService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: ShippingService, deps: [{ token: i1$3.HttpClient }, { token: BACKEND_URL }, { token: HomeShopService }], target: i0.ɵɵFactoryTarget.Injectable });
931
788
  ShippingService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: ShippingService });
932
789
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: ShippingService, decorators: [{
933
790
  type: Injectable
934
- }], ctorParameters: function () { return [{ type: i1$2.HttpClient }, { type: undefined, decorators: [{
791
+ }], ctorParameters: function () { return [{ type: i1$3.HttpClient }, { type: undefined, decorators: [{
935
792
  type: Inject,
936
793
  args: [BACKEND_URL]
937
794
  }] }, { type: HomeShopService }]; } });
@@ -1191,6 +1048,13 @@ AngularFirestoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0",
1191
1048
  },
1192
1049
  deps: [AngularFirestore],
1193
1050
  },
1051
+ {
1052
+ provide: 'ShopSettingsRepository',
1053
+ useFactory: (firestore) => {
1054
+ return new ShopSettingsFirestoreRepository(firestore.firestore);
1055
+ },
1056
+ deps: [AngularFirestore],
1057
+ },
1194
1058
  {
1195
1059
  provide: 'SubscriptionPaymentRepository',
1196
1060
  useFactory: (firestore, subscriptionRepository) => {
@@ -1357,6 +1221,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImpo
1357
1221
  },
1358
1222
  deps: [AngularFirestore],
1359
1223
  },
1224
+ {
1225
+ provide: 'ShopSettingsRepository',
1226
+ useFactory: (firestore) => {
1227
+ return new ShopSettingsFirestoreRepository(firestore.firestore);
1228
+ },
1229
+ deps: [AngularFirestore],
1230
+ },
1360
1231
  {
1361
1232
  provide: 'SubscriptionPaymentRepository',
1362
1233
  useFactory: (firestore, subscriptionRepository) => {
@@ -1440,10 +1311,10 @@ AngularHasuraGraphQLModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.
1440
1311
  },
1441
1312
  {
1442
1313
  provide: CategoryHasuraGraphQLRepository,
1443
- useFactory: (options, productRepository, categoryFilterRepository) => {
1444
- return new CategoryHasuraGraphQLRepository(options.endpoint, options.credentials, productRepository, categoryFilterRepository);
1314
+ useFactory: (options, productRepository) => {
1315
+ return new CategoryHasuraGraphQLRepository(options.endpoint, options.credentials, productRepository);
1445
1316
  },
1446
- deps: [HASURA_OPTIONS, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
1317
+ deps: [HASURA_OPTIONS, ProductHasuraGraphQLRepository],
1447
1318
  },
1448
1319
  {
1449
1320
  provide: 'ProductRepository',
@@ -1467,39 +1338,6 @@ AngularHasuraGraphQLModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.
1467
1338
  },
1468
1339
  deps: [HASURA_OPTIONS],
1469
1340
  },
1470
- {
1471
- provide: 'CategoryFilterRepository',
1472
- useExisting: CategoryFilterHasuraGraphQLRepository,
1473
- },
1474
- {
1475
- provide: CategoryFilterHasuraGraphQLRepository,
1476
- useFactory: (options) => {
1477
- return new CategoryFilterHasuraGraphQLRepository(options.endpoint, options.credentials);
1478
- },
1479
- deps: [HASURA_OPTIONS],
1480
- },
1481
- {
1482
- provide: 'FilterOptionRepository',
1483
- useExisting: FilterOptionHasuraGraphQLRepository,
1484
- },
1485
- {
1486
- provide: FilterOptionHasuraGraphQLRepository,
1487
- useFactory: (options) => {
1488
- return new FilterOptionHasuraGraphQLRepository(options.endpoint, options.credentials);
1489
- },
1490
- deps: [HASURA_OPTIONS],
1491
- },
1492
- {
1493
- provide: 'FilterRepository',
1494
- useExisting: FilterHasuraGraphQLRepository,
1495
- },
1496
- {
1497
- provide: FilterHasuraGraphQLRepository,
1498
- useFactory: (options, filterOptionRepository, categoryFilterRepository) => {
1499
- return new FilterHasuraGraphQLRepository(options.endpoint, options.credentials, filterOptionRepository, categoryFilterRepository);
1500
- },
1501
- deps: [HASURA_OPTIONS, FilterOptionHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
1502
- },
1503
1341
  ] });
1504
1342
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularHasuraGraphQLModule, decorators: [{
1505
1343
  type: NgModule,
@@ -1511,10 +1349,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImpo
1511
1349
  },
1512
1350
  {
1513
1351
  provide: CategoryHasuraGraphQLRepository,
1514
- useFactory: (options, productRepository, categoryFilterRepository) => {
1515
- return new CategoryHasuraGraphQLRepository(options.endpoint, options.credentials, productRepository, categoryFilterRepository);
1352
+ useFactory: (options, productRepository) => {
1353
+ return new CategoryHasuraGraphQLRepository(options.endpoint, options.credentials, productRepository);
1516
1354
  },
1517
- deps: [HASURA_OPTIONS, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
1355
+ deps: [HASURA_OPTIONS, ProductHasuraGraphQLRepository],
1518
1356
  },
1519
1357
  {
1520
1358
  provide: 'ProductRepository',
@@ -1538,39 +1376,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImpo
1538
1376
  },
1539
1377
  deps: [HASURA_OPTIONS],
1540
1378
  },
1541
- {
1542
- provide: 'CategoryFilterRepository',
1543
- useExisting: CategoryFilterHasuraGraphQLRepository,
1544
- },
1545
- {
1546
- provide: CategoryFilterHasuraGraphQLRepository,
1547
- useFactory: (options) => {
1548
- return new CategoryFilterHasuraGraphQLRepository(options.endpoint, options.credentials);
1549
- },
1550
- deps: [HASURA_OPTIONS],
1551
- },
1552
- {
1553
- provide: 'FilterOptionRepository',
1554
- useExisting: FilterOptionHasuraGraphQLRepository,
1555
- },
1556
- {
1557
- provide: FilterOptionHasuraGraphQLRepository,
1558
- useFactory: (options) => {
1559
- return new FilterOptionHasuraGraphQLRepository(options.endpoint, options.credentials);
1560
- },
1561
- deps: [HASURA_OPTIONS],
1562
- },
1563
- {
1564
- provide: 'FilterRepository',
1565
- useExisting: FilterHasuraGraphQLRepository,
1566
- },
1567
- {
1568
- provide: FilterHasuraGraphQLRepository,
1569
- useFactory: (options, filterOptionRepository, categoryFilterRepository) => {
1570
- return new FilterHasuraGraphQLRepository(options.endpoint, options.credentials, filterOptionRepository, categoryFilterRepository);
1571
- },
1572
- deps: [HASURA_OPTIONS, FilterOptionHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
1573
- },
1574
1379
  ],
1575
1380
  }]
1576
1381
  }] });
@@ -1600,7 +1405,7 @@ AngularConnectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", ve
1600
1405
  CouponService,
1601
1406
  HomeShopService,
1602
1407
  OrderService,
1603
- ShippingService,
1408
+ ShippingService
1604
1409
  ], imports: [[AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule]] });
1605
1410
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, decorators: [{
1606
1411
  type: NgModule,
@@ -1614,7 +1419,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImpo
1614
1419
  CouponService,
1615
1420
  HomeShopService,
1616
1421
  OrderService,
1617
- ShippingService,
1422
+ ShippingService
1618
1423
  ],
1619
1424
  }]
1620
1425
  }] });