@infrab4a/connect-angular 4.0.0-beta.10 → 4.0.0-beta.12

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.
@@ -4,14 +4,14 @@ import * as i1 from '@angular/fire/auth';
4
4
  import { getIdToken, authState, Auth, provideAuth, getAuth } from '@angular/fire/auth';
5
5
  import { combineLatest, of, from, throwError, Subject, iif, forkJoin } from 'rxjs';
6
6
  import { map, mergeMap, catchError, concatMap, tap } from 'rxjs/operators';
7
- import * as i1$1 from '@infrab4a/connect';
8
- 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';
7
+ import * as i3 from '@infrab4a/connect';
8
+ 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';
9
9
  import cookie from 'js-cookie';
10
10
  import { CustomError } from 'ts-custom-error';
11
- import * as i1$2 from '@angular/fire/firestore';
11
+ import * as i1$1 from '@angular/fire/firestore';
12
12
  import { docSnapshots, doc, Firestore, provideFirestore, getFirestore } from '@angular/fire/firestore';
13
- import * as i1$3 from '@angular/common/http';
14
- import * as i1$4 from '@angular/fire/app';
13
+ import * as i1$2 from '@angular/common/http';
14
+ import * as i1$3 from '@angular/fire/app';
15
15
  import { provideFirebaseApp, initializeApp } from '@angular/fire/app';
16
16
  import { isPlatformBrowser } from '@angular/common';
17
17
 
@@ -71,11 +71,10 @@ class GroupInvalidCouponError extends CustomError {
71
71
  }
72
72
 
