@infrab4a/connect-angular 4.0.0-beta.11 → 4.0.0-beta.13

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,14 +5,14 @@ import { getIdToken, authState, Auth, provideAuth, getAuth } from '@angular/fire
5
5
  import { combineLatest, of, from, throwError, Subject, iif, forkJoin } from 'rxjs';
6
6
  import { map, mergeMap, catchError, concatMap, tap } from 'rxjs/operators';
7
7
  import { __awaiter } from 'tslib';
8
- import * as i1$1 from '@infrab4a/connect';
9
- import { 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, SubscriptionPaymentFirestoreRepository, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionFirestoreRepository, UserFirestoreRepository, UserAddressFirestoreRepository, UserPaymentMethodFirestoreRepository, ProductVariantFirestoreRepository, CategoryHasuraGraphQLRepository, ProductHasuraGraphQLRepository, VariantHasuraGraphQLRepository } from '@infrab4a/connect';
8
+ import * as i3 from '@infrab4a/connect';
9
+ import { 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, CampaignHashtagFirestoreRepository, CampaignDashboardFirestoreRepository, SubscriptionEditionFirestoreRepository, HomeFirestoreRepository, LeadFirestoreRepository, LegacyOrderFirestoreRepository, ShopMenuFirestoreRepository, OrderFirestoreRepository, PaymentFirestoreRepository, ProductFirestoreRepository, ShopSettingsFirestoreRepository, SubscriptionPaymentFirestoreRepository, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionFirestoreRepository, UserFirestoreRepository, UserAddressFirestoreRepository, UserPaymentMethodFirestoreRepository, ProductVariantFirestoreRepository, CategoryHasuraGraphQLRepository, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository, VariantHasuraGraphQLRepository, FilterOptionHasuraGraphQLRepository, FilterHasuraGraphQLRepository } from '@infrab4a/connect';
10
10
  import cookie from 'js-cookie';
11
11
  import { CustomError } from 'ts-custom-error';
12
- import * as i1$2 from '@angular/fire/firestore';
13
- import { docSnapshots, doc, Firestore, provideFirestore, getFirestore } from '@angular/fire/firestore';
14
- import * as i1$3 from '@angular/common/http';
15
- import * as i1$4 from '@angular/fire/app';
12
+ import * as i1$1 from '@angular/fire/firestore';
13
+ import { docSnapshots, doc, Firestore } from '@angular/fire/firestore';
14
+ import * as i1$2 from '@angular/common/http';
15
+ import * as i1$3 from '@angular/fire/app';
16
16
  import { provideFirebaseApp, initializeApp } from '@angular/fire/app';
17
17
  import { isPlatformBrowser } from '@angular/common';
18
18
 
@@ -74,11 +74,10 @@ class GroupInvalidCouponError extends CustomError {
74
74
  }
75
75
 
