@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.
- package/esm2020/angular-firestore.module.mjs +7 -2
- package/esm2020/helpers/index.mjs +2 -0
- package/esm2020/helpers/mobile-operation-system-checker.helper.mjs +7 -0
- package/esm2020/services/coupon.service.mjs +11 -7
- package/fesm2015/infrab4a-connect-angular.mjs +23 -7
- package/fesm2015/infrab4a-connect-angular.mjs.map +1 -1
- package/fesm2020/infrab4a-connect-angular.mjs +22 -7
- package/fesm2020/infrab4a-connect-angular.mjs.map +1 -1
- package/helpers/index.d.ts +1 -0
- package/helpers/mobile-operation-system-checker.helper.d.ts +3 -0
- package/package.json +1 -1
|
@@ -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.
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
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.';
|