73
73
  class CouponService {
74
- constructor(couponRepository, defaultShop, orderRepository, subscriptionRepository, categoryRepository) {
74
+ constructor(couponRepository, defaultShop, orderRepository, categoryRepository) {
75
75
  this.couponRepository = couponRepository;
76
76
  this.defaultShop = defaultShop;
77
77
  this.orderRepository = orderRepository;
78
- this.subscriptionRepository = subscriptionRepository;
79
78
  this.categoryRepository = categoryRepository;
80
79
  this.emailIsFromCollaborator = (userEmail) => !!userEmail?.match(/@b4a.com.br/g);
81
80
  }
@@ -116,7 +115,7 @@ class CouponService {
116
115
  const hasMinSubTotal = this.hasMinSubTotal(coupon, checkout);
117
116
  // Se não tem valor mínimo atingido, retorna erro
118
117
  if (!hasMinSubTotal)
119
- return throwError('Valor mínimo não atingido');
118
+ return throwError(`Valor mínimo de ${Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' }).format(coupon.minSubTotalValue)} não atingido`);
120
119
  return of(coupon);
121
120
  }
122
121
  isValidCoupon(coupon, userEmail) {
@@ -143,7 +142,7 @@ class CouponService {
143
142
  // Verifica o limite de uso geral por usuario
144
143
  if (coupon.useLimit && orders.data.length >= coupon.useLimit)
145
144
  throw new InvalidCouponError('Limite de uso atingido.');
146
- const validUser = await this.userValidationAndSubscriptionStatus(coupon, userEmail);
145
+ const validUser = this.userValidationAndSubscriptionStatus(coupon, checkout?.user);
147
146
  if (!validUser)
148
147
  throw new InvalidCouponError('Usuário não elegível.');
149
148
  const hasProductCategories = await this.hasProductCategories(coupon, checkout);
@@ -219,37 +218,24 @@ class CouponService {
219
218
  });
220
219
  return hasCategories.length ? true : false;
221
220
  }
222
- async userValidationAndSubscriptionStatus(coupon, userEmail) {
221
+ userValidationAndSubscriptionStatus(coupon, user) {
222
+ if (coupon.exclusivityType === Exclusivities.ALL_USERS)
223
+ return true;
224
+ if (!user)
225
+ return true;
223
226
  // Verifica se o email do usuário é coorporativo
224
- if (!this.emailIsFromCollaborator(userEmail) && coupon.exclusivityType === Exclusivities.COLLABORATORS)
227
+ if (!this.emailIsFromCollaborator(user.email) && coupon.exclusivityType === Exclusivities.COLLABORATORS)
225
228
  throw new InvalidCouponError('Você não é colaborador.');
226
229
  // Verifica se o email do usuário é associado ao cupom de uso por usuario
227
- if (coupon.exclusivityType === Exclusivities.SPECIFIC_USER && coupon.userExclusiveEmail !== userEmail)
230
+ if (coupon.exclusivityType === Exclusivities.SPECIFIC_USER && coupon.userExclusiveEmail !== user.email)
228
231
  throw new InvalidCouponError('Cupom não é válido para este usuário.');
229
- const couponRuleSubscription = coupon.exclusivityType === Exclusivities.ACTIVE_SUBSCRIBER ||
230
- coupon.exclusivityType === Exclusivities.INACTIVE_SUBSCRIBER ||
231
- coupon.exclusivityType === Exclusivities.NON_SUBSCRIBER;
232
- if (couponRuleSubscription && userEmail) {
233
- const sub = await this.subscriptionRepository
234
- .find({
235
- filters: {
236
- user: {
237
- email: { operator: Where.EQUALS, value: userEmail },
238
- },
239
- },
240
- })
241
- .then((sub) => sub.data);
242
- const activeSubs = sub?.filter((s) => s.status === Status.ACTIVE);
243
- switch (coupon.exclusivityType) {
244
- case Exclusivities.ACTIVE_SUBSCRIBER:
245
- return activeSubs.length > 0;
246
- case Exclusivities.INACTIVE_SUBSCRIBER:
247
- return activeSubs.length === 0;
248
- case Exclusivities.NON_SUBSCRIBER:
249
- return sub.length === 0;
250
- default:
251
- return false;
252
- }
232
+ switch (coupon.exclusivityType) {
233
+ case Exclusivities.ACTIVE_SUBSCRIBER:
234
+ return user.isSubscriber ? true : false;
235
+ case Exclusivities.INACTIVE_SUBSCRIBER:
236
+ return user.isSubscriber ? false : true;
237
+ case Exclusivities.NON_SUBSCRIBER:
238
+ return user.isSubscriber ? false : true;
253
239
  }
254
240
  return true;
255
241
  }
@@ -264,7 +250,7 @@ class CouponService {
264
250
  return couponCategories;
265
251
  }
266
252
  }
267
- 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 });
253
+ 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 });
268
254
  CouponService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CouponService, providedIn: 'root' });
269
255
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CouponService, decorators: [{
270
256
  type: Injectable,
@@ -274,15 +260,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
274
260
  }], ctorParameters: function () { return [{ type: undefined, decorators: [{
275
261
  type: Inject,
276
262
  args: ['CouponRepository']
277
- }] }, { type: i1$1.Shops, decorators: [{
263
+ }] }, { type: i3.Shops, decorators: [{
278
264
  type: Inject,
279
265
  args: [DEFAULT_SHOP]
280
266
  }] }, { type: undefined, decorators: [{
281
267
  type: Inject,
282
268
  args: ['OrderRepository']
283
- }] }, { type: undefined, decorators: [{
284
- type: Inject,
285
- args: ['SubscriptionRepository']
286
269
  }] }, { type: undefined, decorators: [{
287
270
  type: Inject,
288
271
  args: ['CategoryRepository']
@@ -346,21 +329,23 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
346
329
  }] }, { type: undefined, decorators: [{
347
330
  type: Inject,
348
331
  args: ['UserRepository']
349
- }] }, { type: i1$1.Shops, decorators: [{
332
+ }] }, { type: i3.Shops, decorators: [{
350
333
  type: Inject,
351
334
  args: [DEFAULT_SHOP]
352
335
  }] }]; } });
353
336
 