76
76
  class CouponService {
77
- constructor(couponRepository, defaultShop, orderRepository, subscriptionRepository, categoryRepository) {
77
+ constructor(couponRepository, defaultShop, orderRepository, categoryRepository) {
78
78
  this.couponRepository = couponRepository;
79
79
  this.defaultShop = defaultShop;
80
80
  this.orderRepository = orderRepository;
81
- this.subscriptionRepository = subscriptionRepository;
82
81
  this.categoryRepository = categoryRepository;
83
82
  this.emailIsFromCollaborator = (userEmail) => !!(userEmail === null || userEmail === void 0 ? void 0 : userEmail.match(/@b4a.com.br/g));
84
83
  }
@@ -119,7 +118,7 @@ class CouponService {
119
118
  const hasMinSubTotal = this.hasMinSubTotal(coupon, checkout);
120
119
  // Se não tem valor mínimo atingido, retorna erro
121
120
  if (!hasMinSubTotal)
122
- return throwError('Valor mínimo não atingido');
121
+ return throwError(`Valor mínimo de ${Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' }).format(coupon.minSubTotalValue)} não atingido`);
123
122
  return of(coupon);
124
123
  }
125
124
  isValidCoupon(coupon, userEmail) {
@@ -147,7 +146,7 @@ class CouponService {
147
146
  // Verifica o limite de uso geral por usuario
148
147
  if (coupon.useLimit && orders.data.length >= coupon.useLimit)
149
148
  throw new InvalidCouponError('Limite de uso atingido.');
150
- const validUser = yield this.userValidationAndSubscriptionStatus(coupon, userEmail);
149
+ const validUser = this.userValidationAndSubscriptionStatus(coupon, checkout === null || checkout === void 0 ? void 0 : checkout.user);
151
150
  if (!validUser)
152
151
  throw new InvalidCouponError('Usuário não elegível.');
153
152
  const hasProductCategories = yield this.hasProductCategories(coupon, checkout);
@@ -241,41 +240,26 @@ class CouponService {
241
240
  return hasCategories.length ? true : false;
242
241
  });
243
242
  }
244
- userValidationAndSubscriptionStatus(coupon, userEmail) {
245
- return __awaiter(this, void 0, void 0, function* () {
246
- // Verifica se o email do usuário é coorporativo
247
- if (!this.emailIsFromCollaborator(userEmail) && coupon.exclusivityType === Exclusivities.COLLABORATORS)
248
- throw new InvalidCouponError('Você não é colaborador.');
249
- // Verifica se o email do usuário é associado ao cupom de uso por usuario
250
- if (coupon.exclusivityType === Exclusivities.SPECIFIC_USER && coupon.userExclusiveEmail !== userEmail)
251
- throw new InvalidCouponError('Cupom não é válido para este usuário.');
252
- const couponRuleSubscription = coupon.exclusivityType === Exclusivities.ACTIVE_SUBSCRIBER ||
253
- coupon.exclusivityType === Exclusivities.INACTIVE_SUBSCRIBER ||
254
- coupon.exclusivityType === Exclusivities.NON_SUBSCRIBER;
255
- if (couponRuleSubscription && userEmail) {
256
- const sub = yield this.subscriptionRepository
257
- .find({
258
- filters: {
259
- user: {
260
- email: { operator: Where.EQUALS, value: userEmail },
261
- },
262
- },
263
- })
264
- .then((sub) => sub.data);
265
- const activeSubs = sub === null || sub === void 0 ? void 0 : sub.filter((s) => s.status === Status.ACTIVE);
266
- switch (coupon.exclusivityType) {
267
- case Exclusivities.ACTIVE_SUBSCRIBER:
268
- return activeSubs.length > 0;
269
- case Exclusivities.INACTIVE_SUBSCRIBER:
270
- return activeSubs.length === 0;
271
- case Exclusivities.NON_SUBSCRIBER:
272
- return sub.length === 0;
273
- default:
274
- return false;
275
- }
276
- }
243
+ userValidationAndSubscriptionStatus(coupon, user) {
244
+ if (coupon.exclusivityType === Exclusivities.ALL_USERS)
277
245
  return true;
278
- });
246
+ if (!user)
247
+ return true;
248
+ // Verifica se o email do usuário é coorporativo
249
+ if (!this.emailIsFromCollaborator(user.email) && coupon.exclusivityType === Exclusivities.COLLABORATORS)
250
+ throw new InvalidCouponError('Você não é colaborador.');
251
+ // Verifica se o email do usuário é associado ao cupom de uso por usuario
252
+ if (coupon.exclusivityType === Exclusivities.SPECIFIC_USER && coupon.userExclusiveEmail !== user.email)
253
+ throw new InvalidCouponError('Cupom não é válido para este usuário.');
254
+ switch (coupon.exclusivityType) {
255
+ case Exclusivities.ACTIVE_SUBSCRIBER:
256
+ return user.isSubscriber ? true : false;
257
+ case Exclusivities.INACTIVE_SUBSCRIBER:
258
+ return user.isSubscriber ? false : true;
259
+ case Exclusivities.NON_SUBSCRIBER:
260
+ return user.isSubscriber ? false : true;
261
+ }
262
+ return true;
279
263
  }
280
264
  getCouponCategoriesId(coupon) {
281
265
  return __awaiter(this, void 0, void 0, function* () {
@@ -290,7 +274,7 @@ class CouponService {
290
274
  });
291
275
  }
292
276
  }
293
- CouponService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CouponService, deps: [{ token: 'CouponRepository' }, { token: DEFAULT_SHOP }, { token: 'OrderRepository' }, { token: 'SubscriptionRepository' }, { token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
277
+ CouponService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CouponService, deps: [{ token: 'CouponRepository' }, { token: DEFAULT_SHOP }, { token: 'OrderRepository' }, { token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
294
278
  CouponService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CouponService, providedIn: 'root' });
295
279
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CouponService, decorators: [{
296
280
  type: Injectable,
@@ -301,15 +285,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
301
285
  return [{ type: undefined, decorators: [{
302
286
  type: Inject,
303
287
  args: ['CouponRepository']
304
- }] }, { type: i1$1.Shops, decorators: [{
288
+ }] }, { type: i3.Shops, decorators: [{
305
289
  type: Inject,
306
290
  args: [DEFAULT_SHOP]
307
291
  }] }, { type: undefined, decorators: [{
308
292
  type: Inject,
309
293
  args: ['OrderRepository']
310
- }] }, { type: undefined, decorators: [{
311
- type: Inject,
312
- args: ['SubscriptionRepository']
313
294
  }] }, { type: undefined, decorators: [{
314
295
  type: Inject,
315
296
  args: ['CategoryRepository']
@@ -376,23 +357,25 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
376
357
  }] }, { type: undefined, decorators: [{
377
358
  type: Inject,
378
359
  args: ['UserRepository']
379
- }] }, { type: i1$1.Shops, decorators: [{
360
+ }] }, { type: i3.Shops, decorators: [{
380
361
  type: Inject,
381
362
  args: [DEFAULT_SHOP]
382
363
  }] }];
383
364
  } });
384
365
 
385
366
  class CartService {
386
- constructor(authService, checkoutService, defaultShop, productRepository) {
367
+ constructor(authService, checkoutService, defaultShop, productRepository, variantRepository, buy2WinRepository) {
387
368
  this.authService = authService;
388
369
  this.checkoutService = checkoutService;
389
370
  this.defaultShop = defaultShop;
390
371
  this.productRepository = productRepository;
372
+ this.variantRepository = variantRepository;
373
+ this.buy2WinRepository = buy2WinRepository;
391
374
  this.cartSubject = new Subject();
392
375
  this.updateLineItemInCart = (lineItem, quantity, checkout) => (isNil(checkout) ? this.checkoutService.getCheckout() : of(checkout)).pipe(concatMap((checkoutLoaded) => {
393
376
  var _a;
394
377
  const items = [];
395
- const index = (_a = checkoutLoaded.lineItems) === null || _a === void 0 ? void 0 : _a.map((checkoutItem) => checkoutItem.sku).indexOf(lineItem.sku);
378
+ const index = (_a = checkoutLoaded.lineItems) === null || _a === void 0 ? void 0 : _a.map((checkoutItem) => checkoutItem.id).indexOf(lineItem.id);
396
379
  if (index > -1) {
397
380
  checkoutLoaded.lineItems[index].quantity += quantity;
398
381
  checkoutLoaded.lineItems[index].pricePaid = lineItem.pricePaid;
@@ -403,22 +386,18 @@ class CartService {
403
386
  .updateCheckoutLineItems(checkoutLoaded)
404
387
  .pipe(map((updatedCheckout) => this.generateCartObject(updatedCheckout.lineItems)));
405
388
  }));
406
- this.generateCartObject = (items) => {
407
- const cart = {};
408
- items === null || items === void 0 ? void 0 : items.forEach((item) => {
409
- var _a;
410
- return (cart[item.sku] = LineItem.toInstance(Object.assign(Object.assign({}, (cart[item.sku] || item)), { quantity: (((_a = cart[item.sku]) === null || _a === void 0 ? void 0 : _a.quantity) || 0) + (item.quantity ? item.quantity : 1) })));
411
- });
412
- return cart;
413
- };
389
+ this.generateCartObject = (items) => items.reduce((cart, item) => {
390
+ var _a;
391
+ return (Object.assign(Object.assign({}, cart), { [item.id]: 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) })) }));
392
+ }, {});
414
393
  this.buildLineItem = ({ checkout, item, quantity, }) => __awaiter(this, void 0, void 0, function* () {
415
394
  var _a, _b, _c, _d, _e, _f, _g;
416
- const product = yield this.productRepository.get({ id: item.id });
417
- item.quantity = (item === null || item === void 0 ? void 0 : item.quantity) || ((_b = (_a = checkout === null || checkout === void 0 ? void 0 : checkout.lineItems) === null || _a === void 0 ? void 0 : _a.find((lineItem) => lineItem.sku === item.sku)) === null || _b === void 0 ? void 0 : _b.quantity) || 0;
395
+ const product = yield this.getProductData(item.id);
396
+ item.quantity = (item === null || item === void 0 ? void 0 : item.quantity) || ((_b = (_a = checkout === null || checkout === void 0 ? void 0 : checkout.lineItems) === null || _a === void 0 ? void 0 : _a.find((lineItem) => lineItem.id === item.id)) === null || _b === void 0 ? void 0 : _b.quantity) || 0;
418
397
  if (this.checkMaxStock(item, quantity || 0))
419
398
  throw new Error('Desculpe! Temos apenas ' + ((_c = item.stock) === null || _c === void 0 ? void 0 : _c.quantity) + ' em estoque.');
420
399
  const image = item.image || ((_d = item.images) === null || _d === void 0 ? void 0 : _d.shift());
421
- const { id, name, EAN, brand, slug, stock, price, weight, categories, sku, type } = item;
400
+ const { id, name, EAN, slug, stock, price, weight, sku, type } = item;
422
401
  const isGift = item.isGift || null;
423
402
  const pricePaid = this.getProductPrice({
424
403
  product: item,
@@ -466,7 +445,7 @@ class CartService {
466
445
  decreaseItem(item) {
467
446
  return this.checkoutService.getCheckout().pipe(map((checkout) => {
468
447
  var _a;
469
- const checkoutItem = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.find((lineItem) => lineItem.sku === item.sku);
448
+ const checkoutItem = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.find((lineItem) => lineItem.id === item.id);
470
449
  if (!isNil(checkoutItem))
471
450
  checkoutItem.quantity -= checkoutItem.quantity > 1 ? 1 : 0;
472
451
  return checkout;
@@ -484,7 +463,7 @@ class CartService {
484
463
  }
485
464
  removeItem(item) {
486
465
  return this.checkoutService.getCheckout().pipe(map((checkout) => {
487
- const index = checkout.lineItems.findIndex((lineItem) => lineItem.sku === item.sku);
466
+ const index = checkout.lineItems.findIndex((lineItem) => lineItem.id === item.id);
488
467
  if (index >= 0)
489
468
  checkout.lineItems.splice(index, 1);
490
469
  return checkout;
@@ -493,8 +472,12 @@ class CartService {
493
472
  updateUserCart(user) {
494
473
  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* () {
495
474
  var _a, _b;
496
- 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();
497
- })), map(checkout => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
475
+ return this.checkoutService
476
+ .updateCheckoutLineItems(Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { lineItems: ((_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.length)
477
+ ? 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; })))
478
+ : [] })))
479
+ .toPromise();
480
+ })), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
498
481
  }
499
482
  clearCart() {
500
483
  return this.checkoutService.getCheckout().pipe(map((checkout) => {
@@ -505,18 +488,122 @@ class CartService {
505
488
  buildCartFromCheckout(checkoutData) {
506
489
  return this.checkoutService.getCheckout(checkoutData).pipe(map((checkout) => checkout.lineItems), concatMap((lineItems) => of(this.generateCartObject(lineItems))));
507
490
  }
491
+ getProductData(productId) {
492
+ return __awaiter(this, void 0, void 0, function* () {
493
+ let product;
494
+ let variant;
495
+ try {
496
+ product = yield this.productRepository.get({ id: productId });
497
+ }
498
+ catch (error) {
499
+ if (!(error instanceof NotFoundError))
500
+ throw error;
501
+ variant = yield this.variantRepository.get({ id: productId });
502
+ product = yield this.productRepository.get({ id: variant.productId });
503
+ }
504
+ return Object.assign(Object.assign({}, product.toPlain()), (variant && Object.assign({}, variant.toPlain())));
505
+ });
506
+ }
507
+ getGifts() {
508
+ return this.checkoutService.getCheckout().pipe(mergeMap((checkout) => __awaiter(this, void 0, void 0, function* () {
509
+ const campaigns = yield this.buy2WinRepository
510
+ .find({
511
+ filters: {
512
+ active: { operator: Where.EQUALS, value: true },
513
+ shop: { operator: Where.EQUALS, value: this.defaultShop },
514
+ },
515
+ })
516
+ .then((data) => data.data);
517
+ const notGiftItems = checkout.lineItems.filter((item) => !item.isGift);
518
+ if (!campaigns.length)
519
+ return Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems });
520
+ const cartTotal = notGiftItems.reduce((a, b) => a + b.pricePaid * b.quantity, 0);
521
+ const elegibleCampaigns = [];
522
+ for (const campaign of campaigns) {
523
+ const today = new Date();
524
+ if (!(campaign.startDate <= today) && !(campaign.endDate >= today))
525
+ continue;
526
+ if (campaign.activeCategory) {
527
+ const categoriesCampaing = campaign.categories.map((c) => c.id);
528
+ const filterProductsCategories = checkout.lineItems.filter((l) => {
529
+ var _a;
530
+ if (!l.categories || !((_a = l.categories) === null || _a === void 0 ? void 0 : _a.length))
531
+ return true;
532
+ return l.categories.some((c) => categoriesCampaing.some((cat) => cat == c));
533
+ });
534
+ if (filterProductsCategories.length) {
535
+ const cartTotalCategories = filterProductsCategories.reduce((a, b) => a + b.pricePaid * b.quantity, 0);
536
+ if (cartTotalCategories >= campaign.cartValueMin)
537
+ elegibleCampaigns.push(campaign);
538
+ }
539
+ }
540
+ else {
541
+ if (campaign.cartValue && campaign.cartValue > 0) {
542
+ if (campaign.cartValue <= cartTotal)
543
+ elegibleCampaigns.push(campaign);
544
+ }
545
+ }
546
+ }
547
+ if (!elegibleCampaigns.length)
548
+ return Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems });
549
+ const campaingnProducts = [];
550
+ for (const campaign of elegibleCampaigns) {
551
+ let elegibleProducts = [];
552
+ for (const product of campaign.products) {
553
+ const productData = yield this.productRepository.get({ sku: product });
554
+ if (!productData)
555
+ continue;
556
+ elegibleProducts.push(productData);
557
+ }
558
+ campaingnProducts.push(elegibleProducts);
559
+ }
560
+ if (!campaingnProducts.length)
561
+ return Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems });
562
+ const gifts = this.giftToLineItems([].concat(...campaingnProducts));
563
+ return Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems.concat(gifts) });
564
+ })), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
565
+ }
566
+ giftToLineItems(items) {
567
+ return items.map((item) => {
568
+ var _a;
569
+ const { brand, categories, id, name, price, sku, slug, stock, weight, EAN } = item;
570
+ 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];
571
+ return LineItem.toInstance({
572
+ brand,
573
+ categories,
574
+ id: id.toString(),
575
+ name,
576
+ price,
577
+ sku,
578
+ slug,
579
+ stock,
580
+ weight,
581
+ EAN,
582
+ image,
583
+ pricePaid: 0,
584
+ quantity: 1,
585
+ isGift: true,
586
+ });
587
+ });
588
+ }
508
589
  }
509
- CartService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService, deps: [{ token: AuthService }, { token: CheckoutService }, { token: DEFAULT_SHOP }, { token: 'ProductRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
590
+ CartService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService, deps: [{ token: AuthService }, { token: CheckoutService }, { token: DEFAULT_SHOP }, { token: 'ProductRepository' }, { token: 'VariantRepository' }, { token: 'Buy2WinRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
510
591
  CartService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService });
511
592
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService, decorators: [{
512
593
  type: Injectable
513
594
  }], ctorParameters: function () {
514
- return [{ type: AuthService }, { type: CheckoutService }, { type: i1$1.Shops, decorators: [{
595
+ return [{ type: AuthService }, { type: CheckoutService }, { type: i3.Shops, decorators: [{
515
596
  type: Inject,
516
597
  args: [DEFAULT_SHOP]
517
598
  }] }, { type: undefined, decorators: [{
518
599
  type: Inject,
519
600
  args: ['ProductRepository']
601
+ }] }, { type: undefined, decorators: [{
602
+ type: Inject,
603
+ args: ['VariantRepository']
604
+ }] }, { type: i3.Buy2WinFirestoreRepository, decorators: [{
605
+ type: Inject,
606
+ args: ['Buy2WinRepository']
520
607
  }] }];
521
608
  } });
522
609
 
@@ -544,7 +631,9 @@ class CheckoutSubscriptionService {
544
631
  return of();
545
632
  }
546
633
  checkCoupon(nickname, userEmail) {
547
- return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService.checkCoupon(nickname, userEmail, CheckoutTypes.SUBSCRIPTION, checkout.subscriptionPlan.name, null, true).pipe()));
634
+ return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService
635
+ .checkCoupon(nickname, userEmail, CheckoutTypes.SUBSCRIPTION, checkout.subscriptionPlan.name, checkout, true)
636
+ .pipe()));
548
637
  }
549
638
  calcDiscountSubscription(coupon) {
550
639
  return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService.calcDiscountSubscription(coupon, checkout).pipe()));
@@ -670,7 +759,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
670
759
  }] }, { type: undefined, decorators: [{
671
760
  type: Inject,
672
761
  args: ['ProductRepository']
673
- }] }, { type: i1$1.Shops, decorators: [{
762
+ }] }, { type: i3.Shops, decorators: [{
674
763
  type: Inject,
675
764
  args: [DEFAULT_SHOP]
676
765
  }] }];
@@ -689,12 +778,12 @@ class OrderService {
689
778
  return this.orderSubject;
690
779
  }
691
780
  }
