@infrab4a/connect-angular 5.7.5-beta.0 → 5.7.5-beta.10
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) {
|
|
@@ -1861,7 +2025,7 @@ class CatalogServiceFacade {
|
|
|
1861
2025
|
}
|
|
1862
2026
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CatalogServiceFacade, decorators: [{
|
|
1863
2027
|
type: Injectable
|
|
1864
|
-
}], ctorParameters: () => [{ type: CatalogHelpersService }, { type: CatalogStrategiesFacade }, { type:
|
|
2028
|
+
}], ctorParameters: () => [{ type: CatalogHelpersService }, { type: CatalogStrategiesFacade }, { type: i3.Shops, decorators: [{
|
|
1865
2029
|
type: Inject,
|
|
1866
2030
|
args: [DEFAULT_SHOP]
|
|
1867
2031
|
}] }] });
|
|
@@ -1914,7 +2078,7 @@ class CategoryService {
|
|
|
1914
2078
|
}
|
|
1915
2079
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CategoryService, decorators: [{
|
|
1916
2080
|
type: Injectable
|
|
1917
|
-
}], ctorParameters: () => [{ type: CategoryRepositoryFacade }, { type: ProductCatalogFacade }, { type:
|
|
2081
|
+
}], ctorParameters: () => [{ type: CategoryRepositoryFacade }, { type: ProductCatalogFacade }, { type: i3.Shops, decorators: [{
|
|
1918
2082
|
type: Inject,
|
|
1919
2083
|
args: [DEFAULT_SHOP]
|
|
1920
2084
|
}] }] });
|
|
@@ -1952,7 +2116,7 @@ class CategoryServiceFacade {
|
|
|
1952
2116
|
}
|
|
1953
2117
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CategoryServiceFacade, decorators: [{
|
|
1954
2118
|
type: Injectable
|
|
1955
|
-
}], ctorParameters: () => [{ type: CategoryRepositoryFacade }, { type: ProductCatalogFacade }, { type:
|
|
2119
|
+
}], ctorParameters: () => [{ type: CategoryRepositoryFacade }, { type: ProductCatalogFacade }, { type: i3.Shops, decorators: [{
|
|
1956
2120
|
type: Inject,
|
|
1957
2121
|
args: [DEFAULT_SHOP]
|
|
1958
2122
|
}] }] });
|
|
@@ -2334,7 +2498,7 @@ class CatalogService {
|
|
|
2334
2498
|
}
|
|
2335
2499
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CatalogService, decorators: [{
|
|
2336
2500
|
type: Injectable
|
|
2337
|
-
}], ctorParameters: () => [{ type: CatalogSearchContext }, { type: CatalogHelpersService }, { type:
|
|
2501
|
+
}], ctorParameters: () => [{ type: CatalogSearchContext }, { type: CatalogHelpersService }, { type: i3.Shops, decorators: [{
|
|
2338
2502
|
type: Inject,
|
|
2339
2503
|
args: [DEFAULT_SHOP]
|
|
2340
2504
|
}] }] });
|
|
@@ -2605,320 +2769,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImpo
|
|
|
2605
2769
|
}] }, { type: undefined, decorators: [{
|
|
2606
2770
|
type: Inject,
|
|
2607
2771
|
args: ['LogRepository']
|
|
2608
|
-
}] }, { type:
|
|
2772
|
+
}] }, { type: i3.Shops, decorators: [{
|
|
2609
2773
|
type: Inject,
|
|
2610
2774
|
args: [DEFAULT_SHOP]
|
|
2611
2775
|
}] }] });
|
|
2612
2776
|
|
|
2613
|
-
class CouponRepositoriesFacade {
|
|
2614
|
-
constructor(couponRepository, orderRepository, categoryRepository) {
|
|
2615
|
-
this.couponRepository = couponRepository;
|
|
2616
|
-
this.orderRepository = orderRepository;
|
|
2617
|
-
this.categoryRepository = categoryRepository;
|
|
2618
|
-
}
|
|
2619
|
-
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 }); }
|
|
2620
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CouponRepositoriesFacade }); }
|
|
2621
|
-
}
|
|
2622
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CouponRepositoriesFacade, decorators: [{
|
|
2623
|
-
type: Injectable
|
|
2624
|
-
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
2625
|
-
type: Inject,
|
|
2626
|
-
args: ['CouponRepository']
|
|
2627
|
-
}] }, { type: undefined, decorators: [{
|
|
2628
|
-
type: Inject,
|
|
2629
|
-
args: ['OrderRepository']
|
|
2630
|
-
}] }, { type: undefined, decorators: [{
|
|
2631
|
-
type: Inject,
|
|
2632
|
-
args: ['CategoryRepository']
|
|
2633
|
-
}] }] });
|
|
2634
|
-
|
|
2635
|
-
class CouponService {
|
|
2636
|
-
constructor(repositoriesFacade, configurationFacade) {
|
|
2637
|
-
this.repositoriesFacade = repositoriesFacade;
|
|
2638
|
-
this.configurationFacade = configurationFacade;
|
|
2639
|
-
this.emailIsFromCollaborator = (userEmail) => !!userEmail?.match(/@b4a.com.br/g);
|
|
2640
|
-
}
|
|
2641
|
-
checkCoupon(params) {
|
|
2642
|
-
const { nickname, checkoutType, checkout, plan } = params;
|
|
2643
|
-
return from(this.repositoriesFacade.couponRepository
|
|
2644
|
-
.find({
|
|
2645
|
-
filters: {
|
|
2646
|
-
nickname: { operator: Where.EQUALS, value: nickname },
|
|
2647
|
-
active: { operator: Where.EQUALS, value: true },
|
|
2648
|
-
},
|
|
2649
|
-
})
|
|
2650
|
-
.then((result) => result.data[0])).pipe(concatMap((coupon) => this.couponValidation(coupon, checkoutType)), concatMap((couponValid) => this.couponRulesValidation({ coupon: couponValid, checkoutType, checkout, plan })), map((couponValidated) => couponValidated));
|
|
2651
|
-
}
|
|
2652
|
-
async couponValidation(coupon, checkoutType) {
|
|
2653
|
-
if (!coupon)
|
|
2654
|
-
throw 'Cupom inválido.';
|
|
2655
|
-
if (coupon?.beginAt && coupon?.beginAt.getTime() > new Date().getTime())
|
|
2656
|
-
throw 'Cupom inválido.';
|
|
2657
|
-
if (coupon?.expiresIn && (coupon?.expiresIn).getTime() < new Date().getTime())
|
|
2658
|
-
throw 'Cupom expirado.';
|
|
2659
|
-
const isInShop = coupon.shopAvailability === Shops.ALL || coupon.shopAvailability === this.configurationFacade.defaultShop;
|
|
2660
|
-
if (!isInShop)
|
|
2661
|
-
throw 'Cupom inválido para loja.';
|
|
2662
|
-
const isCheckoutType = coupon.checkoutType === CheckoutTypes.ALL || coupon.checkoutType === checkoutType;
|
|
2663
|
-
if (!isCheckoutType)
|
|
2664
|
-
throw 'Cupom inválido. Erro de checkout.';
|
|
2665
|
-
return coupon;
|
|
2666
|
-
}
|
|
2667
|
-
async couponRulesValidation(params) {
|
|
2668
|
-
const { coupon, checkoutType, checkout, plan } = params;
|
|
2669
|
-
if (checkoutType == CheckoutTypes.SUBSCRIPTION) {
|
|
2670
|
-
return this.validateSubscriptionCoupon(coupon, plan);
|
|
2671
|
-
}
|
|
2672
|
-
return this.validateEcommerceCoupon(coupon, checkoutType, checkout);
|
|
2673
|
-
}
|
|
2674
|
-
validateSubscriptionCoupon(coupon, plan) {
|
|
2675
|
-
if (coupon.plan && coupon.plan.toUpperCase() !== plan.toUpperCase()) {
|
|
2676
|
-
throw 'Cupom inválido para sua assinatura.';
|
|
2677
|
-
}
|
|
2678
|
-
return coupon;
|
|
2679
|
-
}
|
|
2680
|
-
async validateEcommerceCoupon(coupon, checkoutType, checkout) {
|
|
2681
|
-
this.validateUserEligibility(coupon, checkout?.user);
|
|
2682
|
-
await this.validateUsageLimits(coupon, checkoutType, checkout);
|
|
2683
|
-
await this.validateProductEligibility(coupon, checkout);
|
|
2684
|
-
return coupon;
|
|
2685
|
-
}
|
|
2686
|
-
validateUserEligibility(coupon, user) {
|
|
2687
|
-
const validUser = this.coupomUserValidation(coupon, user);
|
|
2688
|
-
if (!validUser)
|
|
2689
|
-
throw 'Usuário não elegível.';
|
|
2690
|
-
}
|
|
2691
|
-
async validateUsageLimits(coupon, checkoutType, checkout) {
|
|
2692
|
-
const couponUseLimits = this.getCouponUseLimits(coupon, checkoutType, checkout.user);
|
|
2693
|
-
if (couponUseLimits.firstOrder) {
|
|
2694
|
-
await this.validateFirstOrderLimit(checkout.user.email);
|
|
2695
|
-
}
|
|
2696
|
-
if (!couponUseLimits.unlimited || couponUseLimits.limitedPerUser) {
|
|
2697
|
-
await this.validateCouponUsageLimits(coupon, couponUseLimits, checkout.user.email);
|
|
2698
|
-
}
|
|
2699
|
-
}
|
|
2700
|
-
async validateFirstOrderLimit(userEmail) {
|
|
2701
|
-
const ordersUser = await this.getOrdersFromUser(userEmail.toLocaleLowerCase());
|
|
2702
|
-
if (ordersUser.length >= 1)
|
|
2703
|
-
throw 'Limite de uso atingido';
|
|
2704
|
-
}
|
|
2705
|
-
async validateCouponUsageLimits(coupon, couponUseLimits, userEmail) {
|
|
2706
|
-
const ordersCoupon = await this.getOrdersWithCoupon(coupon);
|
|
2707
|
-
if (!couponUseLimits.unlimited && couponUseLimits.total && ordersCoupon.length >= couponUseLimits.total) {
|
|
2708
|
-
throw 'Limite de uso atingido.';
|
|
2709
|
-
}
|
|
2710
|
-
if (couponUseLimits.limitedPerUser) {
|
|
2711
|
-
const ordersWithUser = this.countOrdersWithUser(ordersCoupon, userEmail);
|
|
2712
|
-
if (ordersWithUser > 0)
|
|
2713
|
-
throw 'Limite de uso por usuário atingido.';
|
|
2714
|
-
}
|
|
2715
|
-
}
|
|
2716
|
-
async validateProductEligibility(coupon, checkout) {
|
|
2717
|
-
const hasProductCategories = await this.hasProductCategories(coupon, checkout);
|
|
2718
|
-
if (!hasProductCategories)
|
|
2719
|
-
throw 'Seu carrinho não possui produtos elegíveis para desconto.';
|
|
2720
|
-
const hasMinSubTotal = await this.hasMinSubTotal(coupon, checkout);
|
|
2721
|
-
if (!hasMinSubTotal) {
|
|
2722
|
-
this.throwMinSubTotalError(coupon);
|
|
2723
|
-
}
|
|
2724
|
-
}
|
|
2725
|
-
throwMinSubTotalError(coupon) {
|
|
2726
|
-
const formattedValue = Intl.NumberFormat('pt-BR', {
|
|
2727
|
-
style: 'currency',
|
|
2728
|
-
currency: 'BRL',
|
|
2729
|
-
}).format(coupon.minSubTotalValue);
|
|
2730
|
-
if (coupon.productsCategories?.length) {
|
|
2731
|
-
throw `Valor mínimo de ${formattedValue} não atingido na(s) categoria(s) elegíveis para o desconto.`;
|
|
2732
|
-
}
|
|
2733
|
-
throw `Valor mínimo de ${formattedValue} não atingido.`;
|
|
2734
|
-
}
|
|
2735
|
-
calcDiscountSubscription(coupon, checkout) {
|
|
2736
|
-
let discount = 0;
|
|
2737
|
-
if (coupon.discount.subscription.type == CouponTypes.ABSOLUTE)
|
|
2738
|
-
discount = coupon.discount.subscription.value;
|
|
2739
|
-
else
|
|
2740
|
-
discount = checkout.subscriptionPlan.recurrencePrice * (coupon.discount.subscription.value / 100);
|
|
2741
|
-
return of(discount);
|
|
2742
|
-
}
|
|
2743
|
-
async hasMinSubTotal(coupon, checkout) {
|
|
2744
|
-
if (!coupon.minSubTotalValue)
|
|
2745
|
-
return true;
|
|
2746
|
-
const lineItensDiscount = await this.getLineItensEligebleForDiscount(coupon.productsCategories, checkout);
|
|
2747
|
-
const subTotal = this.calcCheckoutSubtotal(lineItensDiscount, checkout.user);
|
|
2748
|
-
if (coupon.minSubTotalValue <= subTotal)
|
|
2749
|
-
return true;
|
|
2750
|
-
return false;
|
|
2751
|
-
}
|
|
2752
|
-
async hasProductCategories(coupon, checkout) {
|
|
2753
|
-
if (!coupon.productsCategories?.length) {
|
|
2754
|
-
return true;
|
|
2755
|
-
}
|
|
2756
|
-
const couponCategories = await this.getCouponCategoriesId(coupon.productsCategories);
|
|
2757
|
-
const hasCategories = checkout.lineItems?.filter((item) => {
|
|
2758
|
-
if (item.isGift)
|
|
2759
|
-
return false;
|
|
2760
|
-
if (!item.categories?.length)
|
|
2761
|
-
return true;
|
|
2762
|
-
return item.categories.some((c) => couponCategories.some((cat) => cat == c));
|
|
2763
|
-
});
|
|
2764
|
-
return hasCategories?.length ? true : false;
|
|
2765
|
-
}
|
|
2766
|
-
coupomUserValidation(coupon, user) {
|
|
2767
|
-
if (!user || coupon.exclusivityType.includes(Exclusivities.ALL_USERS))
|
|
2768
|
-
return true;
|
|
2769
|
-
const userTypes = [];
|
|
2770
|
-
if (coupon.exclusivityType.includes(Exclusivities.COLLABORATORS) &&
|
|
2771
|
-
this.emailIsFromCollaborator(user.email.toLocaleLowerCase()))
|
|
2772
|
-
userTypes.push(Exclusivities.COLLABORATORS);
|
|
2773
|
-
if (coupon.exclusivityType.includes(Exclusivities.SPECIFIC_USER) &&
|
|
2774
|
-
coupon.userExclusiveEmail.includes(user.email.toLocaleLowerCase()))
|
|
2775
|
-
userTypes.push(Exclusivities.SPECIFIC_USER);
|
|
2776
|
-
if (coupon.exclusivityType.includes(Exclusivities.ACTIVE_SUBSCRIBER) &&
|
|
2777
|
-
user.isSubscriber &&
|
|
2778
|
-
user.subscriptionPlan != '')
|
|
2779
|
-
userTypes.push(Exclusivities.ACTIVE_SUBSCRIBER);
|
|
2780
|
-
if (user.isSubscriber &&
|
|
2781
|
-
user.subscriptionPlan == '' &&
|
|
2782
|
-
coupon.exclusivityType.includes(Exclusivities.INACTIVE_SUBSCRIBER))
|
|
2783
|
-
userTypes.push(Exclusivities.INACTIVE_SUBSCRIBER);
|
|
2784
|
-
if (coupon.exclusivityType.includes(Exclusivities.NON_SUBSCRIBER) && !user.isSubscriber)
|
|
2785
|
-
userTypes.push(Exclusivities.NON_SUBSCRIBER);
|
|
2786
|
-
return coupon.exclusivityType.some((r) => userTypes.includes(r));
|
|
2787
|
-
}
|
|
2788
|
-
async getCouponCategoriesId(productsCategories) {
|
|
2789
|
-
const couponCategories = [];
|
|
2790
|
-
for (let index = 0; index < productsCategories.length; index++) {
|
|
2791
|
-
const category = await this.repositoriesFacade.categoryRepository.get({
|
|
2792
|
-
id: productsCategories[index],
|
|
2793
|
-
});
|
|
2794
|
-
if (category) {
|
|
2795
|
-
const children = await this.repositoriesFacade.categoryRepository.getChildren(parseInt(productsCategories[index]));
|
|
2796
|
-
couponCategories.push(category.id, ...children.map((c) => c.id.toString()));
|
|
2797
|
-
}
|
|
2798
|
-
}
|
|
2799
|
-
return [...new Set(couponCategories)];
|
|
2800
|
-
}
|
|
2801
|
-
async getLineItensEligebleForDiscount(productsCategories, checkout) {
|
|
2802
|
-
let lineItensDiscount = [];
|
|
2803
|
-
const couponCategories = await this.getCouponCategoriesId(productsCategories);
|
|
2804
|
-
if (productsCategories?.length) {
|
|
2805
|
-
lineItensDiscount = checkout.lineItems?.filter((item) => {
|
|
2806
|
-
if (item.isGift)
|
|
2807
|
-
return false;
|
|
2808
|
-
if (item.categories?.length) {
|
|
2809
|
-
return item.categories.some((c) => couponCategories.some((cat) => cat == c));
|
|
2810
|
-
}
|
|
2811
|
-
return true;
|
|
2812
|
-
});
|
|
2813
|
-
}
|
|
2814
|
-
else {
|
|
2815
|
-
lineItensDiscount = checkout.lineItems.filter((item) => !item.isGift);
|
|
2816
|
-
}
|
|
2817
|
-
return lineItensDiscount;
|
|
2818
|
-
}
|
|
2819
|
-
calcCheckoutSubtotal(lineItens, user) {
|
|
2820
|
-
return (lineItens
|
|
2821
|
-
?.filter((item) => !item.isGift)
|
|
2822
|
-
.reduce((acc, curr) => user?.isSubscriber && curr.price?.subscriberPrice
|
|
2823
|
-
? acc + curr.price?.subscriberPrice * curr.quantity
|
|
2824
|
-
: acc + curr.pricePaid * curr.quantity, 0) || 0);
|
|
2825
|
-
}
|
|
2826
|
-
async getOrdersWithCoupon(coupon) {
|
|
2827
|
-
return await this.repositoriesFacade.orderRepository
|
|
2828
|
-
.find({
|
|
2829
|
-
filters: {
|
|
2830
|
-
coupon: { id: coupon.id },
|
|
2831
|
-
status: { operator: Where.NOTEQUALS, value: OrderStatus.CANCELADO },
|
|
2832
|
-
},
|
|
2833
|
-
})
|
|
2834
|
-
.then((result) => result.data);
|
|
2835
|
-
}
|
|
2836
|
-
async getOrdersFromUser(email) {
|
|
2837
|
-
return await this.repositoriesFacade.orderRepository
|
|
2838
|
-
.find({
|
|
2839
|
-
filters: {
|
|
2840
|
-
user: { email: { operator: Where.EQUALS, value: email } },
|
|
2841
|
-
status: { operator: Where.NOTEQUALS, value: OrderStatus.CANCELADO },
|
|
2842
|
-
},
|
|
2843
|
-
})
|
|
2844
|
-
.then((result) => result.data);
|
|
2845
|
-
}
|
|
2846
|
-
countOrdersWithUser(orders, email) {
|
|
2847
|
-
return orders.filter((o) => o.user.email == email).length;
|
|
2848
|
-
}
|
|
2849
|
-
getCouponUseLimits(coupon, checkoutType, user) {
|
|
2850
|
-
let couponUseLimits;
|
|
2851
|
-
if (checkoutType == CheckoutTypes.ECOMMERCE || checkoutType == CheckoutTypes.ALL) {
|
|
2852
|
-
if (coupon.exclusivityType.length === 1 &&
|
|
2853
|
-
(coupon.exclusivityType.at(0) === Exclusivities.SPECIFIC_USER ||
|
|
2854
|
-
coupon.exclusivityType.at(0) === Exclusivities.COLLABORATORS))
|
|
2855
|
-
couponUseLimits = coupon.useLimits.non_subscriber;
|
|
2856
|
-
else
|
|
2857
|
-
couponUseLimits = user?.isSubscriber ? coupon.useLimits.subscriber : coupon.useLimits.non_subscriber;
|
|
2858
|
-
}
|
|
2859
|
-
else {
|
|
2860
|
-
couponUseLimits = coupon.useLimits.subscription;
|
|
2861
|
-
}
|
|
2862
|
-
return couponUseLimits;
|
|
2863
|
-
}
|
|
2864
|
-
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 }); }
|
|
2865
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CouponService, providedIn: 'root' }); }
|
|
2866
|
-
}
|
|
2867
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CouponService, decorators: [{
|
|
2868
|
-
type: Injectable,
|
|
2869
|
-
args: [{
|
|
2870
|
-
providedIn: 'root',
|
|
2871
|
-
}]
|
|
2872
|
-
}], ctorParameters: () => [{ type: CouponRepositoriesFacade }, { type: ConfigurationFacade }] });
|
|
2873
|
-
|
|
2874
|
-
class CheckoutSubscriptionService {
|
|
2875
|
-
constructor(checkoutSubscriptionRepository, dataPersistence, couponService) {
|
|
2876
|
-
this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
|
|
2877
|
-
this.dataPersistence = dataPersistence;
|
|
2878
|
-
this.couponService = couponService;
|
|
2879
|
-
}
|
|
2880
|
-
getCheckoutSubscription(checkoutData) {
|
|
2881
|
-
return this.dataPersistence
|
|
2882
|
-
.get('checkoutSubscriptionId')
|
|
2883
|
-
.pipe(concatMap((id) => !isNil(id) ? this.checkoutSubscriptionRepository.get({ id }) : this.createCheckoutSubscription(checkoutData)));
|
|
2884
|
-
}
|
|
2885
|
-
clearCheckoutSubscriptionFromSession() {
|
|
2886
|
-
return this.dataPersistence.remove('checkoutSubscriptionId');
|
|
2887
|
-
}
|
|
2888
|
-
checkCoupon(nickname, _userEmail) {
|
|
2889
|
-
return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService
|
|
2890
|
-
.checkCoupon({
|
|
2891
|
-
nickname,
|
|
2892
|
-
checkoutType: CheckoutTypes.SUBSCRIPTION,
|
|
2893
|
-
checkout,
|
|
2894
|
-
plan: checkout.subscriptionPlan.name,
|
|
2895
|
-
})
|
|
2896
|
-
.pipe()));
|
|
2897
|
-
}
|
|
2898
|
-
calcDiscountSubscription(coupon) {
|
|
2899
|
-
return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService.calcDiscountSubscription(coupon, checkout).pipe()));
|
|
2900
|
-
}
|
|
2901
|
-
async createCheckoutSubscription(checkoutData) {
|
|
2902
|
-
const checkout = await this.checkoutSubscriptionRepository.create({
|
|
2903
|
-
createdAt: new Date(),
|
|
2904
|
-
...CheckoutSubscription.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain(),
|
|
2905
|
-
});
|
|
2906
|
-
await this.dataPersistence.set('checkoutSubscriptionId', checkout.id).toPromise();
|
|
2907
|
-
return checkout;
|
|
2908
|
-
}
|
|
2909
|
-
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 }); }
|
|
2910
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CheckoutSubscriptionService }); }
|
|
2911
|
-
}
|
|
2912
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CheckoutSubscriptionService, decorators: [{
|
|
2913
|
-
type: Injectable
|
|
2914
|
-
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
2915
|
-
type: Inject,
|
|
2916
|
-
args: ['CheckoutSubscriptionRepository']
|
|
2917
|
-
}] }, { type: undefined, decorators: [{
|
|
2918
|
-
type: Inject,
|
|
2919
|
-
args: [PERSISTENCE_PROVIDER]
|
|
2920
|
-
}] }, { type: CouponService }] });
|
|
2921
|
-
|
|
2922
2777
|
class UtilHelper {
|
|
2923
2778
|
static createSlug(name) {
|
|
2924
2779
|
return name
|
|
@@ -3020,6 +2875,17 @@ class HomeShopService {
|
|
|
3020
2875
|
getMinValueForFreeShipping() {
|
|
3021
2876
|
return this.getHomeConfiguration().pipe(map((home) => home.minValueForFreeShipping));
|
|
3022
2877
|
}
|
|
2878
|
+
/**
|
|
2879
|
+
* Retorna os thresholds de frete grátis estruturados configurados no documento
|
|
2880
|
+
* Home (`shippingThresholds`). Quando o documento ainda não possui essa
|
|
2881
|
+
* estrutura, retorna um default conservador equivalente à regra legada
|
|
2882
|
+
* (edition: 50, avulsoSp: 99, avulsoOutro: null) para que consumidores não
|
|
2883
|
+
* quebrem durante a migração.
|
|
2884
|
+
*/
|
|
2885
|
+
getShippingThresholds() {
|
|
2886
|
+
const conservativeDefault = { edition: 50, avulsoSp: 99, avulsoOutro: null };
|
|
2887
|
+
return this.getHomeConfiguration().pipe(map((home) => home.shippingThresholds ?? conservativeDefault));
|
|
2888
|
+
}
|
|
3023
2889
|
getDiscoverProducts(_gender) {
|
|
3024
2890
|
return this.getHomeConfiguration().pipe(concatMap((home) => from(this.repositoriesFacade.categoryRepository.getCategoriesForHome({
|
|
3025
2891
|
categoryIds: home.discoverCategories,
|
|
@@ -3176,7 +3042,7 @@ class OrderProductReviewService {
|
|
|
3176
3042
|
}
|
|
3177
3043
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: OrderProductReviewService, decorators: [{
|
|
3178
3044
|
type: Injectable
|
|
3179
|
-
}], ctorParameters: () => [{ type:
|
|
3045
|
+
}], ctorParameters: () => [{ type: i3.OrderFirestoreRepository, decorators: [{
|
|
3180
3046
|
type: Inject,
|
|
3181
3047
|
args: ['OrderRepository']
|
|
3182
3048
|
}] }, { type: undefined, decorators: [{
|
|
@@ -3185,11 +3051,77 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImpo
|
|
|
3185
3051
|
}] }, { type: undefined, decorators: [{
|
|
3186
3052
|
type: Inject,
|
|
3187
3053
|
args: ['VariantRepository']
|
|
3188
|
-
}] }, { type:
|
|
3054
|
+
}] }, { type: i3.Shops, decorators: [{
|
|
3189
3055
|
type: Inject,
|
|
3190
3056
|
args: [DEFAULT_SHOP]
|
|
3191
3057
|
}] }] });
|
|
3192
3058
|
|
|
3059
|
+
class OrderRecurrenceService {
|
|
3060
|
+
constructor(shoppingRecurrenceRepository, defaultShop, dependenciesFacade, configurationFacade) {
|
|
3061
|
+
this.shoppingRecurrenceRepository = shoppingRecurrenceRepository;
|
|
3062
|
+
this.defaultShop = defaultShop;
|
|
3063
|
+
this.dependenciesFacade = dependenciesFacade;
|
|
3064
|
+
this.configurationFacade = configurationFacade;
|
|
3065
|
+
this.checkoutUrl = null;
|
|
3066
|
+
this.checkoutUrl = this.configurationFacade.getCheckoutUrl();
|
|
3067
|
+
}
|
|
3068
|
+
getRecurrenceOrder(recurrenceId) {
|
|
3069
|
+
return from(this.shoppingRecurrenceRepository.get({ id: recurrenceId }));
|
|
3070
|
+
}
|
|
3071
|
+
createRecurrenceOrder(recurrencePayload) {
|
|
3072
|
+
return this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/createShoppingRecurrence`, {
|
|
3073
|
+
data: recurrencePayload,
|
|
3074
|
+
});
|
|
3075
|
+
}
|
|
3076
|
+
updatePaymentMethod(data) {
|
|
3077
|
+
return this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/updateShoppingRecurrencePaymentMethod`, {
|
|
3078
|
+
data,
|
|
3079
|
+
});
|
|
3080
|
+
}
|
|
3081
|
+
getRecurrenceAvailableShipping(data) {
|
|
3082
|
+
return this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/getShoppingRecurrenceAvailableShipping`, {
|
|
3083
|
+
data,
|
|
3084
|
+
});
|
|
3085
|
+
}
|
|
3086
|
+
updateShippingAddress(data) {
|
|
3087
|
+
return this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/updateShoppingRecurrenceShippingAddress`, {
|
|
3088
|
+
data,
|
|
3089
|
+
});
|
|
3090
|
+
}
|
|
3091
|
+
cancelRecurrenceOrder(data) {
|
|
3092
|
+
return this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/cancelShoppingRecurrence`, {
|
|
3093
|
+
data,
|
|
3094
|
+
});
|
|
3095
|
+
}
|
|
3096
|
+
enableOrDisableRecurrenceOrder(recurrenceId, active) {
|
|
3097
|
+
const payload = { recurrenceId, active };
|
|
3098
|
+
return this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/enableOrDisableShoppingRecurrence`, payload);
|
|
3099
|
+
}
|
|
3100
|
+
skipRecurrenceOrder(recurrenceEditionId) {
|
|
3101
|
+
const payload = { recurrenceEditionId };
|
|
3102
|
+
return this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/skipShoppingRecurrenceEdition`, payload);
|
|
3103
|
+
}
|
|
3104
|
+
updateFrequency(recurrenceId, frequency) {
|
|
3105
|
+
const payload = { recurrenceId, frequency };
|
|
3106
|
+
return this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/updateShoppingRecurrenceFrequency`, payload);
|
|
3107
|
+
}
|
|
3108
|
+
updateLineItems(recurrenceId, lineItems) {
|
|
3109
|
+
const payload = { recurrenceId, lineItems };
|
|
3110
|
+
return this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/updateShoppingRecurrenceLineItems`, payload);
|
|
3111
|
+
}
|
|
3112
|
+
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 }); }
|
|
3113
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: OrderRecurrenceService }); }
|
|
3114
|
+
}
|
|
3115
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: OrderRecurrenceService, decorators: [{
|
|
3116
|
+
type: Injectable
|
|
3117
|
+
}], ctorParameters: () => [{ type: i3.ShoppingRecurrenceFirestoreRepository, decorators: [{
|
|
3118
|
+
type: Inject,
|
|
3119
|
+
args: ['ShoppingRecurrenceRepository']
|
|
3120
|
+
}] }, { type: i3.Shops, decorators: [{
|
|
3121
|
+
type: Inject,
|
|
3122
|
+
args: [DEFAULT_SHOP]
|
|
3123
|
+
}] }, { type: CheckoutDependenciesFacade }, { type: ConfigurationFacade }] });
|
|
3124
|
+
|
|
3193
3125
|
class OrderService {
|
|
3194
3126
|
constructor(angularFirestore, orderRepository) {
|
|
3195
3127
|
this.angularFirestore = angularFirestore;
|
|
@@ -3202,14 +3134,36 @@ class OrderService {
|
|
|
3202
3134
|
.subscribe((doc) => this.orderSubject.next(doc));
|
|
3203
3135
|
return this.orderSubject;
|
|
3204
3136
|
}
|
|
3205
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: OrderService, deps: [{ token: i1$
|
|
3137
|
+
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 }); }
|
|
3206
3138
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: OrderService }); }
|
|
3207
3139
|
}
|
|
3208
3140
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: OrderService, decorators: [{
|
|
3209
3141
|
type: Injectable
|
|
3210
|
-
}], ctorParameters: () => [{ type: i1$
|
|
3142
|
+
}], ctorParameters: () => [{ type: i1$2.Firestore }, { type: i3.OrderFirestoreRepository, decorators: [{
|
|
3143
|
+
type: Inject,
|
|
3144
|
+
args: ['OrderRepository']
|
|
3145
|
+
}] }] });
|
|
3146
|
+
|
|
3147
|
+
class CouponRepositoriesFacade {
|
|
3148
|
+
constructor(couponRepository, orderRepository, categoryRepository) {
|
|
3149
|
+
this.couponRepository = couponRepository;
|
|
3150
|
+
this.orderRepository = orderRepository;
|
|
3151
|
+
this.categoryRepository = categoryRepository;
|
|
3152
|
+
}
|
|
3153
|
+
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 }); }
|
|
3154
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CouponRepositoriesFacade }); }
|
|
3155
|
+
}
|
|
3156
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CouponRepositoriesFacade, decorators: [{
|
|
3157
|
+
type: Injectable
|
|
3158
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
3159
|
+
type: Inject,
|
|
3160
|
+
args: ['CouponRepository']
|
|
3161
|
+
}] }, { type: undefined, decorators: [{
|
|
3211
3162
|
type: Inject,
|
|
3212
3163
|
args: ['OrderRepository']
|
|
3164
|
+
}] }, { type: undefined, decorators: [{
|
|
3165
|
+
type: Inject,
|
|
3166
|
+
args: ['CategoryRepository']
|
|
3213
3167
|
}] }] });
|
|
3214
3168
|
|
|
3215
3169
|
class AngularConnectModule {
|
|
@@ -3294,8 +3248,6 @@ class AngularConnectModule {
|
|
|
3294
3248
|
CatalogService,
|
|
3295
3249
|
CategoryService,
|
|
3296
3250
|
CheckoutService,
|
|
3297
|
-
CheckoutSubscriptionService,
|
|
3298
|
-
CouponService,
|
|
3299
3251
|
HomeShopService,
|
|
3300
3252
|
OrderService,
|
|
3301
3253
|
WishlistService,
|
|
@@ -3356,6 +3308,7 @@ class AngularConnectModule {
|
|
|
3356
3308
|
CouponRepositoriesFacade,
|
|
3357
3309
|
HomeShopRepositoriesFacade,
|
|
3358
3310
|
OrderProductReviewService,
|
|
3311
|
+
OrderRecurrenceService,
|
|
3359
3312
|
], imports: [AngularElasticSeachModule,
|
|
3360
3313
|
AngularVertexSeachModule,
|
|
3361
3314
|
AngularFirebaseAuthModule,
|
|
@@ -3408,8 +3361,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImpo
|
|
|
3408
3361
|
CatalogService,
|
|
3409
3362
|
CategoryService,
|
|
3410
3363
|
CheckoutService,
|
|
3411
|
-
CheckoutSubscriptionService,
|
|
3412
|
-
CouponService,
|
|
3413
3364
|
HomeShopService,
|
|
3414
3365
|
OrderService,
|
|
3415
3366
|
WishlistService,
|
|
@@ -3470,6 +3421,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImpo
|
|
|
3470
3421
|
CouponRepositoriesFacade,
|
|
3471
3422
|
HomeShopRepositoriesFacade,
|
|
3472
3423
|
OrderProductReviewService,
|
|
3424
|
+
OrderRecurrenceService,
|
|
3473
3425
|
],
|
|
3474
3426
|
}]
|
|
3475
3427
|
}] });
|
|
@@ -3478,5 +3430,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImpo
|
|
|
3478
3430
|
* Generated bundle index. Do not edit.
|
|
3479
3431
|
*/
|
|
3480
3432
|
|
|
3481
|
-
export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule, AuthService, CartService, CatalogService, CategoryService, CategoryWithTree, CheckoutService,
|
|
3433
|
+
export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule, AuthService, CartService, CatalogService, CategoryService, CategoryWithTree, CheckoutService, CookieDataPersistence, HomeShopService, NewCategoryStructureAdapter, OldCategoryStructureAdapter, OrderProductReviewService, OrderRecurrenceService, OrderService, ProductSorts, UtilHelper, WishlistService };
|
|
3482
3434
|
//# sourceMappingURL=infrab4a-connect-angular.mjs.map
|