354
337
  class CartService {
355
- constructor(authService, checkoutService, defaultShop, productRepository) {
338
+ constructor(authService, checkoutService, defaultShop, productRepository, variantRepository, buy2WinRepository) {
356
339
  this.authService = authService;
357
340
  this.checkoutService = checkoutService;
358
341
  this.defaultShop = defaultShop;
359
342
  this.productRepository = productRepository;
343
+ this.variantRepository = variantRepository;
344
+ this.buy2WinRepository = buy2WinRepository;
360
345
  this.cartSubject = new Subject();
361
346
  this.updateLineItemInCart = (lineItem, quantity, checkout) => (isNil(checkout) ? this.checkoutService.getCheckout() : of(checkout)).pipe(concatMap((checkoutLoaded) => {
362
347
  const items = [];
363
- const index = checkoutLoaded.lineItems?.map((checkoutItem) => checkoutItem.sku).indexOf(lineItem.sku);
348
+ const index = checkoutLoaded.lineItems?.map((checkoutItem) => checkoutItem.id).indexOf(lineItem.id);
364
349
  if (index > -1) {
365
350
  checkoutLoaded.lineItems[index].quantity += quantity;
366
351
  checkoutLoaded.lineItems[index].pricePaid = lineItem.pricePaid;
@@ -371,21 +356,20 @@ class CartService {
371
356
  .updateCheckoutLineItems(checkoutLoaded)
372
357
  .pipe(map((updatedCheckout) => this.generateCartObject(updatedCheckout.lineItems)));
373
358
  }));
374
- this.generateCartObject = (items) => {
375
- const cart = {};
376
- items?.forEach((item) => (cart[item.sku] = LineItem.toInstance({
377
- ...(cart[item.sku] || item),
378
- quantity: (cart[item.sku]?.quantity || 0) + (item.quantity ? item.quantity : 1),
379
- })));
380
- return cart;
381
- };
359
+ this.generateCartObject = (items) => items.reduce((cart, item) => ({
360
+ ...cart,
361
+ [item.id]: LineItem.toInstance({
362
+ ...(cart[item.id] || item),
363
+ quantity: (cart[item.id]?.quantity || 0) + (item.quantity ? item.quantity : 1),
364
+ }),
365
+ }), {});
382
366
  this.buildLineItem = async ({ checkout, item, quantity, }) => {
383
- const product = await this.productRepository.get({ id: item.id });
384
- item.quantity = item?.quantity || checkout?.lineItems?.find((lineItem) => lineItem.sku === item.sku)?.quantity || 0;
367
+ const product = await this.getProductData(item.id);
368
+ item.quantity = item?.quantity || checkout?.lineItems?.find((lineItem) => lineItem.id === item.id)?.quantity || 0;
385
369
  if (this.checkMaxStock(item, quantity || 0))
386
370
  throw new Error('Desculpe! Temos apenas ' + item.stock?.quantity + ' em estoque.');
387
371
  const image = item.image || item.images?.shift();
388
- const { id, name, EAN, brand, slug, stock, price, weight, categories, sku, type } = item;
372
+ const { id, name, EAN, slug, stock, price, weight, sku, type } = item;
389
373
  const isGift = item.isGift || null;
390
374
  const pricePaid = this.getProductPrice({
391
375
  product: item,
@@ -431,7 +415,7 @@ class CartService {
431
415
  }
432
416
  decreaseItem(item) {
433
417
  return this.checkoutService.getCheckout().pipe(map((checkout) => {
434
- const checkoutItem = checkout.lineItems?.find((lineItem) => lineItem.sku === item.sku);
418
+ const checkoutItem = checkout.lineItems?.find((lineItem) => lineItem.id === item.id);
435
419
  if (!isNil(checkoutItem))
436
420
  checkoutItem.quantity -= checkoutItem.quantity > 1 ? 1 : 0;
437
421
  return checkout;
@@ -449,17 +433,21 @@ class CartService {
449
433
  }
450
434
  removeItem(item) {
451
435
  return this.checkoutService.getCheckout().pipe(map((checkout) => {
452
- const index = checkout.lineItems.findIndex((lineItem) => lineItem.sku === item.sku);
436
+ const index = checkout.lineItems.findIndex((lineItem) => lineItem.id === item.id);
453
437
  if (index >= 0)
454
438
  checkout.lineItems.splice(index, 1);
455
439
  return checkout;
456
440
  }), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
457
441
  }
458
442
  updateUserCart(user) {
459
- return this.checkoutService.getCheckout().pipe(concatMap((checkout) => this.checkoutService.updateCheckoutUser(Checkout.toInstance({ ...checkout.toPlain(), user }))), concatMap(async (checkout) => this.checkoutService.updateCheckoutLineItems(Checkout.toInstance({
443
+ return this.checkoutService.getCheckout().pipe(concatMap((checkout) => this.checkoutService.updateCheckoutUser(Checkout.toInstance({ ...checkout.toPlain(), user }))), concatMap(async (checkout) => this.checkoutService
444
+ .updateCheckoutLineItems(Checkout.toInstance({
460
445
  ...checkout.toPlain(),
461
- lineItems: checkout.lineItems?.length ? await Promise.all(checkout.lineItems?.map(async (item) => (await this.buildLineItem({ checkout, item })).lineItem)) : [],
462
- })).toPromise()), map(checkout => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
446
+ lineItems: checkout.lineItems?.length
447
+ ? await Promise.all(checkout.lineItems?.map(async (item) => (await this.buildLineItem({ checkout, item })).lineItem))
448
+ : [],
449
+ }))
450
+ .toPromise()), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
463
451
  }
464
452
  clearCart() {
465
453
  return this.checkoutService.getCheckout().pipe(map((checkout) => {
@@ -470,17 +458,120 @@ class CartService {
470
458
  buildCartFromCheckout(checkoutData) {
471
459
  return this.checkoutService.getCheckout(checkoutData).pipe(map((checkout) => checkout.lineItems), concatMap((lineItems) => of(this.generateCartObject(lineItems))));
472
460
  }
461
+ async getProductData(productId) {
462
+ let product;
463
+ let variant;
464
+ try {
465
+ product = await this.productRepository.get({ id: productId });
466
+ }
467
+ catch (error) {
468
+ if (!(error instanceof NotFoundError))
469
+ throw error;
470
+ variant = await this.variantRepository.get({ id: productId });
471
+ product = await this.productRepository.get({ id: variant.productId });
472
+ }
473
+ return {
474
+ ...product.toPlain(),
475
+ ...(variant && { ...variant.toPlain() }),
476
+ };
477
+ }
478
+ getGifts() {
479
+ return this.checkoutService.getCheckout().pipe(mergeMap(async (checkout) => {
480
+ const campaigns = await this.buy2WinRepository
481
+ .find({
482
+ filters: {
483
+ active: { operator: Where.EQUALS, value: true },
484
+ shop: { operator: Where.EQUALS, value: this.defaultShop },
485
+ },
486
+ })
487
+ .then((data) => data.data);
488
+ const notGiftItems = checkout.lineItems.filter((item) => !item.isGift);
489
+ if (!campaigns.length)
490
+ return { ...checkout, lineItems: notGiftItems };
491
+ const cartTotal = notGiftItems.reduce((a, b) => a + b.pricePaid * b.quantity, 0);
492
+ const elegibleCampaigns = [];
493
+ for (const campaign of campaigns) {
494
+ const today = new Date();
495
+ if (!(campaign.startDate <= today) && !(campaign.endDate >= today))
496
+ continue;
497
+ if (campaign.activeCategory) {
498
+ const categoriesCampaing = campaign.categories.map((c) => c.id);
499
+ const filterProductsCategories = checkout.lineItems.filter((l) => {
500
+ if (!l.categories || !l.categories?.length)
501
+ return true;
502
+ return l.categories.some((c) => categoriesCampaing.some((cat) => cat == c));
503
+ });
504
+ if (filterProductsCategories.length) {
505
+ const cartTotalCategories = filterProductsCategories.reduce((a, b) => a + b.pricePaid * b.quantity, 0);
506
+ if (cartTotalCategories >= campaign.cartValueMin)
507
+ elegibleCampaigns.push(campaign);
508
+ }
509
+ }
510
+ else {
511
+ if (campaign.cartValue && campaign.cartValue > 0) {
512
+ if (campaign.cartValue <= cartTotal)
513
+ elegibleCampaigns.push(campaign);
514
+ }
515
+ }
516
+ }
517
+ if (!elegibleCampaigns.length)
518
+ return { ...checkout, lineItems: notGiftItems };
519
+ const campaingnProducts = [];
520
+ for (const campaign of elegibleCampaigns) {
521
+ let elegibleProducts = [];
522
+ for (const product of campaign.products) {
523
+ const productData = await this.productRepository.get({ sku: product });
524
+ if (!productData)
525
+ continue;
526
+ elegibleProducts.push(productData);
527
+ }
528
+ campaingnProducts.push(elegibleProducts);
529
+ }
530
+ if (!campaingnProducts.length)
531
+ return { ...checkout, lineItems: notGiftItems };
532
+ const gifts = this.giftToLineItems([].concat(...campaingnProducts));
533
+ return { ...checkout, lineItems: notGiftItems.concat(gifts) };
534
+ }), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
535
+ }
536
+ giftToLineItems(items) {
537
+ return items.map((item) => {
538
+ const { brand, categories, id, name, price, sku, slug, stock, weight, EAN } = item;
539
+ const image = item?.miniatures?.length ? item.miniatures[0] : item.images[0];
540
+ return LineItem.toInstance({
541
+ brand,
542
+ categories,
543
+ id: id.toString(),
544
+ name,
545
+ price,
546
+ sku,
547
+ slug,
548
+ stock,
549
+ weight,
550
+ EAN,
551
+ image,
552
+ pricePaid: 0,
553
+ quantity: 1,
554
+ isGift: true,
555
+ });
556
+ });
557
+ }
473
558
  }
474
- 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 });
559
+ 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 });
475
560
  CartService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService });
476
561
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService, decorators: [{
477
562
  type: Injectable
478
- }], ctorParameters: function () { return [{ type: AuthService }, { type: CheckoutService }, { type: i1$1.Shops, decorators: [{
563
+ }], ctorParameters: function () { return [{ type: AuthService }, { type: CheckoutService }, { type: i3.Shops, decorators: [{
479
564
  type: Inject,
480
565
  args: [DEFAULT_SHOP]
481
566
  }] }, { type: undefined, decorators: [{
482
567
  type: Inject,
483
568
  args: ['ProductRepository']
569
+ }] }, { type: undefined, decorators: [{
570
+ type: Inject,
571
+ args: ['VariantRepository']
572
+ }] }, { type: i3.Buy2WinFirestoreRepository, decorators: [{
573
+ type: Inject,
574
+ args: ['Buy2WinRepository']
484
575
  }] }]; } });
485
576
 
486
577
  class CheckoutSubscriptionService {
@@ -508,7 +599,9 @@ class CheckoutSubscriptionService {
508
599
  return of();
509
600
  }
510
601
  checkCoupon(nickname, userEmail) {
511
- return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService.checkCoupon(nickname, userEmail, CheckoutTypes.SUBSCRIPTION, checkout.subscriptionPlan.name, null, true).pipe()));
602
+ return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService
603
+ .checkCoupon(nickname, userEmail, CheckoutTypes.SUBSCRIPTION, checkout.subscriptionPlan.name, checkout, true)
604
+ .pipe()));
512
605
  }
513
606
  calcDiscountSubscription(coupon) {
514
607
  return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService.calcDiscountSubscription(coupon, checkout).pipe()));
@@ -628,7 +721,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
628
721
  }] }, { type: undefined, decorators: [{
629
722
  type: Inject,
630
723
  args: ['ProductRepository']
631
- }] }, { type: i1$1.Shops, decorators: [{
724
+ }] }, { type: i3.Shops, decorators: [{
632
725
  type: Inject,
633
726
  args: [DEFAULT_SHOP]
634
727
  }] }]; } });
@@ -646,11 +739,11 @@ class OrderService {
646
739
  return this.orderSubject;
647
740
  }
648
741
  }
649
- 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 });
742
+ 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 });
650
743
  OrderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OrderService });