692
- OrderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OrderService, deps: [{ token: i1$2.Firestore }, { token: 'OrderRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
781
+ OrderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OrderService, deps: [{ token: i1$1.Firestore }, { token: 'OrderRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
693
782
  OrderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OrderService });
694
783
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OrderService, decorators: [{
695
784
  type: Injectable
696
785
  }], ctorParameters: function () {
697
- return [{ type: i1$2.Firestore }, { type: i1$1.OrderFirestoreRepository, decorators: [{
786
+ return [{ type: i1$1.Firestore }, { type: i3.OrderFirestoreRepository, decorators: [{
698
787
  type: Inject,
699
788
  args: ['OrderRepository']
700
789
  }] }];
@@ -721,7 +810,7 @@ class ShippingService {
721
810
  });
722
811
  const datasSameDayNotAvaliable = datas.sameDayNotAvaliable;
723
812
  if (this.isHolidays(datasSameDayNotAvaliable)) {
724
- shippingMethods = shippingMethods.filter((method) => method.ShippingCompanyName !== 'Same Day');
813
+ shippingMethods = shippingMethods.filter((method) => method.serviceName !== 'Same Day');
725
814
  }
726
815
  if (totalPrice >= 200) {
727
816
  shippingMethods = shippingMethods.map((s) => {
@@ -752,9 +841,8 @@ class ShippingService {
752
841
  isFreeShippingBySubscription(shop, subscriptionPlan) {
753
842
  if (!subscriptionPlan)
754
843
  return false;
755
- if (shop == Shops.MENSMARKET && subscriptionPlan == 'SELECT') {
844
+ if (shop == Shops.MENSMARKET && subscriptionPlan == 'SELECT')
756
845
  return true;
757
- }
758
846
  return false;
759
847
  }
760
848
  isHalfShippingBySubscription(shop, subscriptionPlan) {
@@ -778,12 +866,12 @@ class ShippingService {
778
866
  return false;
779
867
  }
780
868
  }
781
- ShippingService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ShippingService, deps: [{ token: i1$3.HttpClient }, { token: BACKEND_URL }, { token: HomeShopService }], target: i0.ɵɵFactoryTarget.Injectable });
869
+ ShippingService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ShippingService, deps: [{ token: i1$2.HttpClient }, { token: BACKEND_URL }, { token: HomeShopService }], target: i0.ɵɵFactoryTarget.Injectable });
782
870
  ShippingService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ShippingService });
783
871
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ShippingService, decorators: [{
784
872
  type: Injectable
785
873
  }], ctorParameters: function () {
786
- return [{ type: i1$3.HttpClient }, { type: undefined, decorators: [{
874
+ return [{ type: i1$2.HttpClient }, { type: undefined, decorators: [{
787
875
  type: Inject,
788
876
  args: [BACKEND_URL]
789
877
  }] }, { type: HomeShopService }];
@@ -801,7 +889,7 @@ class AngularFirebaseAuthModule {
801
889
  }
802
890
  }
803
891
  AngularFirebaseAuthModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirebaseAuthModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
804
- AngularFirebaseAuthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularFirebaseAuthModule, imports: [i1$4.FirebaseAppModule, i1.AuthModule] });
892
+ AngularFirebaseAuthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularFirebaseAuthModule, imports: [i1$3.FirebaseAppModule, i1.AuthModule] });
805
893
  AngularFirebaseAuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirebaseAuthModule, providers: [
806
894
  {
807
895
  provide: 'Authentication',
@@ -958,7 +1046,7 @@ class AngularFirestoreModule {
958
1046
  }
959
1047
  }
960
1048
  AngularFirestoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirestoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
961
- AngularFirestoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularFirestoreModule, imports: [AngularElasticSeachModule, i1$4.FirebaseAppModule, i1$2.FirestoreModule] });
1049
+ AngularFirestoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularFirestoreModule, imports: [AngularElasticSeachModule, i1$3.FirebaseAppModule] });
962
1050
  AngularFirestoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirestoreModule, providers: [
963
1051
  {
964
1052
  provide: 'FirestoreOptions',
@@ -1024,12 +1112,26 @@ AngularFirestoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0",
1024
1112
  },
1025
1113
  deps: ['FirestoreOptions'],
1026
1114
  },
1115
+ {
1116
+ provide: 'CampaignHashtagRepository',
1117
+ useFactory: (options) => {
1118
+ return new CampaignHashtagFirestoreRepository(options);
1119
+ },
1120
+ deps: ['FirestoreOptions'],
1121
+ },
1122
+ {
1123
+ provide: 'CampaignDashboardRepository',
1124
+ useFactory: (options) => {
1125
+ return new CampaignDashboardFirestoreRepository(options);
1126
+ },
1127
+ deps: ['FirestoreOptions'],
1128
+ },
1027
1129
  {
1028
1130
  provide: 'EditionRepository',
1029
1131
  useFactory: (options, subscriptionRepository) => {
1030
1132
  return new SubscriptionEditionFirestoreRepository(options, subscriptionRepository);
1031
1133
  },
1032
- deps: [Firestore, 'SubscriptionRepository'],
1134
+ deps: ['FirestoreOptions', 'SubscriptionRepository'],
1033
1135
  },
1034
1136
  {
1035
1137
  provide: 'HomeRepository',
@@ -1080,12 +1182,19 @@ AngularFirestoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0",
1080
1182
  },
1081
1183
  deps: ['FirestoreOptions'],
1082
1184
  },
