@infrab4a/connect-angular 5.7.5-beta.12 → 5.7.5-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.
|
@@ -3,12 +3,12 @@ import { NgModule, InjectionToken, PLATFORM_ID, Injectable, Inject } from '@angu
|
|
|
3
3
|
import { FirebaseApp, provideFirebaseApp, getApp, initializeApp } from '@angular/fire/app';
|
|
4
4
|
import { provideAppCheck, initializeAppCheck } from '@angular/fire/app-check';
|
|
5
5
|
import { Storage, provideStorage, getStorage } from '@angular/fire/storage';
|
|
6
|
-
import * as
|
|
7
|
-
import { ProductsIndex, AxiosAdapter, Authentication, AuthenticationFirebaseAuthService, Register, RegisterFirebaseAuthService, SignOut, RecoveryPassword, ConnectFirestoreService, CategoryFirestoreRepository, ProductFirestoreRepository, ProductVariantFirestoreRepository, UserBeautyProfileFirestoreRepository, Buy2WinFirestoreRepository, CheckoutFirestoreRepository, CheckoutSubscriptionFirestoreRepository, CouponFirestoreRepository, CampaignHashtagFirestoreRepository, CampaignDashboardFirestoreRepository, SubscriptionEditionFirestoreRepository, GroupFirestoreRepository, HomeFirestoreRepository, LeadFirestoreRepository, LegacyOrderFirestoreRepository, ShopMenuFirestoreRepository, OrderFirestoreRepository, PaymentFirestoreRepository, ShopSettingsFirestoreRepository, SubscriptionPaymentFirestoreRepository, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionFirestoreRepository, UserFirestoreRepository, UserAddressFirestoreRepository, UserPaymentMethodFirestoreRepository, SubscriptionMaterializationFirestoreRepository, SubscriptionSummaryFirestoreRepository, OrderBlockedFirestoreRepository, LogFirestoreRepository, SequenceFirestoreRepository, BrandCategoryFirestoreRepository, ShopConfigsFirestoreRepository, CategoryHasuraGraphQLRepository, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository, ProductReviewHasuraGraphQLRepository, VariantHasuraGraphQLRepository, ProductStockNotificationHasuraGraphQLRepository, FilterOptionHasuraGraphQLRepository, FilterHasuraGraphQLRepository, CategoryCollectionChildrenHasuraGraphQLRepository, CategoryProductHasuraGraphQLRepository, WishlistHasuraGraphQLRepository, ProductErrorsHasuraGraphQLRepository, ProductCatalogHasuraGraphQLRepository, ProductStockEntryHasuraGraphQLRepository, ProductsVertexSearch, VertexAxiosAdapter, isNil, NotFoundError, Checkout, pick, LineItem, Where, isEmpty, Shops, set, InvalidArgumentError, RoundProductPricesHelper, Category, WishlistLogType, PersonTypes, Wishlist,
|
|
6
|
+
import * as i3 from '@infrab4a/connect';
|
|
7
|
+
import { ProductsIndex, AxiosAdapter, Authentication, AuthenticationFirebaseAuthService, Register, RegisterFirebaseAuthService, SignOut, RecoveryPassword, ConnectFirestoreService, CategoryFirestoreRepository, ProductFirestoreRepository, ProductVariantFirestoreRepository, UserBeautyProfileFirestoreRepository, Buy2WinFirestoreRepository, CheckoutFirestoreRepository, CheckoutSubscriptionFirestoreRepository, CouponFirestoreRepository, CampaignHashtagFirestoreRepository, CampaignHashtagPostsFirestoreRepository, CampaignDashboardFirestoreRepository, CampaignSettingsFirestoreRepository, SubscriptionEditionFirestoreRepository, GroupFirestoreRepository, HomeFirestoreRepository, LeadFirestoreRepository, LegacyOrderFirestoreRepository, ShopMenuFirestoreRepository, OrderFirestoreRepository, PendingOrderFirestoreRepository, PaymentFirestoreRepository, ShoppingRecurrenceFirestoreRepository, ShoppingRecurrenceEditionFirestoreRepository, ShoppingRecurrenceErrorLogFirestoreRepository, ShopSettingsFirestoreRepository, SubscriptionPaymentFirestoreRepository, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionFirestoreRepository, UserFirestoreRepository, UserAddressFirestoreRepository, UserPaymentMethodFirestoreRepository, SubscriptionMaterializationFirestoreRepository, SubscriptionSummaryFirestoreRepository, OrderBlockedFirestoreRepository, LogFirestoreRepository, SequenceFirestoreRepository, BrandCategoryFirestoreRepository, ShopConfigsFirestoreRepository, CategoryHasuraGraphQLRepository, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository, ProductReviewHasuraGraphQLRepository, VariantHasuraGraphQLRepository, ProductStockNotificationHasuraGraphQLRepository, FilterOptionHasuraGraphQLRepository, FilterHasuraGraphQLRepository, CategoryCollectionChildrenHasuraGraphQLRepository, CategoryProductHasuraGraphQLRepository, WishlistHasuraGraphQLRepository, ProductErrorsHasuraGraphQLRepository, ProductCatalogHasuraGraphQLRepository, ProductStockEntryHasuraGraphQLRepository, ProductGroupHasuraGraphQLRepository, ProductPriceLogHasuraGraphQLRepository, resolveCacheConfig, ProductsVertexSearch, VertexAxiosAdapter, isNil, NotFoundError, Checkout, pick, LineItem, Where, isEmpty, Shops, set, InvalidArgumentError, RoundProductPricesHelper, Category, WishlistLogType, PersonTypes, Wishlist, Product, RequiredArgumentError, add, OrderStatus, ProductReview, Order, UpdateUserImage, FirebaseFileUploaderService } from '@infrab4a/connect';
|
|
8
8
|
import * as i1 from '@angular/fire/auth';
|
|
9
9
|
import { Auth, provideAuth, initializeAuth, indexedDBLocalPersistence, browserLocalPersistence, browserSessionPersistence, getAuth, getIdToken, authState } from '@angular/fire/auth';
|
|
10
10
|
import { isPlatformServer, isPlatformBrowser } from '@angular/common';
|
|
11
|
-
import * as i1$
|
|
11
|
+
import * as i1$2 from '@angular/fire/firestore';
|
|
12
12
|
import { Firestore, provideFirestore, initializeFirestore, memoryLocalCache, docSnapshots, doc } from '@angular/fire/firestore';
|
|
13
13
|
import cookie from 'js-cookie';
|
|
14
14
|
import { of, from, combineLatest, throwError, Subject, forkJoin } from 'rxjs';
|
|
@@ -304,6 +304,13 @@ class AngularFirestoreModule {
|
|
|
304
304
|
},
|
|
305
305
|
deps: ['FirestoreOptions'],
|
|
306
306
|
},
|
|
307
|
+
{
|
|
308
|
+
provide: 'CampaignHashtagPostsRepository',
|
|
309
|
+
useFactory: (options) => {
|
|
310
|
+
return new CampaignHashtagPostsFirestoreRepository(options);
|
|
311
|
+
},
|
|
312
|
+
deps: ['FirestoreOptions'],
|
|
313
|
+
},
|
|
307
314
|
{
|
|
308
315
|
provide: 'CampaignDashboardRepository',
|
|
309
316
|
useFactory: (options) => {
|
|
@@ -311,6 +318,13 @@ class AngularFirestoreModule {
|
|
|
311
318
|
},
|
|
312
319
|
deps: ['FirestoreOptions'],
|
|
313
320
|
},
|
|
321
|
+
{
|
|
322
|
+
provide: 'CampaignSettingsRepository',
|
|
323
|
+
useFactory: (options) => {
|
|
324
|
+
return new CampaignSettingsFirestoreRepository(options);
|
|
325
|
+
},
|
|
326
|
+
deps: ['FirestoreOptions'],
|
|
327
|
+
},
|
|
314
328
|
{
|
|
315
329
|
provide: 'EditionRepository',
|
|
316
330
|
useFactory: (options, subscriptionRepository) => {
|
|
@@ -360,6 +374,13 @@ class AngularFirestoreModule {
|
|
|
360
374
|
},
|
|
361
375
|
deps: ['FirestoreOptions'],
|
|
362
376
|
},
|
|
377
|
+
{
|
|
378
|
+
provide: 'PendingOrderRepository',
|
|
379
|
+
useFactory: (options) => {
|
|
380
|
+
return new PendingOrderFirestoreRepository(options);
|
|
381
|
+
},
|
|
382
|
+
deps: ['FirestoreOptions'],
|
|
383
|
+
},
|
|
363
384
|
{
|
|
364
385
|
provide: 'PaymentRepository',
|
|
365
386
|
useFactory: (options) => {
|
|
@@ -367,6 +388,27 @@ class AngularFirestoreModule {
|
|
|
367
388
|
},
|
|
368
389
|
deps: ['FirestoreOptions'],
|
|
369
390
|
},
|
|
391
|
+
{
|
|
392
|
+
provide: 'ShoppingRecurrenceRepository',
|
|
393
|
+
useFactory: (options) => {
|
|
394
|
+
return new ShoppingRecurrenceFirestoreRepository(options);
|
|
395
|
+
},
|
|
396
|
+
deps: ['FirestoreOptions'],
|
|
397
|
+
},
|
|
398
|
+
{
|
|
399
|
+
provide: 'ShoppingRecurrenceEditionRepository',
|
|
400
|
+
useFactory: (options) => {
|
|
401
|
+
return new ShoppingRecurrenceEditionFirestoreRepository(options);
|
|
402
|
+
},
|
|
403
|
+
deps: ['FirestoreOptions'],
|
|
404
|
+
},
|
|
405
|
+
{
|
|
406
|
+
provide: 'ShoppingRecurrenceErrorLogRepository',
|
|
407
|
+
useFactory: (options) => {
|
|
408
|
+
return new ShoppingRecurrenceErrorLogFirestoreRepository(options);
|
|
409
|
+
},
|
|
410
|
+
deps: ['FirestoreOptions'],
|
|
411
|
+
},
|
|
370
412
|
{
|
|
371
413
|
provide: ProductFirestoreRepository,
|
|
372
414
|
useFactory: (options) => {
|
|
@@ -577,6 +619,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImpo
|
|
|
577
619
|
},
|
|
578
620
|
deps: ['FirestoreOptions'],
|
|
579
621
|
},
|
|
622
|
+
{
|
|
623
|
+
provide: 'CampaignHashtagPostsRepository',
|
|
624
|
+
useFactory: (options) => {
|
|
625
|
+
return new CampaignHashtagPostsFirestoreRepository(options);
|
|
626
|
+
},
|
|
627
|
+
deps: ['FirestoreOptions'],
|
|
628
|
+
},
|
|
580
629
|
{
|
|
581
630
|
provide: 'CampaignDashboardRepository',
|
|
582
631
|
useFactory: (options) => {
|
|
@@ -584,6 +633,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImpo
|
|
|
584
633
|
},
|
|
585
634
|
deps: ['FirestoreOptions'],
|
|
586
635
|
},
|
|
636
|
+
{
|
|
637
|
+
provide: 'CampaignSettingsRepository',
|
|
638
|
+
useFactory: (options) => {
|
|
639
|
+
return new CampaignSettingsFirestoreRepository(options);
|
|
640
|
+
},
|
|
641
|
+
deps: ['FirestoreOptions'],
|
|
642
|
+
},
|
|
587
643
|
{
|
|
588
644
|
provide: 'EditionRepository',
|
|
589
645
|
useFactory: (options, subscriptionRepository) => {
|
|
@@ -633,6 +689,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImpo
|
|
|
633
689
|
},
|
|
634
690
|
deps: ['FirestoreOptions'],
|
|
635
691
|
},
|
|
692
|
+
{
|
|
693
|
+
provide: 'PendingOrderRepository',
|
|
694
|
+
useFactory: (options) => {
|
|
695
|
+
return new PendingOrderFirestoreRepository(options);
|
|
696
|
+
},
|
|
697
|
+
deps: ['FirestoreOptions'],
|
|
698
|
+
},
|
|
636
699
|
{
|
|
637
700
|
provide: 'PaymentRepository',
|
|
638
701
|
useFactory: (options) => {
|
|
@@ -640,6 +703,27 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImpo
|
|
|
640
703
|
},
|
|
641
704
|
deps: ['FirestoreOptions'],
|
|
642
705
|
},
|
|
706
|
+
{
|
|
707
|
+
provide: 'ShoppingRecurrenceRepository',
|
|
708
|
+
useFactory: (options) => {
|
|
709
|
+
return new ShoppingRecurrenceFirestoreRepository(options);
|
|
710
|
+
},
|
|
711
|
+
deps: ['FirestoreOptions'],
|
|
712
|
+
},
|
|
713
|
+
{
|
|
714
|
+
provide: 'ShoppingRecurrenceEditionRepository',
|
|
715
|
+
useFactory: (options) => {
|
|
716
|
+
return new ShoppingRecurrenceEditionFirestoreRepository(options);
|
|
717
|
+
},
|
|
718
|
+
deps: ['FirestoreOptions'],
|
|
719
|
+
},
|
|
720
|
+
{
|
|
721
|
+
provide: 'ShoppingRecurrenceErrorLogRepository',
|
|
722
|
+
useFactory: (options) => {
|
|
723
|
+
return new ShoppingRecurrenceErrorLogFirestoreRepository(options);
|
|
724
|
+
},
|
|
725
|
+
deps: ['FirestoreOptions'],
|
|
726
|
+
},
|
|
643
727
|
{
|
|
644
728
|
provide: ProductFirestoreRepository,
|
|
645
729
|
useFactory: (options) => {
|
|
@@ -778,7 +862,7 @@ class AngularHasuraGraphQLModule {
|
|
|
778
862
|
useFactory: (options, platformId) => ({
|
|
779
863
|
endpoint: options.endpoint,
|
|
780
864
|
authOptions: options.credentials,
|
|
781
|
-
cache: options.cache,
|
|
865
|
+
cache: resolveCacheConfig(options.cache),
|
|
782
866
|
interceptors: {
|
|
783
867
|
request: (request) => {
|
|
784
868
|
if (isPlatformBrowser(platformId))
|
|
@@ -949,6 +1033,28 @@ class AngularHasuraGraphQLModule {
|
|
|
949
1033
|
provide: 'ProductStockEntryRepository',
|
|
950
1034
|
useExisting: ProductStockEntryHasuraGraphQLRepository,
|
|
951
1035
|
},
|
|
1036
|
+
{
|
|
1037
|
+
provide: ProductGroupHasuraGraphQLRepository,
|
|
1038
|
+
useFactory: (options) => {
|
|
1039
|
+
return new ProductGroupHasuraGraphQLRepository(options);
|
|
1040
|
+
},
|
|
1041
|
+
deps: ['HasuraConfig'],
|
|
1042
|
+
},
|
|
1043
|
+
{
|
|
1044
|
+
provide: 'ProductGroupRepository',
|
|
1045
|
+
useExisting: ProductGroupHasuraGraphQLRepository,
|
|
1046
|
+
},
|
|
1047
|
+
{
|
|
1048
|
+
provide: ProductPriceLogHasuraGraphQLRepository,
|
|
1049
|
+
useFactory: (options) => {
|
|
1050
|
+
return new ProductPriceLogHasuraGraphQLRepository(options);
|
|
1051
|
+
},
|
|
1052
|
+
deps: ['HasuraConfig'],
|
|
1053
|
+
},
|
|
1054
|
+
{
|
|
1055
|
+
provide: 'ProductPriceLogRepository',
|
|
1056
|
+
useExisting: ProductPriceLogHasuraGraphQLRepository,
|
|
1057
|
+
},
|
|
952
1058
|
] }); }
|
|
953
1059
|
}
|
|
954
1060
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: AngularHasuraGraphQLModule, decorators: [{
|
|
@@ -960,7 +1066,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImpo
|
|
|
960
1066
|
useFactory: (options, platformId) => ({
|
|
961
1067
|
endpoint: options.endpoint,
|
|
962
1068
|
authOptions: options.credentials,
|
|
963
|
-
cache: options.cache,
|
|
1069
|
+
cache: resolveCacheConfig(options.cache),
|
|
964
1070
|
interceptors: {
|
|
965
1071
|
request: (request) => {
|
|
966
1072
|
if (isPlatformBrowser(platformId))
|
|
@@ -1131,6 +1237,28 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImpo
|
|
|
1131
1237
|
provide: 'ProductStockEntryRepository',
|
|
1132
1238
|
useExisting: ProductStockEntryHasuraGraphQLRepository,
|
|
1133
1239
|
},
|
|
1240
|
+
{
|
|
1241
|
+
provide: ProductGroupHasuraGraphQLRepository,
|
|
1242
|
+
useFactory: (options) => {
|
|
1243
|
+
return new ProductGroupHasuraGraphQLRepository(options);
|
|
1244
|
+
},
|
|
1245
|
+
deps: ['HasuraConfig'],
|
|
1246
|
+
},
|
|
1247
|
+
{
|
|
1248
|
+
provide: 'ProductGroupRepository',
|
|
1249
|
+
useExisting: ProductGroupHasuraGraphQLRepository,
|
|
1250
|
+
},
|
|
1251
|
+
{
|
|
1252
|
+
provide: ProductPriceLogHasuraGraphQLRepository,
|
|
1253
|
+
useFactory: (options) => {
|
|
1254
|
+
return new ProductPriceLogHasuraGraphQLRepository(options);
|
|
1255
|
+
},
|
|
1256
|
+
deps: ['HasuraConfig'],
|
|
1257
|
+
},
|
|
1258
|
+
{
|
|
1259
|
+
provide: 'ProductPriceLogRepository',
|
|
1260
|
+
useExisting: ProductPriceLogHasuraGraphQLRepository,
|
|
1261
|
+
},
|
|
1134
1262
|
],
|
|
1135
1263
|
}]
|
|
1136
1264
|
}] });
|
|
@@ -1264,7 +1392,7 @@ class ConfigurationFacade {
|
|
|
1264
1392
|
}
|
|
1265
1393
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: ConfigurationFacade, decorators: [{
|
|
1266
1394
|
type: Injectable
|
|
1267
|
-
}], ctorParameters: () => [{ type:
|
|
1395
|
+
}], ctorParameters: () => [{ type: i3.Shops, decorators: [{
|
|
1268
1396
|
type: Inject,
|
|
1269
1397
|
args: [DEFAULT_SHOP]
|
|
1270
1398
|
}] }, { type: undefined, decorators: [{
|
|
@@ -1316,16 +1444,41 @@ class CheckoutService {
|
|
|
1316
1444
|
checkoutId: checkout.id,
|
|
1317
1445
|
})), concatMap(() => this.getCheckout()));
|
|
1318
1446
|
}
|
|
1447
|
+
applyPointsDiscount(points) {
|
|
1448
|
+
return this.getCheckout().pipe(concatMap((checkout) => this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/checkoutApplyPointsDiscount`, {
|
|
1449
|
+
checkoutId: checkout.id,
|
|
1450
|
+
points,
|
|
1451
|
+
})), concatMap(() => this.getCheckout()));
|
|
1452
|
+
}
|
|
1453
|
+
removePointsDiscount() {
|
|
1454
|
+
return this.getCheckout().pipe(concatMap((checkout) => this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/checkoutRemovePointsDiscount`, {
|
|
1455
|
+
checkoutId: checkout.id,
|
|
1456
|
+
})), concatMap(() => this.getCheckout()));
|
|
1457
|
+
}
|
|
1319
1458
|
validateStockProducts() {
|
|
1320
1459
|
return this.getCheckout().pipe(concatMap((checkout) => this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/checkoutValidateProductStock`, {
|
|
1321
1460
|
checkoutId: checkout.id,
|
|
1322
1461
|
})));
|
|
1323
1462
|
}
|
|
1324
1463
|
selectShippingAddress(address) {
|
|
1464
|
+
const formattedAddress = {
|
|
1465
|
+
...address,
|
|
1466
|
+
zip: this.formatZip(address.zip),
|
|
1467
|
+
};
|
|
1325
1468
|
return this.getCheckout().pipe(concatMap((checkout) => {
|
|
1326
|
-
return this.repositoriesFacade.checkoutRepository.update(Checkout.toInstance({
|
|
1469
|
+
return this.repositoriesFacade.checkoutRepository.update(Checkout.toInstance({
|
|
1470
|
+
id: checkout.id,
|
|
1471
|
+
shippingAddress: formattedAddress,
|
|
1472
|
+
billingAddress: formattedAddress,
|
|
1473
|
+
}));
|
|
1327
1474
|
}));
|
|
1328
1475
|
}
|
|
1476
|
+
formatZip(zip) {
|
|
1477
|
+
if (!zip)
|
|
1478
|
+
return zip;
|
|
1479
|
+
const digits = zip.replace(/\D/g, '');
|
|
1480
|
+
return digits;
|
|
1481
|
+
}
|
|
1329
1482
|
getAvailableShippingForProduct(productShipping) {
|
|
1330
1483
|
return this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/checkoutGetAvailableShipping`, {
|
|
1331
1484
|
checkoutId: null,
|
|
@@ -1382,6 +1535,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImpo
|
|
|
1382
1535
|
type: Injectable
|
|
1383
1536
|
}], ctorParameters: () => [{ type: AuthService }, { type: CheckoutService }, { type: i1$1.HttpClient }] });
|
|
1384
1537
|
|
|
1538
|
+
/* eslint-disable max-params */
|
|
1385
1539
|
class CartService {
|
|
1386
1540
|
constructor(servicesFacade, configurationFacade) {
|
|
1387
1541
|
this.servicesFacade = servicesFacade;
|
|
@@ -1397,11 +1551,21 @@ class CartService {
|
|
|
1397
1551
|
}), {}) || {};
|
|
1398
1552
|
this.checkoutUrl = this.configurationFacade.getCheckoutUrl();
|
|
1399
1553
|
}
|
|
1400
|
-
addItem(item, quantity = 1) {
|
|
1554
|
+
addItem(item, quantity = 1, recurrence = false, recurrenceCycle = null) {
|
|
1401
1555
|
return this.servicesFacade.checkoutService.getCheckout().pipe(concatMap((checkout) => this.servicesFacade.httpClient.post(`${this.checkoutUrl}/checkoutAddItemToCart`, {
|
|
1402
1556
|
checkoutId: checkout.id,
|
|
1403
1557
|
productId: item.id,
|
|
1404
1558
|
quantity,
|
|
1559
|
+
recurrence,
|
|
1560
|
+
recurrenceCycle,
|
|
1561
|
+
})), concatMap(() => this.servicesFacade.checkoutService.getCheckout()), map((updatedCheckout) => this.generateCartObject(updatedCheckout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
|
|
1562
|
+
}
|
|
1563
|
+
updateItemRecurrence(item, recurrence = false, recurrenceCycle = null) {
|
|
1564
|
+
return this.servicesFacade.checkoutService.getCheckout().pipe(concatMap((checkout) => this.servicesFacade.httpClient.post(`${this.checkoutUrl}/checkoutUpdateItemRecurrence`, {
|
|
1565
|
+
checkoutId: checkout.id,
|
|
1566
|
+
productId: item.id,
|
|
1567
|
+
recurrence,
|
|
1568
|
+
recurrenceCycle,
|
|
1405
1569
|
})), concatMap(() => this.servicesFacade.checkoutService.getCheckout()), map((updatedCheckout) => this.generateCartObject(updatedCheckout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
|
|
1406
1570
|
}
|
|
1407
1571
|
decreaseItem(item) {
|
|
@@ -1470,6 +1634,9 @@ class NewCategoryStructureAdapter {
|
|
|
1470
1634
|
.then((categories) => categories.map((category) => category.id.toString()));
|
|
1471
1635
|
}
|
|
1472
1636
|
async getCategory(category) {
|
|
1637
|
+
if ((category.isWishlist || category.isCollection) && Array.isArray(category.products)) {
|
|
1638
|
+
return category;
|
|
1639
|
+
}
|
|
1473
1640
|
const collectionCategory = category.isCollection ||
|
|
1474
1641
|
(isNil(category.isCollection) && !category.products?.length) ||
|
|
1475
1642
|
category.isWishlist ||
|
|
@@ -1557,6 +1724,18 @@ class CategorySearchStrategy {
|
|
|
1557
1724
|
throw new Error('Category is required for CategorySearchStrategy');
|
|
1558
1725
|
}
|
|
1559
1726
|
const fields = this.helpersService.getFieldsHelper().getStandardFields();
|
|
1727
|
+
if (category.isWishlist) {
|
|
1728
|
+
return this.searchDefault({
|
|
1729
|
+
category,
|
|
1730
|
+
filters,
|
|
1731
|
+
limits,
|
|
1732
|
+
shop,
|
|
1733
|
+
mainGender,
|
|
1734
|
+
sort: sort === 'most-relevant' ? 'best-sellers' : sort,
|
|
1735
|
+
optionsCache,
|
|
1736
|
+
fields,
|
|
1737
|
+
});
|
|
1738
|
+
}
|
|
1560
1739
|
if (sort === 'most-relevant') {
|
|
1561
1740
|
return this.searchWithMostRelevant({
|
|
1562
1741
|
category,
|
|
@@ -1678,8 +1857,12 @@ class CategorySearchStrategy {
|
|
|
1678
1857
|
if (Number.isNaN(createdDate.getTime())) {
|
|
1679
1858
|
return false;
|
|
1680
1859
|
}
|
|
1681
|
-
const
|
|
1682
|
-
|
|
1860
|
+
const diffMs = Date.now() - createdDate.getTime();
|
|
1861
|
+
if (diffMs < 0) {
|
|
1862
|
+
return false;
|
|
1863
|
+
}
|
|
1864
|
+
const diffDays = diffMs / (1000 * 60 * 60 * 24);
|
|
1865
|
+
return diffDays <= days;
|
|
1683
1866
|
}
|
|
1684
1867
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CategorySearchStrategy, deps: [{ token: CatalogRepositoryService }, { token: CatalogHelpersService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1685
1868
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CategorySearchStrategy }); }
|
|
@@ -1875,7 +2058,7 @@ class CatalogServiceFacade {
|
|
|
1875
2058
|
}
|
|
1876
2059
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CatalogServiceFacade, decorators: [{
|
|
1877
2060
|
type: Injectable
|
|
1878
|
-
}], ctorParameters: () => [{ type: CatalogHelpersService }, { type: CatalogStrategiesFacade }, { type:
|
|
2061
|
+
}], ctorParameters: () => [{ type: CatalogHelpersService }, { type: CatalogStrategiesFacade }, { type: i3.Shops, decorators: [{
|
|
1879
2062
|
type: Inject,
|
|
1880
2063
|
args: [DEFAULT_SHOP]
|
|
1881
2064
|
}] }] });
|
|
@@ -1928,7 +2111,7 @@ class CategoryService {
|
|
|
1928
2111
|
}
|
|
1929
2112
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CategoryService, decorators: [{
|
|
1930
2113
|
type: Injectable
|
|
1931
|
-
}], ctorParameters: () => [{ type: CategoryRepositoryFacade }, { type: ProductCatalogFacade }, { type:
|
|
2114
|
+
}], ctorParameters: () => [{ type: CategoryRepositoryFacade }, { type: ProductCatalogFacade }, { type: i3.Shops, decorators: [{
|
|
1932
2115
|
type: Inject,
|
|
1933
2116
|
args: [DEFAULT_SHOP]
|
|
1934
2117
|
}] }] });
|
|
@@ -1966,7 +2149,7 @@ class CategoryServiceFacade {
|
|
|
1966
2149
|
}
|
|
1967
2150
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CategoryServiceFacade, decorators: [{
|
|
1968
2151
|
type: Injectable
|
|
1969
|
-
}], ctorParameters: () => [{ type: CategoryRepositoryFacade }, { type: ProductCatalogFacade }, { type:
|
|
2152
|
+
}], ctorParameters: () => [{ type: CategoryRepositoryFacade }, { type: ProductCatalogFacade }, { type: i3.Shops, decorators: [{
|
|
1970
2153
|
type: Inject,
|
|
1971
2154
|
args: [DEFAULT_SHOP]
|
|
1972
2155
|
}] }] });
|
|
@@ -2348,7 +2531,7 @@ class CatalogService {
|
|
|
2348
2531
|
}
|
|
2349
2532
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CatalogService, decorators: [{
|
|
2350
2533
|
type: Injectable
|
|
2351
|
-
}], ctorParameters: () => [{ type: CatalogSearchContext }, { type: CatalogHelpersService }, { type:
|
|
2534
|
+
}], ctorParameters: () => [{ type: CatalogSearchContext }, { type: CatalogHelpersService }, { type: i3.Shops, decorators: [{
|
|
2352
2535
|
type: Inject,
|
|
2353
2536
|
args: [DEFAULT_SHOP]
|
|
2354
2537
|
}] }] });
|
|
@@ -2619,320 +2802,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImpo
|
|
|
2619
2802
|
}] }, { type: undefined, decorators: [{
|
|
2620
2803
|
type: Inject,
|
|
2621
2804
|
args: ['LogRepository']
|
|
2622
|
-
}] }, { type:
|
|
2805
|
+
}] }, { type: i3.Shops, decorators: [{
|
|
2623
2806
|
type: Inject,
|
|
2624
2807
|
args: [DEFAULT_SHOP]
|
|
2625
2808
|
}] }] });
|
|
2626
2809
|
|
|
2627
|
-
class CouponRepositoriesFacade {
|
|
2628
|
-
constructor(couponRepository, orderRepository, categoryRepository) {
|
|
2629
|
-
this.couponRepository = couponRepository;
|
|
2630
|
-
this.orderRepository = orderRepository;
|
|
2631
|
-
this.categoryRepository = categoryRepository;
|
|
2632
|
-
}
|
|
2633
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CouponRepositoriesFacade, deps: [{ token: 'CouponRepository' }, { token: 'OrderRepository' }, { token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2634
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CouponRepositoriesFacade }); }
|
|
2635
|
-
}
|
|
2636
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CouponRepositoriesFacade, decorators: [{
|
|
2637
|
-
type: Injectable
|
|
2638
|
-
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
2639
|
-
type: Inject,
|
|
2640
|
-
args: ['CouponRepository']
|
|
2641
|
-
}] }, { type: undefined, decorators: [{
|
|
2642
|
-
type: Inject,
|
|
2643
|
-
args: ['OrderRepository']
|
|
2644
|
-
}] }, { type: undefined, decorators: [{
|
|
2645
|
-
type: Inject,
|
|
2646
|
-
args: ['CategoryRepository']
|
|
2647
|
-
}] }] });
|
|
2648
|
-
|
|
2649
|
-
class CouponService {
|
|
2650
|
-
constructor(repositoriesFacade, configurationFacade) {
|
|
2651
|
-
this.repositoriesFacade = repositoriesFacade;
|
|
2652
|
-
this.configurationFacade = configurationFacade;
|
|
2653
|
-
this.emailIsFromCollaborator = (userEmail) => !!userEmail?.match(/@b4a.com.br/g);
|
|
2654
|
-
}
|
|
2655
|
-
checkCoupon(params) {
|
|
2656
|
-
const { nickname, checkoutType, checkout, plan } = params;
|
|
2657
|
-
return from(this.repositoriesFacade.couponRepository
|
|
2658
|
-
.find({
|
|
2659
|
-
filters: {
|
|
2660
|
-
nickname: { operator: Where.EQUALS, value: nickname },
|
|
2661
|
-
active: { operator: Where.EQUALS, value: true },
|
|
2662
|
-
},
|
|
2663
|
-
})
|
|
2664
|
-
.then((result) => result.data[0])).pipe(concatMap((coupon) => this.couponValidation(coupon, checkoutType)), concatMap((couponValid) => this.couponRulesValidation({ coupon: couponValid, checkoutType, checkout, plan })), map((couponValidated) => couponValidated));
|
|
2665
|
-
}
|
|
2666
|
-
async couponValidation(coupon, checkoutType) {
|
|
2667
|
-
if (!coupon)
|
|
2668
|
-
throw 'Cupom inválido.';
|
|
2669
|
-
if (coupon?.beginAt && coupon?.beginAt.getTime() > new Date().getTime())
|
|
2670
|
-
throw 'Cupom inválido.';
|
|
2671
|
-
if (coupon?.expiresIn && (coupon?.expiresIn).getTime() < new Date().getTime())
|
|
2672
|
-
throw 'Cupom expirado.';
|
|
2673
|
-
const isInShop = coupon.shopAvailability === Shops.ALL || coupon.shopAvailability === this.configurationFacade.defaultShop;
|
|
2674
|
-
if (!isInShop)
|
|
2675
|
-
throw 'Cupom inválido para loja.';
|
|
2676
|
-
const isCheckoutType = coupon.checkoutType === CheckoutTypes.ALL || coupon.checkoutType === checkoutType;
|
|
2677
|
-
if (!isCheckoutType)
|
|
2678
|
-
throw 'Cupom inválido. Erro de checkout.';
|
|
2679
|
-
return coupon;
|
|
2680
|
-
}
|
|
2681
|
-
async couponRulesValidation(params) {
|
|
2682
|
-
const { coupon, checkoutType, checkout, plan } = params;
|
|
2683
|
-
if (checkoutType == CheckoutTypes.SUBSCRIPTION) {
|
|
2684
|
-
return this.validateSubscriptionCoupon(coupon, plan);
|
|
2685
|
-
}
|
|
2686
|
-
return this.validateEcommerceCoupon(coupon, checkoutType, checkout);
|
|
2687
|
-
}
|
|
2688
|
-
validateSubscriptionCoupon(coupon, plan) {
|
|
2689
|
-
if (coupon.plan && coupon.plan.toUpperCase() !== plan.toUpperCase()) {
|
|
2690
|
-
throw 'Cupom inválido para sua assinatura.';
|
|
2691
|
-
}
|
|
2692
|
-
return coupon;
|
|
2693
|
-
}
|
|
2694
|
-
async validateEcommerceCoupon(coupon, checkoutType, checkout) {
|
|
2695
|
-
this.validateUserEligibility(coupon, checkout?.user);
|
|
2696
|
-
await this.validateUsageLimits(coupon, checkoutType, checkout);
|
|
2697
|
-
await this.validateProductEligibility(coupon, checkout);
|
|
2698
|
-
return coupon;
|
|
2699
|
-
}
|
|
2700
|
-
validateUserEligibility(coupon, user) {
|
|
2701
|
-
const validUser = this.coupomUserValidation(coupon, user);
|
|
2702
|
-
if (!validUser)
|
|
2703
|
-
throw 'Usuário não elegível.';
|
|
2704
|
-
}
|
|
2705
|
-
async validateUsageLimits(coupon, checkoutType, checkout) {
|
|
2706
|
-
const couponUseLimits = this.getCouponUseLimits(coupon, checkoutType, checkout.user);
|
|
2707
|
-
if (couponUseLimits.firstOrder) {
|
|
2708
|
-
await this.validateFirstOrderLimit(checkout.user.email);
|
|
2709
|
-
}
|
|
2710
|
-
if (!couponUseLimits.unlimited || couponUseLimits.limitedPerUser) {
|
|
2711
|
-
await this.validateCouponUsageLimits(coupon, couponUseLimits, checkout.user.email);
|
|
2712
|
-
}
|
|
2713
|
-
}
|
|
2714
|
-
async validateFirstOrderLimit(userEmail) {
|
|
2715
|
-
const ordersUser = await this.getOrdersFromUser(userEmail.toLocaleLowerCase());
|
|
2716
|
-
if (ordersUser.length >= 1)
|
|
2717
|
-
throw 'Limite de uso atingido';
|
|
2718
|
-
}
|
|
2719
|
-
async validateCouponUsageLimits(coupon, couponUseLimits, userEmail) {
|
|
2720
|
-
const ordersCoupon = await this.getOrdersWithCoupon(coupon);
|
|
2721
|
-
if (!couponUseLimits.unlimited && couponUseLimits.total && ordersCoupon.length >= couponUseLimits.total) {
|
|
2722
|
-
throw 'Limite de uso atingido.';
|
|
2723
|
-
}
|
|
2724
|
-
if (couponUseLimits.limitedPerUser) {
|
|
2725
|
-
const ordersWithUser = this.countOrdersWithUser(ordersCoupon, userEmail);
|
|
2726
|
-
if (ordersWithUser > 0)
|
|
2727
|
-
throw 'Limite de uso por usuário atingido.';
|
|
2728
|
-
}
|
|
2729
|
-
}
|
|
2730
|
-
async validateProductEligibility(coupon, checkout) {
|
|
2731
|
-
const hasProductCategories = await this.hasProductCategories(coupon, checkout);
|
|
2732
|
-
if (!hasProductCategories)
|
|
2733
|
-
throw 'Seu carrinho não possui produtos elegíveis para desconto.';
|
|
2734
|
-
const hasMinSubTotal = await this.hasMinSubTotal(coupon, checkout);
|
|
2735
|
-
if (!hasMinSubTotal) {
|
|
2736
|
-
this.throwMinSubTotalError(coupon);
|
|
2737
|
-
}
|
|
2738
|
-
}
|
|
2739
|
-
throwMinSubTotalError(coupon) {
|
|
2740
|
-
const formattedValue = Intl.NumberFormat('pt-BR', {
|
|
2741
|
-
style: 'currency',
|
|
2742
|
-
currency: 'BRL',
|
|
2743
|
-
}).format(coupon.minSubTotalValue);
|
|
2744
|
-
if (coupon.productsCategories?.length) {
|
|
2745
|
-
throw `Valor mínimo de ${formattedValue} não atingido na(s) categoria(s) elegíveis para o desconto.`;
|
|
2746
|
-
}
|
|
2747
|
-
throw `Valor mínimo de ${formattedValue} não atingido.`;
|
|
2748
|
-
}
|
|
2749
|
-
calcDiscountSubscription(coupon, checkout) {
|
|
2750
|
-
let discount = 0;
|
|
2751
|
-
if (coupon.discount.subscription.type == CouponTypes.ABSOLUTE)
|
|
2752
|
-
discount = coupon.discount.subscription.value;
|
|
2753
|
-
else
|
|
2754
|
-
discount = checkout.subscriptionPlan.recurrencePrice * (coupon.discount.subscription.value / 100);
|
|
2755
|
-
return of(discount);
|
|
2756
|
-
}
|
|
2757
|
-
async hasMinSubTotal(coupon, checkout) {
|
|
2758
|
-
if (!coupon.minSubTotalValue)
|
|
2759
|
-
return true;
|
|
2760
|
-
const lineItensDiscount = await this.getLineItensEligebleForDiscount(coupon.productsCategories, checkout);
|
|
2761
|
-
const subTotal = this.calcCheckoutSubtotal(lineItensDiscount, checkout.user);
|
|
2762
|
-
if (coupon.minSubTotalValue <= subTotal)
|
|
2763
|
-
return true;
|
|
2764
|
-
return false;
|
|
2765
|
-
}
|
|
2766
|
-
async hasProductCategories(coupon, checkout) {
|
|
2767
|
-
if (!coupon.productsCategories?.length) {
|
|
2768
|
-
return true;
|
|
2769
|
-
}
|
|
2770
|
-
const couponCategories = await this.getCouponCategoriesId(coupon.productsCategories);
|
|
2771
|
-
const hasCategories = checkout.lineItems?.filter((item) => {
|
|
2772
|
-
if (item.isGift)
|
|
2773
|
-
return false;
|
|
2774
|
-
if (!item.categories?.length)
|
|
2775
|
-
return true;
|
|
2776
|
-
return item.categories.some((c) => couponCategories.some((cat) => cat == c));
|
|
2777
|
-
});
|
|
2778
|
-
return hasCategories?.length ? true : false;
|
|
2779
|
-
}
|
|
2780
|
-
coupomUserValidation(coupon, user) {
|
|
2781
|
-
if (!user || coupon.exclusivityType.includes(Exclusivities.ALL_USERS))
|
|
2782
|
-
return true;
|
|
2783
|
-
const userTypes = [];
|
|
2784
|
-
if (coupon.exclusivityType.includes(Exclusivities.COLLABORATORS) &&
|
|
2785
|
-
this.emailIsFromCollaborator(user.email.toLocaleLowerCase()))
|
|
2786
|
-
userTypes.push(Exclusivities.COLLABORATORS);
|
|
2787
|
-
if (coupon.exclusivityType.includes(Exclusivities.SPECIFIC_USER) &&
|
|
2788
|
-
coupon.userExclusiveEmail.includes(user.email.toLocaleLowerCase()))
|
|
2789
|
-
userTypes.push(Exclusivities.SPECIFIC_USER);
|
|
2790
|
-
if (coupon.exclusivityType.includes(Exclusivities.ACTIVE_SUBSCRIBER) &&
|
|
2791
|
-
user.isSubscriber &&
|
|
2792
|
-
user.subscriptionPlan != '')
|
|
2793
|
-
userTypes.push(Exclusivities.ACTIVE_SUBSCRIBER);
|
|
2794
|
-
if (user.isSubscriber &&
|
|
2795
|
-
user.subscriptionPlan == '' &&
|
|
2796
|
-
coupon.exclusivityType.includes(Exclusivities.INACTIVE_SUBSCRIBER))
|
|
2797
|
-
userTypes.push(Exclusivities.INACTIVE_SUBSCRIBER);
|
|
2798
|
-
if (coupon.exclusivityType.includes(Exclusivities.NON_SUBSCRIBER) && !user.isSubscriber)
|
|
2799
|
-
userTypes.push(Exclusivities.NON_SUBSCRIBER);
|
|
2800
|
-
return coupon.exclusivityType.some((r) => userTypes.includes(r));
|
|
2801
|
-
}
|
|
2802
|
-
async getCouponCategoriesId(productsCategories) {
|
|
2803
|
-
const couponCategories = [];
|
|
2804
|
-
for (let index = 0; index < productsCategories.length; index++) {
|
|
2805
|
-
const category = await this.repositoriesFacade.categoryRepository.get({
|
|
2806
|
-
id: productsCategories[index],
|
|
2807
|
-
});
|
|
2808
|
-
if (category) {
|
|
2809
|
-
const children = await this.repositoriesFacade.categoryRepository.getChildren(parseInt(productsCategories[index]));
|
|
2810
|
-
couponCategories.push(category.id, ...children.map((c) => c.id.toString()));
|
|
2811
|
-
}
|
|
2812
|
-
}
|
|
2813
|
-
return [...new Set(couponCategories)];
|
|
2814
|
-
}
|
|
2815
|
-
async getLineItensEligebleForDiscount(productsCategories, checkout) {
|
|
2816
|
-
let lineItensDiscount = [];
|
|
2817
|
-
const couponCategories = await this.getCouponCategoriesId(productsCategories);
|
|
2818
|
-
if (productsCategories?.length) {
|
|
2819
|
-
lineItensDiscount = checkout.lineItems?.filter((item) => {
|
|
2820
|
-
if (item.isGift)
|
|
2821
|
-
return false;
|
|
2822
|
-
if (item.categories?.length) {
|
|
2823
|
-
return item.categories.some((c) => couponCategories.some((cat) => cat == c));
|
|
2824
|
-
}
|
|
2825
|
-
return true;
|
|
2826
|
-
});
|
|
2827
|
-
}
|
|
2828
|
-
else {
|
|
2829
|
-
lineItensDiscount = checkout.lineItems.filter((item) => !item.isGift);
|
|
2830
|
-
}
|
|
2831
|
-
return lineItensDiscount;
|
|
2832
|
-
}
|
|
2833
|
-
calcCheckoutSubtotal(lineItens, user) {
|
|
2834
|
-
return (lineItens
|
|
2835
|
-
?.filter((item) => !item.isGift)
|
|
2836
|
-
.reduce((acc, curr) => user?.isSubscriber && curr.price?.subscriberPrice
|
|
2837
|
-
? acc + curr.price?.subscriberPrice * curr.quantity
|
|
2838
|
-
: acc + curr.pricePaid * curr.quantity, 0) || 0);
|
|
2839
|
-
}
|
|
2840
|
-
async getOrdersWithCoupon(coupon) {
|
|
2841
|
-
return await this.repositoriesFacade.orderRepository
|
|
2842
|
-
.find({
|
|
2843
|
-
filters: {
|
|
2844
|
-
coupon: { id: coupon.id },
|
|
2845
|
-
status: { operator: Where.NOTEQUALS, value: OrderStatus.CANCELADO },
|
|
2846
|
-
},
|
|
2847
|
-
})
|
|
2848
|
-
.then((result) => result.data);
|
|
2849
|
-
}
|
|
2850
|
-
async getOrdersFromUser(email) {
|
|
2851
|
-
return await this.repositoriesFacade.orderRepository
|
|
2852
|
-
.find({
|
|
2853
|
-
filters: {
|
|
2854
|
-
user: { email: { operator: Where.EQUALS, value: email } },
|
|
2855
|
-
status: { operator: Where.NOTEQUALS, value: OrderStatus.CANCELADO },
|
|
2856
|
-
},
|
|
2857
|
-
})
|
|
2858
|
-
.then((result) => result.data);
|
|
2859
|
-
}
|
|
2860
|
-
countOrdersWithUser(orders, email) {
|
|
2861
|
-
return orders.filter((o) => o.user.email == email).length;
|
|
2862
|
-
}
|
|
2863
|
-
getCouponUseLimits(coupon, checkoutType, user) {
|
|
2864
|
-
let couponUseLimits;
|
|
2865
|
-
if (checkoutType == CheckoutTypes.ECOMMERCE || checkoutType == CheckoutTypes.ALL) {
|
|
2866
|
-
if (coupon.exclusivityType.length === 1 &&
|
|
2867
|
-
(coupon.exclusivityType.at(0) === Exclusivities.SPECIFIC_USER ||
|
|
2868
|
-
coupon.exclusivityType.at(0) === Exclusivities.COLLABORATORS))
|
|
2869
|
-
couponUseLimits = coupon.useLimits.non_subscriber;
|
|
2870
|
-
else
|
|
2871
|
-
couponUseLimits = user?.isSubscriber ? coupon.useLimits.subscriber : coupon.useLimits.non_subscriber;
|
|
2872
|
-
}
|
|
2873
|
-
else {
|
|
2874
|
-
couponUseLimits = coupon.useLimits.subscription;
|
|
2875
|
-
}
|
|
2876
|
-
return couponUseLimits;
|
|
2877
|
-
}
|
|
2878
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CouponService, deps: [{ token: CouponRepositoriesFacade }, { token: ConfigurationFacade }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2879
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CouponService, providedIn: 'root' }); }
|
|
2880
|
-
}
|
|
2881
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CouponService, decorators: [{
|
|
2882
|
-
type: Injectable,
|
|
2883
|
-
args: [{
|
|
2884
|
-
providedIn: 'root',
|
|
2885
|
-
}]
|
|
2886
|
-
}], ctorParameters: () => [{ type: CouponRepositoriesFacade }, { type: ConfigurationFacade }] });
|
|
2887
|
-
|
|
2888
|
-
class CheckoutSubscriptionService {
|
|
2889
|
-
constructor(checkoutSubscriptionRepository, dataPersistence, couponService) {
|
|
2890
|
-
this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
|
|
2891
|
-
this.dataPersistence = dataPersistence;
|
|
2892
|
-
this.couponService = couponService;
|
|
2893
|
-
}
|
|
2894
|
-
getCheckoutSubscription(checkoutData) {
|
|
2895
|
-
return this.dataPersistence
|
|
2896
|
-
.get('checkoutSubscriptionId')
|
|
2897
|
-
.pipe(concatMap((id) => !isNil(id) ? this.checkoutSubscriptionRepository.get({ id }) : this.createCheckoutSubscription(checkoutData)));
|
|
2898
|
-
}
|
|
2899
|
-
clearCheckoutSubscriptionFromSession() {
|
|
2900
|
-
return this.dataPersistence.remove('checkoutSubscriptionId');
|
|
2901
|
-
}
|
|
2902
|
-
checkCoupon(nickname, _userEmail) {
|
|
2903
|
-
return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService
|
|
2904
|
-
.checkCoupon({
|
|
2905
|
-
nickname,
|
|
2906
|
-
checkoutType: CheckoutTypes.SUBSCRIPTION,
|
|
2907
|
-
checkout,
|
|
2908
|
-
plan: checkout.subscriptionPlan.name,
|
|
2909
|
-
})
|
|
2910
|
-
.pipe()));
|
|
2911
|
-
}
|
|
2912
|
-
calcDiscountSubscription(coupon) {
|
|
2913
|
-
return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService.calcDiscountSubscription(coupon, checkout).pipe()));
|
|
2914
|
-
}
|
|
2915
|
-
async createCheckoutSubscription(checkoutData) {
|
|
2916
|
-
const checkout = await this.checkoutSubscriptionRepository.create({
|
|
2917
|
-
createdAt: new Date(),
|
|
2918
|
-
...CheckoutSubscription.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain(),
|
|
2919
|
-
});
|
|
2920
|
-
await this.dataPersistence.set('checkoutSubscriptionId', checkout.id).toPromise();
|
|
2921
|
-
return checkout;
|
|
2922
|
-
}
|
|
2923
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CheckoutSubscriptionService, deps: [{ token: 'CheckoutSubscriptionRepository' }, { token: PERSISTENCE_PROVIDER }, { token: CouponService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2924
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CheckoutSubscriptionService }); }
|
|
2925
|
-
}
|
|
2926
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CheckoutSubscriptionService, decorators: [{
|
|
2927
|
-
type: Injectable
|
|
2928
|
-
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
2929
|
-
type: Inject,
|
|
2930
|
-
args: ['CheckoutSubscriptionRepository']
|
|
2931
|
-
}] }, { type: undefined, decorators: [{
|
|
2932
|
-
type: Inject,
|
|
2933
|
-
args: [PERSISTENCE_PROVIDER]
|
|
2934
|
-
}] }, { type: CouponService }] });
|
|
2935
|
-
|
|
2936
2810
|
class UtilHelper {
|
|
2937
2811
|
static createSlug(name) {
|
|
2938
2812
|
return name
|
|
@@ -3034,6 +2908,17 @@ class HomeShopService {
|
|
|
3034
2908
|
getMinValueForFreeShipping() {
|
|
3035
2909
|
return this.getHomeConfiguration().pipe(map((home) => home.minValueForFreeShipping));
|
|
3036
2910
|
}
|
|
2911
|
+
/**
|
|
2912
|
+
* Retorna os thresholds de frete grátis estruturados configurados no documento
|
|
2913
|
+
* Home (`shippingThresholds`). Quando o documento ainda não possui essa
|
|
2914
|
+
* estrutura, retorna um default conservador equivalente à regra legada
|
|
2915
|
+
* (edition: 50, avulsoSp: 99, avulsoOutro: null) para que consumidores não
|
|
2916
|
+
* quebrem durante a migração.
|
|
2917
|
+
*/
|
|
2918
|
+
getShippingThresholds() {
|
|
2919
|
+
const conservativeDefault = { edition: 50, avulsoSp: 99, avulsoOutro: null };
|
|
2920
|
+
return this.getHomeConfiguration().pipe(map((home) => home.shippingThresholds ?? conservativeDefault));
|
|
2921
|
+
}
|
|
3037
2922
|
getDiscoverProducts(_gender) {
|
|
3038
2923
|
return this.getHomeConfiguration().pipe(concatMap((home) => from(this.repositoriesFacade.categoryRepository.getCategoriesForHome({
|
|
3039
2924
|
categoryIds: home.discoverCategories,
|
|
@@ -3190,7 +3075,7 @@ class OrderProductReviewService {
|
|
|
3190
3075
|
}
|
|
3191
3076
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: OrderProductReviewService, decorators: [{
|
|
3192
3077
|
type: Injectable
|
|
3193
|
-
}], ctorParameters: () => [{ type:
|
|
3078
|
+
}], ctorParameters: () => [{ type: i3.OrderFirestoreRepository, decorators: [{
|
|
3194
3079
|
type: Inject,
|
|
3195
3080
|
args: ['OrderRepository']
|
|
3196
3081
|
}] }, { type: undefined, decorators: [{
|
|
@@ -3199,11 +3084,77 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImpo
|
|
|
3199
3084
|
}] }, { type: undefined, decorators: [{
|
|
3200
3085
|
type: Inject,
|
|
3201
3086
|
args: ['VariantRepository']
|
|
3202
|
-
}] }, { type:
|
|
3087
|
+
}] }, { type: i3.Shops, decorators: [{
|
|
3203
3088
|
type: Inject,
|
|
3204
3089
|
args: [DEFAULT_SHOP]
|
|
3205
3090
|
}] }] });
|
|
3206
3091
|
|
|
3092
|
+
class OrderRecurrenceService {
|
|
3093
|
+
constructor(shoppingRecurrenceRepository, defaultShop, dependenciesFacade, configurationFacade) {
|
|
3094
|
+
this.shoppingRecurrenceRepository = shoppingRecurrenceRepository;
|
|
3095
|
+
this.defaultShop = defaultShop;
|
|
3096
|
+
this.dependenciesFacade = dependenciesFacade;
|
|
3097
|
+
this.configurationFacade = configurationFacade;
|
|
3098
|
+
this.checkoutUrl = null;
|
|
3099
|
+
this.checkoutUrl = this.configurationFacade.getCheckoutUrl();
|
|
3100
|
+
}
|
|
3101
|
+
getRecurrenceOrder(recurrenceId) {
|
|
3102
|
+
return from(this.shoppingRecurrenceRepository.get({ id: recurrenceId }));
|
|
3103
|
+
}
|
|
3104
|
+
createRecurrenceOrder(recurrencePayload) {
|
|
3105
|
+
return this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/createShoppingRecurrence`, {
|
|
3106
|
+
data: recurrencePayload,
|
|
3107
|
+
});
|
|
3108
|
+
}
|
|
3109
|
+
updatePaymentMethod(data) {
|
|
3110
|
+
return this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/updateShoppingRecurrencePaymentMethod`, {
|
|
3111
|
+
data,
|
|
3112
|
+
});
|
|
3113
|
+
}
|
|
3114
|
+
getRecurrenceAvailableShipping(data) {
|
|
3115
|
+
return this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/getShoppingRecurrenceAvailableShipping`, {
|
|
3116
|
+
data,
|
|
3117
|
+
});
|
|
3118
|
+
}
|
|
3119
|
+
updateShippingAddress(data) {
|
|
3120
|
+
return this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/updateShoppingRecurrenceShippingAddress`, {
|
|
3121
|
+
data,
|
|
3122
|
+
});
|
|
3123
|
+
}
|
|
3124
|
+
cancelRecurrenceOrder(data) {
|
|
3125
|
+
return this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/cancelShoppingRecurrence`, {
|
|
3126
|
+
data,
|
|
3127
|
+
});
|
|
3128
|
+
}
|
|
3129
|
+
enableOrDisableRecurrenceOrder(recurrenceId, active) {
|
|
3130
|
+
const payload = { recurrenceId, active };
|
|
3131
|
+
return this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/enableOrDisableShoppingRecurrence`, payload);
|
|
3132
|
+
}
|
|
3133
|
+
skipRecurrenceOrder(recurrenceEditionId) {
|
|
3134
|
+
const payload = { recurrenceEditionId };
|
|
3135
|
+
return this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/skipShoppingRecurrenceEdition`, payload);
|
|
3136
|
+
}
|
|
3137
|
+
updateFrequency(recurrenceId, frequency) {
|
|
3138
|
+
const payload = { recurrenceId, frequency };
|
|
3139
|
+
return this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/updateShoppingRecurrenceFrequency`, payload);
|
|
3140
|
+
}
|
|
3141
|
+
updateLineItems(recurrenceId, lineItems) {
|
|
3142
|
+
const payload = { recurrenceId, lineItems };
|
|
3143
|
+
return this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/updateShoppingRecurrenceLineItems`, payload);
|
|
3144
|
+
}
|
|
3145
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: OrderRecurrenceService, deps: [{ token: 'ShoppingRecurrenceRepository' }, { token: DEFAULT_SHOP }, { token: CheckoutDependenciesFacade }, { token: ConfigurationFacade }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
3146
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: OrderRecurrenceService }); }
|
|
3147
|
+
}
|
|
3148
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: OrderRecurrenceService, decorators: [{
|
|
3149
|
+
type: Injectable
|
|
3150
|
+
}], ctorParameters: () => [{ type: i3.ShoppingRecurrenceFirestoreRepository, decorators: [{
|
|
3151
|
+
type: Inject,
|
|
3152
|
+
args: ['ShoppingRecurrenceRepository']
|
|
3153
|
+
}] }, { type: i3.Shops, decorators: [{
|
|
3154
|
+
type: Inject,
|
|
3155
|
+
args: [DEFAULT_SHOP]
|
|
3156
|
+
}] }, { type: CheckoutDependenciesFacade }, { type: ConfigurationFacade }] });
|
|
3157
|
+
|
|
3207
3158
|
class OrderService {
|
|
3208
3159
|
constructor(angularFirestore, orderRepository) {
|
|
3209
3160
|
this.angularFirestore = angularFirestore;
|
|
@@ -3216,16 +3167,38 @@ class OrderService {
|
|
|
3216
3167
|
.subscribe((doc) => this.orderSubject.next(doc));
|
|
3217
3168
|
return this.orderSubject;
|
|
3218
3169
|
}
|
|
3219
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: OrderService, deps: [{ token: i1$
|
|
3170
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: OrderService, deps: [{ token: i1$2.Firestore }, { token: 'OrderRepository' }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
3220
3171
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: OrderService }); }
|
|
3221
3172
|
}
|
|
3222
3173
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: OrderService, decorators: [{
|
|
3223
3174
|
type: Injectable
|
|
3224
|
-
}], ctorParameters: () => [{ type: i1$
|
|
3175
|
+
}], ctorParameters: () => [{ type: i1$2.Firestore }, { type: i3.OrderFirestoreRepository, decorators: [{
|
|
3225
3176
|
type: Inject,
|
|
3226
3177
|
args: ['OrderRepository']
|
|
3227
3178
|
}] }] });
|
|
3228
3179
|
|
|
3180
|
+
class CouponRepositoriesFacade {
|
|
3181
|
+
constructor(couponRepository, orderRepository, categoryRepository) {
|
|
3182
|
+
this.couponRepository = couponRepository;
|
|
3183
|
+
this.orderRepository = orderRepository;
|
|
3184
|
+
this.categoryRepository = categoryRepository;
|
|
3185
|
+
}
|
|
3186
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CouponRepositoriesFacade, deps: [{ token: 'CouponRepository' }, { token: 'OrderRepository' }, { token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
3187
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CouponRepositoriesFacade }); }
|
|
3188
|
+
}
|
|
3189
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CouponRepositoriesFacade, decorators: [{
|
|
3190
|
+
type: Injectable
|
|
3191
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
3192
|
+
type: Inject,
|
|
3193
|
+
args: ['CouponRepository']
|
|
3194
|
+
}] }, { type: undefined, decorators: [{
|
|
3195
|
+
type: Inject,
|
|
3196
|
+
args: ['OrderRepository']
|
|
3197
|
+
}] }, { type: undefined, decorators: [{
|
|
3198
|
+
type: Inject,
|
|
3199
|
+
args: ['CategoryRepository']
|
|
3200
|
+
}] }] });
|
|
3201
|
+
|
|
3229
3202
|
class AngularConnectModule {
|
|
3230
3203
|
static initializeApp(defaultShop, options, nameOrConfig) {
|
|
3231
3204
|
return {
|
|
@@ -3308,8 +3281,6 @@ class AngularConnectModule {
|
|
|
3308
3281
|
CatalogService,
|
|
3309
3282
|
CategoryService,
|
|
3310
3283
|
CheckoutService,
|
|
3311
|
-
CheckoutSubscriptionService,
|
|
3312
|
-
CouponService,
|
|
3313
3284
|
HomeShopService,
|
|
3314
3285
|
OrderService,
|
|
3315
3286
|
WishlistService,
|
|
@@ -3370,6 +3341,7 @@ class AngularConnectModule {
|
|
|
3370
3341
|
CouponRepositoriesFacade,
|
|
3371
3342
|
HomeShopRepositoriesFacade,
|
|
3372
3343
|
OrderProductReviewService,
|
|
3344
|
+
OrderRecurrenceService,
|
|
3373
3345
|
], imports: [AngularElasticSeachModule,
|
|
3374
3346
|
AngularVertexSeachModule,
|
|
3375
3347
|
AngularFirebaseAuthModule,
|
|
@@ -3422,8 +3394,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImpo
|
|
|
3422
3394
|
CatalogService,
|
|
3423
3395
|
CategoryService,
|
|
3424
3396
|
CheckoutService,
|
|
3425
|
-
CheckoutSubscriptionService,
|
|
3426
|
-
CouponService,
|
|
3427
3397
|
HomeShopService,
|
|
3428
3398
|
OrderService,
|
|
3429
3399
|
WishlistService,
|
|
@@ -3484,6 +3454,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImpo
|
|
|
3484
3454
|
CouponRepositoriesFacade,
|
|
3485
3455
|
HomeShopRepositoriesFacade,
|
|
3486
3456
|
OrderProductReviewService,
|
|
3457
|
+
OrderRecurrenceService,
|
|
3487
3458
|
],
|
|
3488
3459
|
}]
|
|
3489
3460
|
}] });
|
|
@@ -3492,5 +3463,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImpo
|
|
|
3492
3463
|
* Generated bundle index. Do not edit.
|
|
3493
3464
|
*/
|
|
3494
3465
|
|
|
3495
|
-
export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule, AuthService, CartService, CatalogService, CategoryService, CategoryWithTree, CheckoutService,
|
|
3466
|
+
export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule, AuthService, CartService, CatalogService, CategoryService, CategoryWithTree, CheckoutService, CookieDataPersistence, HomeShopService, NewCategoryStructureAdapter, OldCategoryStructureAdapter, OrderProductReviewService, OrderRecurrenceService, OrderService, ProductSorts, UtilHelper, WishlistService };
|
|
3496
3467
|
//# sourceMappingURL=infrab4a-connect-angular.mjs.map
|