651
744
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OrderService, decorators: [{
652
745
  type: Injectable
653
- }], ctorParameters: function () { return [{ type: i1$2.Firestore }, { type: i1$1.OrderFirestoreRepository, decorators: [{
746
+ }], ctorParameters: function () { return [{ type: i1$1.Firestore }, { type: i3.OrderFirestoreRepository, decorators: [{
654
747
  type: Inject,
655
748
  args: ['OrderRepository']
656
749
  }] }]; } });
@@ -676,7 +769,7 @@ class ShippingService {
676
769
  });
677
770
  const datasSameDayNotAvaliable = datas.sameDayNotAvaliable;
678
771
  if (this.isHolidays(datasSameDayNotAvaliable)) {
679
- shippingMethods = shippingMethods.filter((method) => method.ShippingCompanyName !== 'Same Day');
772
+ shippingMethods = shippingMethods.filter((method) => method.serviceName !== 'Same Day');
680
773
  }
681
774
  if (totalPrice >= 200) {
682
775
  shippingMethods = shippingMethods.map((s) => {
@@ -707,9 +800,8 @@ class ShippingService {
707
800
  isFreeShippingBySubscription(shop, subscriptionPlan) {
708
801
  if (!subscriptionPlan)
709
802
  return false;
710
- if (shop == Shops.MENSMARKET && subscriptionPlan == 'SELECT') {
803
+ if (shop == Shops.MENSMARKET && subscriptionPlan == 'SELECT')
711
804
  return true;
712
- }
713
805
  return false;
714
806
  }
715
807
  isHalfShippingBySubscription(shop, subscriptionPlan) {
@@ -733,11 +825,11 @@ class ShippingService {
733
825
  return false;
734
826
  }
735
827
  }
736
- 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 });
828
+ 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 });
737
829
  ShippingService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ShippingService });