1185
+ {
1186
+ provide: 'ShopSettingsRepository',
1187
+ useFactory: (options) => {
1188
+ return new ShopSettingsFirestoreRepository(options);
1189
+ },
1190
+ deps: ['FirestoreOptions'],
1191
+ },
1083
1192
  {
1084
1193
  provide: 'SubscriptionPaymentRepository',
1085
1194
  useFactory: (options, subscriptionRepository) => {
1086
1195
  return new SubscriptionPaymentFirestoreRepository(options, subscriptionRepository);
1087
1196
  },
1088
- deps: [Firestore, 'SubscriptionRepository'],
1197
+ deps: ['FirestoreOptions', 'SubscriptionRepository'],
1089
1198
  },
1090
1199
  {
1091
1200
  provide: 'SubscriptionPlanRepository',
@@ -1120,21 +1229,21 @@ AngularFirestoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0",
1120
1229
  useFactory: (options, userRepository) => {
1121
1230
  return new UserAddressFirestoreRepository(options, userRepository);
1122
1231
  },
1123
- deps: [Firestore, 'UserRepository'],
1232
+ deps: ['FirestoreOptions', 'UserRepository'],
1124
1233
  },
1125
1234
  {
1126
1235
  provide: 'UserPaymentMethodRepository',
1127
1236
  useFactory: (options, userRepository) => {
1128
1237
  return new UserPaymentMethodFirestoreRepository(options, userRepository);
1129
1238
  },
1130
- deps: [Firestore, 'UserRepository'],
1239
+ deps: ['FirestoreOptions', 'UserRepository'],
1131
1240
  },
