@infrab4a/connect-angular 4.0.0-beta.41 → 4.0.0-beta.42

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.
@@ -8,7 +8,7 @@ import * as i1$1 from '@angular/fire/auth';
8
8
  import { Auth, provideAuth, getAuth, getIdToken, authState } from '@angular/fire/auth';
9
9
  import { isPlatformBrowser } from '@angular/common';
10
10
  import * as i1$2 from '@angular/fire/firestore';
11
- import { Firestore, provideFirestore, initializeFirestore, enableIndexedDbPersistence, docSnapshots, doc } from '@angular/fire/firestore';
11
+ import { Firestore, provideFirestore, getFirestore, initializeFirestore, enableIndexedDbPersistence, docSnapshots, doc } from '@angular/fire/firestore';
12
12
  import { initializeApp as initializeApp$1 } from 'firebase/app';
13
13
  import { combineLatest, from, of, throwError, Subject, iif, forkJoin } from 'rxjs';
14
14
  import { map, mergeMap, catchError, concatMap, tap } from 'rxjs/operators';
@@ -182,6 +182,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
182
182
  }]
183
183
  }] });
184
184
 
185
+ class MobileOperationSystemCheckerHelper {
186
+ static isAppleDevice() {
187
+ return (['iPad Simulator', 'iPhone Simulator', 'iPod Simulator', 'iPad', 'iPhone', 'iPod'].includes(navigator?.platform) ||
188
+ (navigator?.userAgent?.includes?.('Mac') && 'ontouchend' in (document || {})));
189
+ }
190
+ }
191
+
185
192
  class AngularFirestoreModule {
186
193
  static initializeApp(options, nameOrConfig) {
187
194
  return {
@@ -402,6 +409,8 @@ AngularFirestoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0",
402
409
  : initializeApp$1(injector.get(FIREBASE_OPTIONS));
403
410
  }),
404
411
  provideFirestore((injector) => {
412
+ if (!MobileOperationSystemCheckerHelper.isAppleDevice())
413
+ return getFirestore();
405
414
  const firestore = initializeFirestore(injector.get(FirebaseApp), { experimentalForceLongPolling: true });
406
415
  enableIndexedDbPersistence(firestore).catch(console.error);
407
416
  return firestore;
@@ -418,6 +427,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
418
427
  : initializeApp$1(injector.get(FIREBASE_OPTIONS));
419
428
  }),
420
429
  provideFirestore((injector) => {
430
+ if (!MobileOperationSystemCheckerHelper.isAppleDevice())
431
+ return getFirestore();
421
432
  const firestore = initializeFirestore(injector.get(FirebaseApp), { experimentalForceLongPolling: true });
422
433
  enableIndexedDbPersistence(firestore).catch(console.error);
423
434
  return firestore;
@@ -912,13 +923,17 @@ class CouponService {
912
923
  const validUser = this.coupomUserValidation(coupon, checkout?.user);
913
924
  if (!validUser)
914
925
  throw 'Usuário não elegível.';
915
- const orders = await this.getOrdersWithCoupon(coupon);
916
- const ordersWithUser = this.countOrdersWithUser(orders, checkout.user.email);
917
926
  const couponUseLimits = this.getCouponUseLimits(coupon, checkoutType, checkout.user);
918
- if (couponUseLimits.limitedPerUser && ordersWithUser > 0)
919
- throw 'Limite de uso por usuário atingido.';
920
- if (!couponUseLimits.unlimited && couponUseLimits.total && orders.length >= couponUseLimits.total)
921
- throw 'Limite de uso atingido.';
927
+ if (!couponUseLimits.unlimited || couponUseLimits.limitedPerUser) {
928
+ const orders = await this.getOrdersWithCoupon(coupon);
929
+ if (!couponUseLimits.unlimited && couponUseLimits.total && orders.length >= couponUseLimits.total)
930
+ throw 'Limite de uso atingido.';
931
+ if (couponUseLimits.limitedPerUser) {
932
+ const ordersWithUser = this.countOrdersWithUser(orders, checkout.user.email);
933
+ if (ordersWithUser > 0)
934
+ throw 'Limite de uso por usuário atingido.';
935
+ }
936
+ }
922
937
  const hasProductCategories = await this.hasProductCategories(coupon, checkout);
923
938
  if (!hasProductCategories)
924
939
  throw 'Seu carrinho não possui produtos elegíveis para desconto.';