738
830
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ShippingService, decorators: [{
739
831
  type: Injectable
740
- }], ctorParameters: function () { return [{ type: i1$3.HttpClient }, { type: undefined, decorators: [{
832
+ }], ctorParameters: function () { return [{ type: i1$2.HttpClient }, { type: undefined, decorators: [{
741
833
  type: Inject,
742
834
  args: [BACKEND_URL]
743
835
  }] }, { type: HomeShopService }]; } });
@@ -754,7 +846,7 @@ class AngularFirebaseAuthModule {
754
846
  }
755
847
  }
756
848
  AngularFirebaseAuthModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirebaseAuthModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
757
- AngularFirebaseAuthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularFirebaseAuthModule, imports: [i1$4.FirebaseAppModule, i1.AuthModule] });
849
+ AngularFirebaseAuthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularFirebaseAuthModule, imports: [i1$3.FirebaseAppModule, i1.AuthModule] });
758
850
  AngularFirebaseAuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirebaseAuthModule, providers: [
759
851
  {
760
852
  provide: 'Authentication',
@@ -911,7 +1003,7 @@ class AngularFirestoreModule {
911
1003
  }
912
1004
  }
913
1005
  AngularFirestoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirestoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
914
- AngularFirestoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularFirestoreModule, imports: [AngularElasticSeachModule, i1$4.FirebaseAppModule, i1$2.FirestoreModule] });
1006
+ AngularFirestoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularFirestoreModule, imports: [AngularElasticSeachModule, i1$3.FirebaseAppModule, i1$1.FirestoreModule] });
915
1007
  AngularFirestoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirestoreModule, providers: [
916
1008
  {
917
1009
  provide: 'FirestoreOptions',
@@ -977,6 +1069,20 @@ AngularFirestoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0",
977
1069
  },
978
1070
  deps: ['FirestoreOptions'],
979
1071
  },