1132
1241
  {
1133
1242
  provide: ProductVariantFirestoreRepository,
1134
1243
  useFactory: (options, productRepository) => {
1135
1244
  return new ProductVariantFirestoreRepository(options, productRepository);
1136
1245
  },
1137
- deps: [Firestore, ProductFirestoreRepository],
1246
+ deps: ['FirestoreOptions', ProductFirestoreRepository],
1138
1247
  },
1139
1248
  ], imports: [AngularElasticSeachModule,
1140
1249
  provideFirebaseApp((injector) => {
@@ -1142,8 +1251,7 @@ AngularFirestoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0",
1142
1251
  return appName
1143
1252
  ? initializeApp(injector.get(FIREBASE_OPTIONS), appName)
1144
1253
  : initializeApp(injector.get(FIREBASE_OPTIONS));
1145
- }),
1146
- provideFirestore(() => getFirestore())] });
1254
+ })] });
1147
1255
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirestoreModule, decorators: [{
1148
1256
  type: NgModule,
1149
1257
  args: [{
@@ -1155,7 +1263,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
1155
1263
  ? initializeApp(injector.get(FIREBASE_OPTIONS), appName)
1156
1264
  : initializeApp(injector.get(FIREBASE_OPTIONS));
1157
1265
  }),
1158
- provideFirestore(() => getFirestore()),
1266
+ //provideFirestore(() => getFirestore()),
1159
1267
  ],
1160
1268
  providers: [
1161
1269
  {
@@ -1222,12 +1330,26 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
1222
1330
  },
1223
1331
  deps: ['FirestoreOptions'],
1224
1332
  },
1333
+ {
1334
+ provide: 'CampaignHashtagRepository',
1335
+ useFactory: (options) => {
1336
+ return new CampaignHashtagFirestoreRepository(options);
1337
+ },
1338
+ deps: ['FirestoreOptions'],
1339
+ },
1340
+ {
1341
+ provide: 'CampaignDashboardRepository',
1342
+ useFactory: (options) => {
1343
+ return new CampaignDashboardFirestoreRepository(options);
1344
+ },
1345
+ deps: ['FirestoreOptions'],
1346
+ },
1225
1347
  {
1226
1348
  provide: 'EditionRepository',
1227
1349
  useFactory: (options, subscriptionRepository) => {
1228
1350
  return new SubscriptionEditionFirestoreRepository(options, subscriptionRepository);
1229
1351
  },
1230
- deps: [Firestore, 'SubscriptionRepository'],
1352
+ deps: ['FirestoreOptions', 'SubscriptionRepository'],
1231
1353
  },
1232
1354
  {
1233
1355
  provide: 'HomeRepository',
@@ -1278,12 +1400,19 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
1278
1400
  },
1279
1401
  deps: ['FirestoreOptions'],
1280
1402
  },
