@infrab4a/connect-angular 4.0.0-beta.40 → 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 +12 -8
- 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 +28 -13
- package/fesm2015/infrab4a-connect-angular.mjs.map +1 -1
- package/fesm2020/infrab4a-connect-angular.mjs +27 -13
- 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
|
@@ -3,14 +3,13 @@ import { InjectionToken, NgModule, PLATFORM_ID, Injectable, Inject } from '@angu
|
|
|
3
3
|
import * as i1$3 from '@infrab4a/connect';
|
|
4
4
|
import { 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, CategoryCollectionChildrenHasuraGraphQLRepository, Where, Shops, CheckoutTypes, CouponTypes, Exclusivities, isNil, NotFoundError, Checkout, pick, LineItem, RoundProductPricesHelper, set, Category, CheckoutSubscription, Product, RequiredArgumentError, add, Order } from '@infrab4a/connect';
|
|
5
5
|
import * as i1 from '@angular/fire/app';
|
|
6
|
-
import { provideFirebaseApp, initializeApp } from '@angular/fire/app';
|
|
6
|
+
import { provideFirebaseApp, initializeApp, FirebaseApp } from '@angular/fire/app';
|
|
7
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, 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
|
-
import { getFirestore } from 'firebase/firestore';
|
|
14
13
|
import { combineLatest, from, of, throwError, Subject, iif, forkJoin } from 'rxjs';
|
|
15
14
|
import { map, mergeMap, catchError, concatMap, tap } from 'rxjs/operators';
|
|
16
15
|
import cookie from 'js-cookie';
|
|
@@ -183,6 +182,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
|
|
|
183
182
|
}]
|
|
184
183
|
}] });
|
|
185
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
|
+
|
|
186
192
|
class AngularFirestoreModule {
|
|
187
193
|
static initializeApp(options, nameOrConfig) {
|
|
188
194
|
return {
|
|
@@ -402,8 +408,10 @@ AngularFirestoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0",
|
|
|
402
408
|
? initializeApp$1(injector.get(FIREBASE_OPTIONS), appName)
|
|
403
409
|
: initializeApp$1(injector.get(FIREBASE_OPTIONS));
|
|
404
410
|
}),
|
|
405
|
-
provideFirestore(() => {
|
|
406
|
-
|
|
411
|
+
provideFirestore((injector) => {
|
|
412
|
+
if (!MobileOperationSystemCheckerHelper.isAppleDevice())
|
|
413
|
+
return getFirestore();
|
|
414
|
+
const firestore = initializeFirestore(injector.get(FirebaseApp), { experimentalForceLongPolling: true });
|
|
407
415
|
enableIndexedDbPersistence(firestore).catch(console.error);
|
|
408
416
|
return firestore;
|
|
409
417
|
})] });
|
|
@@ -418,8 +426,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
|
|
|
418
426
|
? initializeApp$1(injector.get(FIREBASE_OPTIONS), appName)
|
|
419
427
|
: initializeApp$1(injector.get(FIREBASE_OPTIONS));
|
|
420
428
|
}),
|
|
421
|
-
provideFirestore(() => {
|
|
422
|
-
|
|
429
|
+
provideFirestore((injector) => {
|
|
430
|
+
if (!MobileOperationSystemCheckerHelper.isAppleDevice())
|
|
431
|
+
return getFirestore();
|
|
432
|
+
const firestore = initializeFirestore(injector.get(FirebaseApp), { experimentalForceLongPolling: true });
|
|
423
433
|
enableIndexedDbPersistence(firestore).catch(console.error);
|
|
424
434
|
return firestore;
|
|
425
435
|
}),
|
|
@@ -913,13 +923,17 @@ class CouponService {
|
|
|
913
923
|
const validUser = this.coupomUserValidation(coupon, checkout?.user);
|
|
914
924
|
if (!validUser)
|
|
915
925
|
throw 'Usuário não elegível.';
|
|
916
|
-
const orders = await this.getOrdersWithCoupon(coupon);
|
|
917
|
-
const ordersWithUser = this.countOrdersWithUser(orders, checkout.user.email);
|
|
918
926
|
const couponUseLimits = this.getCouponUseLimits(coupon, checkoutType, checkout.user);
|
|
919
|
-
if (couponUseLimits.
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
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
|
+
}
|
|
923
937
|
const hasProductCategories = await this.hasProductCategories(coupon, checkout);
|
|
924
938
|
if (!hasProductCategories)
|
|
925
939
|
throw 'Seu carrinho não possui produtos elegíveis para desconto.';
|