1072
+ {
1073
+ provide: 'CampaignHashtagRepository',
1074
+ useFactory: (options) => {
1075
+ return new CampaignHashtagFirestoreRepository(options);
1076
+ },
1077
+ deps: [Firestore],
1078
+ },
1079
+ {
1080
+ provide: 'CampaignDashboardRepository',
1081
+ useFactory: (options) => {
1082
+ return new CampaignDashboardFirestoreRepository(options);
1083
+ },
1084
+ deps: [Firestore],
1085
+ },
980
1086
  {
981
1087
  provide: 'EditionRepository',
982
1088
  useFactory: (options, subscriptionRepository) => {
@@ -1033,6 +1139,13 @@ AngularFirestoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0",
1033
1139
  },
1034
1140
  deps: ['FirestoreOptions'],
1035
1141
  },
1142
+ {
1143
+ provide: 'ShopSettingsRepository',
1144
+ useFactory: (options) => {
1145
+ return new ShopSettingsFirestoreRepository(options);
1146
+ },
1147
+ deps: [Firestore],
1148
+ },
1036
1149
  {
1037
1150
  provide: 'SubscriptionPaymentRepository',
1038
1151
  useFactory: (options, subscriptionRepository) => {
@@ -1175,6 +1288,20 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
1175
1288
  },
1176
1289
  deps: ['FirestoreOptions'],
1177
1290
  },