1403
+ {
1404
+ provide: 'ShopSettingsRepository',
1405
+ useFactory: (options) => {
1406
+ return new ShopSettingsFirestoreRepository(options);
1407
+ },
1408
+ deps: ['FirestoreOptions'],
1409
+ },
1281
1410
  {
1282
1411
  provide: 'SubscriptionPaymentRepository',
1283
1412
  useFactory: (options, subscriptionRepository) => {
1284
1413
  return new SubscriptionPaymentFirestoreRepository(options, subscriptionRepository);
1285
1414
  },
1286
- deps: [Firestore, 'SubscriptionRepository'],
1415
+ deps: ['FirestoreOptions', 'SubscriptionRepository'],
1287
1416
  },
1288
1417
  {
1289
1418
  provide: 'SubscriptionPlanRepository',
@@ -1318,21 +1447,21 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
1318
1447
  useFactory: (options, userRepository) => {
1319
1448
  return new UserAddressFirestoreRepository(options, userRepository);
1320
1449
  },
1321
- deps: [Firestore, 'UserRepository'],
1450
+ deps: ['FirestoreOptions', 'UserRepository'],
1322
1451
  },
1323
1452
  {
1324
1453
  provide: 'UserPaymentMethodRepository',
1325
1454
  useFactory: (options, userRepository) => {
1326
1455
  return new UserPaymentMethodFirestoreRepository(options, userRepository);
1327
1456
  },
1328
- deps: [Firestore, 'UserRepository'],
1457
+ deps: ['FirestoreOptions', 'UserRepository'],
1329
1458
  },
1330
1459
  {
1331
1460
  provide: ProductVariantFirestoreRepository,
1332
1461
  useFactory: (options, productRepository) => {
1333
1462
  return new ProductVariantFirestoreRepository(options, productRepository);
1334
1463
  },
1335
- deps: [Firestore, ProductFirestoreRepository],
1464
+ deps: ['FirestoreOptions', ProductFirestoreRepository],
1336
1465
  },
1337
1466
  ],
1338
1467
  }]
@@ -1378,10 +1507,10 @@ AngularHasuraGraphQLModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.
1378
1507
  },
1379
1508
  {
1380
1509
  provide: CategoryHasuraGraphQLRepository,
1381
- useFactory: (hasuraConfig, productRepository) => {
1382
- return new CategoryHasuraGraphQLRepository(hasuraConfig, productRepository);
1510
+ useFactory: (options, productRepository, categoryFilterRepository) => {
1511
+ return new CategoryHasuraGraphQLRepository(options, productRepository, categoryFilterRepository);
1383
1512
  },
1384
- deps: ['HasuraConfig', ProductHasuraGraphQLRepository],
1513
+ deps: [HASURA_OPTIONS, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
1385
1514
  },
1386
1515
  {
1387
1516
  provide: 'ProductRepository',
@@ -1405,6 +1534,39 @@ AngularHasuraGraphQLModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.
1405
1534
  },
1406
1535
  deps: ['HasuraConfig'],
1407
1536
  },
1537
+ {
1538
+ provide: 'CategoryFilterRepository',
1539
+ useExisting: CategoryFilterHasuraGraphQLRepository,
1540
+ },
1541
+ {
1542
+ provide: CategoryFilterHasuraGraphQLRepository,
1543
+ useFactory: (options) => {
1544
+ return new CategoryFilterHasuraGraphQLRepository(options.endpoint, options.credentials);
1545
+ },
1546
+ deps: [HASURA_OPTIONS],
1547
+ },
1548
+ {
1549
+ provide: 'FilterOptionRepository',
1550
+ useExisting: FilterOptionHasuraGraphQLRepository,
1551
+ },
1552
+ {
1553
+ provide: FilterOptionHasuraGraphQLRepository,
1554
+ useFactory: (options) => {
1555
+ return new FilterOptionHasuraGraphQLRepository(options.endpoint, options.credentials);
1556
+ },
1557
+ deps: [HASURA_OPTIONS],
1558
+ },
1559
+ {
1560
+ provide: 'FilterRepository',
1561
+ useExisting: FilterHasuraGraphQLRepository,
1562
+ },
1563
+ {
1564
+ provide: FilterHasuraGraphQLRepository,
1565
+ useFactory: (options, filterOptionRepository, categoryFilterRepository) => {
1566
+ return new FilterHasuraGraphQLRepository(options.endpoint, options.credentials, filterOptionRepository, categoryFilterRepository);
1567
+ },
1568
+ deps: [HASURA_OPTIONS, FilterOptionHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
1569
+ },
1408
1570
  ] });