1291
+ {
1292
+ provide: 'CampaignHashtagRepository',
1293
+ useFactory: (options) => {
1294
+ return new CampaignHashtagFirestoreRepository(options);
1295
+ },
1296
+ deps: [Firestore],
1297
+ },
1298
+ {
1299
+ provide: 'CampaignDashboardRepository',
1300
+ useFactory: (options) => {
1301
+ return new CampaignDashboardFirestoreRepository(options);
1302
+ },
1303
+ deps: [Firestore],
1304
+ },
1178
1305
  {
1179
1306
  provide: 'EditionRepository',
1180
1307
  useFactory: (options, subscriptionRepository) => {
@@ -1231,6 +1358,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
1231
1358
  },
1232
1359
  deps: ['FirestoreOptions'],
1233
1360
  },
1361
+ {
1362
+ provide: 'ShopSettingsRepository',
1363
+ useFactory: (options) => {
1364
+ return new ShopSettingsFirestoreRepository(options);
1365
+ },
1366
+ deps: [Firestore],
1367
+ },
1234
1368
  {
1235
1369
  provide: 'SubscriptionPaymentRepository',
1236
1370
  useFactory: (options, subscriptionRepository) => {
@@ -1331,10 +1465,10 @@ AngularHasuraGraphQLModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.
1331
1465
  },
1332
1466
  {
1333
1467
  provide: CategoryHasuraGraphQLRepository,
1334
- useFactory: (hasuraConfig, productRepository) => {
1335
- return new CategoryHasuraGraphQLRepository(hasuraConfig, productRepository);
1468
+ useFactory: (options, productRepository, categoryFilterRepository) => {
1469
+ return new CategoryHasuraGraphQLRepository(options, productRepository, categoryFilterRepository);
1336
1470
  },
1337
- deps: ['HasuraConfig', ProductHasuraGraphQLRepository],
1471
+ deps: [HASURA_OPTIONS, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
1338
1472
  },
1339
1473
  {
1340
1474
  provide: 'ProductRepository',
@@ -1358,6 +1492,39 @@ AngularHasuraGraphQLModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.
1358
1492
  },
1359
1493
  deps: ['HasuraConfig'],
1360
1494
  },
1495
+ {
1496
+ provide: 'CategoryFilterRepository',
1497
+ useExisting: CategoryFilterHasuraGraphQLRepository,
1498
+ },
1499
+ {
1500
+ provide: CategoryFilterHasuraGraphQLRepository,
1501
+ useFactory: (options) => {
1502
+ return new CategoryFilterHasuraGraphQLRepository(options.endpoint, options.credentials);
1503
+ },
1504
+ deps: [HASURA_OPTIONS],
1505
+ },
1506
+ {
1507
+ provide: 'FilterOptionRepository',
1508
+ useExisting: FilterOptionHasuraGraphQLRepository,
1509
+ },
1510
+ {
1511
+ provide: FilterOptionHasuraGraphQLRepository,
1512
+ useFactory: (options) => {
1513
+ return new FilterOptionHasuraGraphQLRepository(options.endpoint, options.credentials);
1514
+ },
1515
+ deps: [HASURA_OPTIONS],
1516
+ },
1517
+ {
1518
+ provide: 'FilterRepository',
1519
+ useExisting: FilterHasuraGraphQLRepository,
1520
+ },
1521
+ {
1522
+ provide: FilterHasuraGraphQLRepository,
1523
+ useFactory: (options, filterOptionRepository, categoryFilterRepository) => {
1524
+ return new FilterHasuraGraphQLRepository(options.endpoint, options.credentials, filterOptionRepository, categoryFilterRepository);
1525
+ },
1526
+ deps: [HASURA_OPTIONS, FilterOptionHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
1527
+ },
1361
1528
  ] });
1362
1529
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularHasuraGraphQLModule, decorators: [{
1363
1530
  type: NgModule,
@@ -1392,10 +1559,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
1392
1559
  },
1393
1560
  {
1394
1561
  provide: CategoryHasuraGraphQLRepository,
1395
- useFactory: (hasuraConfig, productRepository) => {
1396
- return new CategoryHasuraGraphQLRepository(hasuraConfig, productRepository);
1562
+ useFactory: (options, productRepository, categoryFilterRepository) => {
1563
+ return new CategoryHasuraGraphQLRepository(options, productRepository, categoryFilterRepository);
1397
1564
  },
1398
- deps: ['HasuraConfig', ProductHasuraGraphQLRepository],
1565
+ deps: [HASURA_OPTIONS, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
1399
1566
  },
1400
1567
  {
1401
1568
  provide: 'ProductRepository',
@@ -1419,6 +1586,39 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
1419
1586
  },
1420
1587
  deps: ['HasuraConfig'],
1421
1588
  },
1589
+ {
1590
+ provide: 'CategoryFilterRepository',
1591
+ useExisting: CategoryFilterHasuraGraphQLRepository,
1592
+ },
1593
+ {
1594
+ provide: CategoryFilterHasuraGraphQLRepository,
1595
+ useFactory: (options) => {
1596
+ return new CategoryFilterHasuraGraphQLRepository(options.endpoint, options.credentials);
1597
+ },
1598
+ deps: [HASURA_OPTIONS],
1599
+ },
1600
+ {
1601
+ provide: 'FilterOptionRepository',
1602
+ useExisting: FilterOptionHasuraGraphQLRepository,
1603
+ },
1604
+ {
1605
+ provide: FilterOptionHasuraGraphQLRepository,
1606
+ useFactory: (options) => {
1607
+ return new FilterOptionHasuraGraphQLRepository(options.endpoint, options.credentials);
1608
+ },
1609
+ deps: [HASURA_OPTIONS],
1610
+ },
1611
+ {
1612
+ provide: 'FilterRepository',
1613
+ useExisting: FilterHasuraGraphQLRepository,
1614
+ },
1615
+ {
1616
+ provide: FilterHasuraGraphQLRepository,
1617
+ useFactory: (options, filterOptionRepository, categoryFilterRepository) => {
1618
+ return new FilterHasuraGraphQLRepository(options.endpoint, options.credentials, filterOptionRepository, categoryFilterRepository);
1619
+ },
1620
+ deps: [HASURA_OPTIONS, FilterOptionHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
1621
+ },
1422
1622
  ],
1423
1623
  }]
1424
1624
  }] });