1409
1571
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularHasuraGraphQLModule, decorators: [{
1410
1572
  type: NgModule,
@@ -1439,10 +1601,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
1439
1601
  },
1440
1602
  {
1441
1603
  provide: CategoryHasuraGraphQLRepository,
1442
- useFactory: (hasuraConfig, productRepository) => {
1443
- return new CategoryHasuraGraphQLRepository(hasuraConfig, productRepository);
1604
+ useFactory: (options, productRepository, categoryFilterRepository) => {
1605
+ return new CategoryHasuraGraphQLRepository(options, productRepository, categoryFilterRepository);
1444
1606
  },
1445
- deps: ['HasuraConfig', ProductHasuraGraphQLRepository],
1607
+ deps: [HASURA_OPTIONS, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
1446
1608
  },
1447
1609
  {
1448
1610
  provide: 'ProductRepository',
@@ -1466,6 +1628,39 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
1466
1628
  },
1467
1629
  deps: ['HasuraConfig'],
1468
1630
  },
1631
+ {
1632
+ provide: 'CategoryFilterRepository',
1633
+ useExisting: CategoryFilterHasuraGraphQLRepository,
1634
+ },
1635
+ {
1636
+ provide: CategoryFilterHasuraGraphQLRepository,
1637
+ useFactory: (options) => {
1638
+ return new CategoryFilterHasuraGraphQLRepository(options.endpoint, options.credentials);
1639
+ },
1640
+ deps: [HASURA_OPTIONS],
1641
+ },
1642
+ {
1643
+ provide: 'FilterOptionRepository',
1644
+ useExisting: FilterOptionHasuraGraphQLRepository,
1645
+ },
1646
+ {
1647
+ provide: FilterOptionHasuraGraphQLRepository,
1648
+ useFactory: (options) => {
1649
+ return new FilterOptionHasuraGraphQLRepository(options.endpoint, options.credentials);
1650
+ },
1651
+ deps: [HASURA_OPTIONS],
1652
+ },
1653
+ {
1654
+ provide: 'FilterRepository',
1655
+ useExisting: FilterHasuraGraphQLRepository,
1656
+ },
1657
+ {
1658
+ provide: FilterHasuraGraphQLRepository,
1659
+ useFactory: (options, filterOptionRepository, categoryFilterRepository) => {
1660
+ return new FilterHasuraGraphQLRepository(options.endpoint, options.credentials, filterOptionRepository, categoryFilterRepository);
1661
+ },
1662
+ deps: [HASURA_OPTIONS, FilterOptionHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
1663
+ },
1469
1664
  ],
1470
1665
  }]
1471
1666
  }] });