@infrab4a/connect-angular 5.0.0-beta.5 → 5.0.0-beta.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/angular-connect.module.d.ts +9 -6
- package/angular-firestore.module.d.ts +1 -2
- package/consts/index.d.ts +1 -0
- package/consts/persistence.const.d.ts +1 -0
- package/esm2022/angular-connect.module.mjs +25 -5
- package/esm2022/angular-elastic-search.module.mjs +1 -1
- package/esm2022/angular-firebase-auth.module.mjs +1 -1
- package/esm2022/angular-firestore.module.mjs +25 -28
- package/esm2022/angular-hasura-graphql.module.mjs +24 -2
- package/esm2022/consts/category-structure.mjs +1 -1
- package/esm2022/consts/default-shop.const.mjs +1 -1
- package/esm2022/consts/es-config.const.mjs +1 -1
- package/esm2022/consts/firebase-const.mjs +1 -1
- package/esm2022/consts/hasura-options.const.mjs +1 -1
- package/esm2022/consts/index.mjs +2 -1
- package/esm2022/consts/persistence.const.mjs +2 -0
- package/esm2022/consts/storage-base-url.const.mjs +1 -1
- package/esm2022/helpers/index.mjs +1 -1
- package/esm2022/helpers/mobile-operation-system-checker.helper.mjs +1 -1
- package/esm2022/index.mjs +2 -1
- package/esm2022/persistence/cookie-data-persistence.mjs +22 -0
- package/esm2022/persistence/data-persistence.mjs +2 -0
- package/esm2022/persistence/index.mjs +3 -0
- package/esm2022/services/auth.service.mjs +1 -1
- package/esm2022/services/cart.service.mjs +11 -10
- package/esm2022/services/catalog/adapters/category-structure.adapter.mjs +1 -1
- package/esm2022/services/catalog/adapters/index.mjs +1 -1
- package/esm2022/services/catalog/adapters/new-category-structure.adapter.mjs +6 -4
- package/esm2022/services/catalog/adapters/old-category-structure.adapter.mjs +1 -1
- package/esm2022/services/catalog/catalog.service.mjs +59 -14
- package/esm2022/services/catalog/category.service.mjs +4 -4
- package/esm2022/services/catalog/enums/index.mjs +1 -1
- package/esm2022/services/catalog/enums/product-sorts.enum.mjs +1 -1
- package/esm2022/services/catalog/index.mjs +1 -1
- package/esm2022/services/catalog/models/category-with-tree.model.mjs +1 -1
- package/esm2022/services/catalog/models/index.mjs +1 -1
- package/esm2022/services/catalog/types/index.mjs +1 -1
- package/esm2022/services/catalog/types/product-sort.type.mjs +1 -1
- package/esm2022/services/catalog/wishlist.service.mjs +30 -16
- package/esm2022/services/checkout-subscription.service.mjs +18 -21
- package/esm2022/services/checkout.service.mjs +13 -16
- package/esm2022/services/coupon.service.mjs +35 -10
- package/esm2022/services/helpers/index.mjs +1 -1
- package/esm2022/services/helpers/util.helper.mjs +1 -1
- package/esm2022/services/home-shop.service.mjs +1 -1
- package/esm2022/services/index.mjs +1 -1
- package/esm2022/services/order.service.mjs +1 -1
- package/esm2022/services/shipping.service.mjs +1 -1
- package/esm2022/services/types/index.mjs +1 -1
- package/esm2022/services/types/required-checkout-data.type.mjs +1 -1
- package/esm2022/services/types/required-checkout-subscription-data.type.mjs +1 -1
- package/esm2022/services/types/shipping-methods.type.mjs +1 -1
- package/esm2022/types/firebase-app-config.type.mjs +1 -1
- package/esm2022/types/index.mjs +1 -1
- package/fesm2022/infrab4a-connect-angular.mjs +256 -115
- package/fesm2022/infrab4a-connect-angular.mjs.map +1 -1
- package/index.d.ts +1 -0
- package/package.json +5 -5
- package/persistence/cookie-data-persistence.d.ts +10 -0
- package/persistence/data-persistence.d.ts +6 -0
- package/persistence/index.d.ts +2 -0
- package/services/catalog/catalog.service.d.ts +5 -2
- package/services/catalog/category.service.d.ts +6 -1
- package/services/catalog/wishlist.service.d.ts +10 -4
- package/services/checkout-subscription.service.d.ts +5 -4
- package/services/checkout.service.d.ts +8 -4
- package/services/coupon.service.d.ts +6 -2
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { NgModule, InjectionToken, PLATFORM_ID, Injectable, Inject } from '@angular/core';
|
|
3
3
|
import * as i1$4 from '@angular/fire/app';
|
|
4
|
-
import { FirebaseApp, getApp, initializeApp
|
|
4
|
+
import { FirebaseApp, provideFirebaseApp, getApp, initializeApp } from '@angular/fire/app';
|
|
5
|
+
import * as i2 from '@angular/fire/storage';
|
|
6
|
+
import { Storage, provideStorage, getStorage } from '@angular/fire/storage';
|
|
5
7
|
import * as i1$2 from '@infrab4a/connect';
|
|
6
|
-
import { ProductsIndex, AxiosAdapter, Authentication, AuthenticationFirebaseAuthService, Register, RegisterFirebaseAuthService, SignOut, RecoveryPassword, UserBeautyProfileFirestoreRepository, Buy2WinFirestoreRepository, CategoryFirestoreRepository, CheckoutFirestoreRepository, CheckoutSubscriptionFirestoreRepository, CouponFirestoreRepository, CampaignHashtagFirestoreRepository, CampaignDashboardFirestoreRepository, SubscriptionEditionFirestoreRepository, HomeFirestoreRepository, LeadFirestoreRepository, LegacyOrderFirestoreRepository, ShopMenuFirestoreRepository, OrderFirestoreRepository, PaymentFirestoreRepository, ProductFirestoreRepository, ShopSettingsFirestoreRepository, SubscriptionPaymentFirestoreRepository, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionFirestoreRepository, UserFirestoreRepository, UserAddressFirestoreRepository, UserPaymentMethodFirestoreRepository, SubscriptionMaterializationFirestoreRepository, SubscriptionSummaryFirestoreRepository, ProductVariantFirestoreRepository,
|
|
8
|
+
import { ProductsIndex, AxiosAdapter, Authentication, AuthenticationFirebaseAuthService, Register, RegisterFirebaseAuthService, SignOut, RecoveryPassword, ConnectFirestoreService, UserBeautyProfileFirestoreRepository, Buy2WinFirestoreRepository, CategoryFirestoreRepository, CheckoutFirestoreRepository, CheckoutSubscriptionFirestoreRepository, CouponFirestoreRepository, CampaignHashtagFirestoreRepository, CampaignDashboardFirestoreRepository, SubscriptionEditionFirestoreRepository, HomeFirestoreRepository, LeadFirestoreRepository, LegacyOrderFirestoreRepository, ShopMenuFirestoreRepository, OrderFirestoreRepository, PaymentFirestoreRepository, ProductFirestoreRepository, ShopSettingsFirestoreRepository, SubscriptionPaymentFirestoreRepository, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionFirestoreRepository, UserFirestoreRepository, UserAddressFirestoreRepository, UserPaymentMethodFirestoreRepository, SubscriptionMaterializationFirestoreRepository, SubscriptionSummaryFirestoreRepository, ProductVariantFirestoreRepository, OrderBlockedFirestoreRepository, CategoryHasuraGraphQLRepository, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository, ProductReviewsHasuraGraphQLRepository, VariantHasuraGraphQLRepository, ProductStockNotificationHasuraGraphQLRepository, FilterOptionHasuraGraphQLRepository, FilterHasuraGraphQLRepository, CategoryCollectionChildrenHasuraGraphQLRepository, WishlistHasuraGraphQLRepository, Where, Shops, CheckoutTypes, CouponTypes, Exclusivities, isNil, NotFoundError, Checkout, pick, LineItem, RoundProductPricesHelper, set, InvalidArgumentError, Category, PersonTypes, Wishlist, CheckoutSubscription, Product, RequiredArgumentError, add, Order, UpdateUserImage, FirebaseFileUploaderService } from '@infrab4a/connect';
|
|
7
9
|
import * as i1 from '@angular/fire/auth';
|
|
8
|
-
import { Auth,
|
|
10
|
+
import { Auth, provideAuth, getAuth, getIdToken, authState } from '@angular/fire/auth';
|
|
9
11
|
import { isPlatformBrowser, isPlatformServer } from '@angular/common';
|
|
10
12
|
import * as i1$1 from '@angular/fire/firestore';
|
|
11
|
-
import { Firestore,
|
|
12
|
-
import * as i2 from '@angular/fire/storage';
|
|
13
|
-
import { Storage, getStorage, provideStorage } from '@angular/fire/storage';
|
|
14
|
-
import { combineLatest, of, from, throwError, Subject, iif, forkJoin } from 'rxjs';
|
|
15
|
-
import { map, catchError, mergeMap, concatMap, tap } from 'rxjs/operators';
|
|
13
|
+
import { Firestore, provideFirestore, initializeFirestore, memoryLocalCache, docSnapshots, doc } from '@angular/fire/firestore';
|
|
16
14
|
import cookie from 'js-cookie';
|
|
17
|
-
import {
|
|
15
|
+
import { of, from, combineLatest, throwError, Subject, iif, forkJoin } from 'rxjs';
|
|
16
|
+
import { map, mergeMap, catchError, concatMap, tap } from 'rxjs/operators';
|
|
17
|
+
import { __decorate, __metadata } from 'tslib';
|
|
18
18
|
import { Type } from 'class-transformer';
|
|
19
19
|
import * as i1$3 from '@angular/common/http';
|
|
20
20
|
|
|
@@ -61,6 +61,8 @@ const FIREBASE_OPTIONS = new InjectionToken('firebaseOptions');
|
|
|
61
61
|
|
|
62
62
|
const HASURA_OPTIONS = 'HASURA_OPTIONS';
|
|
63
63
|
|
|
64
|
+
const PERSISTENCE_PROVIDER = 'PERSISTENCE_PROVIDER';
|
|
65
|
+
|
|
64
66
|
class AngularFirebaseAuthModule {
|
|
65
67
|
static initializeApp(options, nameOrConfig) {
|
|
66
68
|
return {
|
|
@@ -169,8 +171,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
169
171
|
}]
|
|
170
172
|
}] });
|
|
171
173
|
|
|
172
|
-
const STORAGE_BASE_URL = 'STORAGE_BASE_URL';
|
|
173
|
-
|
|
174
174
|
class MobileOperationSystemCheckerHelper {
|
|
175
175
|
static isAppleDevice() {
|
|
176
176
|
return (['iPad Simulator', 'iPhone Simulator', 'iPod Simulator', 'iPad', 'iPhone', 'iPod'].includes(navigator?.platform) ||
|
|
@@ -190,12 +190,12 @@ class AngularFirestoreModule {
|
|
|
190
190
|
};
|
|
191
191
|
}
|
|
192
192
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AngularFirestoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
193
|
-
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.0.3", ngImport: i0, type: AngularFirestoreModule, imports: [AngularElasticSeachModule, i1$1.FirestoreModule
|
|
193
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.0.3", ngImport: i0, type: AngularFirestoreModule, imports: [AngularElasticSeachModule, i1$1.FirestoreModule] }); }
|
|
194
194
|
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AngularFirestoreModule, providers: [
|
|
195
195
|
{
|
|
196
196
|
provide: 'FirestoreOptions',
|
|
197
197
|
useFactory: (firestore, platformId) => ({
|
|
198
|
-
firestore,
|
|
198
|
+
firestore: new ConnectFirestoreService(firestore),
|
|
199
199
|
interceptors: {
|
|
200
200
|
request: (request) => {
|
|
201
201
|
if (isPlatformBrowser(platformId))
|
|
@@ -404,26 +404,26 @@ class AngularFirestoreModule {
|
|
|
404
404
|
deps: ['FirestoreOptions', ProductFirestoreRepository],
|
|
405
405
|
},
|
|
406
406
|
{
|
|
407
|
-
provide: '
|
|
408
|
-
useFactory: (
|
|
409
|
-
return new
|
|
407
|
+
provide: 'OrderBlockedRepository',
|
|
408
|
+
useFactory: (options) => {
|
|
409
|
+
return new OrderBlockedFirestoreRepository(options);
|
|
410
410
|
},
|
|
411
|
-
deps: [
|
|
411
|
+
deps: ['FirestoreOptions'],
|
|
412
412
|
},
|
|
413
413
|
], imports: [AngularElasticSeachModule,
|
|
414
414
|
provideFirestore((injector) => {
|
|
415
415
|
const platformId = injector.get(PLATFORM_ID);
|
|
416
|
-
if (isPlatformServer(platformId))
|
|
417
|
-
return
|
|
418
|
-
|
|
419
|
-
|
|
416
|
+
if (isPlatformServer(platformId) || !MobileOperationSystemCheckerHelper.isAppleDevice())
|
|
417
|
+
return initializeFirestore(injector.get(FirebaseApp), {
|
|
418
|
+
ignoreUndefinedProperties: true,
|
|
419
|
+
});
|
|
420
420
|
const firestore = initializeFirestore(injector.get(FirebaseApp), {
|
|
421
421
|
experimentalForceLongPolling: true,
|
|
422
|
+
ignoreUndefinedProperties: true,
|
|
422
423
|
localCache: memoryLocalCache(),
|
|
423
424
|
});
|
|
424
425
|
return firestore;
|
|
425
|
-
})
|
|
426
|
-
provideStorage(() => getStorage())] }); }
|
|
426
|
+
})] }); }
|
|
427
427
|
}
|
|
428
428
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AngularFirestoreModule, decorators: [{
|
|
429
429
|
type: NgModule,
|
|
@@ -432,23 +432,23 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
432
432
|
AngularElasticSeachModule,
|
|
433
433
|
provideFirestore((injector) => {
|
|
434
434
|
const platformId = injector.get(PLATFORM_ID);
|
|
435
|
-
if (isPlatformServer(platformId))
|
|
436
|
-
return
|
|
437
|
-
|
|
438
|
-
|
|
435
|
+
if (isPlatformServer(platformId) || !MobileOperationSystemCheckerHelper.isAppleDevice())
|
|
436
|
+
return initializeFirestore(injector.get(FirebaseApp), {
|
|
437
|
+
ignoreUndefinedProperties: true,
|
|
438
|
+
});
|
|
439
439
|
const firestore = initializeFirestore(injector.get(FirebaseApp), {
|
|
440
440
|
experimentalForceLongPolling: true,
|
|
441
|
+
ignoreUndefinedProperties: true,
|
|
441
442
|
localCache: memoryLocalCache(),
|
|
442
443
|
});
|
|
443
444
|
return firestore;
|
|
444
445
|
}),
|
|
445
|
-
provideStorage(() => getStorage()),
|
|
446
446
|
],
|
|
447
447
|
providers: [
|
|
448
448
|
{
|
|
449
449
|
provide: 'FirestoreOptions',
|
|
450
450
|
useFactory: (firestore, platformId) => ({
|
|
451
|
-
firestore,
|
|
451
|
+
firestore: new ConnectFirestoreService(firestore),
|
|
452
452
|
interceptors: {
|
|
453
453
|
request: (request) => {
|
|
454
454
|
if (isPlatformBrowser(platformId))
|
|
@@ -657,11 +657,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
657
657
|
deps: ['FirestoreOptions', ProductFirestoreRepository],
|
|
658
658
|
},
|
|
659
659
|
{
|
|
660
|
-
provide: '
|
|
661
|
-
useFactory: (
|
|
662
|
-
return new
|
|
660
|
+
provide: 'OrderBlockedRepository',
|
|
661
|
+
useFactory: (options) => {
|
|
662
|
+
return new OrderBlockedFirestoreRepository(options);
|
|
663
663
|
},
|
|
664
|
-
deps: [
|
|
664
|
+
deps: ['FirestoreOptions'],
|
|
665
665
|
},
|
|
666
666
|
],
|
|
667
667
|
}]
|
|
@@ -744,6 +744,17 @@ class AngularHasuraGraphQLModule {
|
|
|
744
744
|
},
|
|
745
745
|
deps: ['HasuraConfig'],
|
|
746
746
|
},
|
|
747
|
+
{
|
|
748
|
+
provide: 'ProductStockNotificationRepository',
|
|
749
|
+
useExisting: ProductStockNotificationHasuraGraphQLRepository,
|
|
750
|
+
},
|
|
751
|
+
{
|
|
752
|
+
provide: ProductStockNotificationHasuraGraphQLRepository,
|
|
753
|
+
useFactory: (hasuraConfig) => {
|
|
754
|
+
return new ProductStockNotificationHasuraGraphQLRepository(hasuraConfig);
|
|
755
|
+
},
|
|
756
|
+
deps: ['HasuraConfig'],
|
|
757
|
+
},
|
|
747
758
|
{
|
|
748
759
|
provide: 'CategoryFilterRepository',
|
|
749
760
|
useExisting: CategoryFilterHasuraGraphQLRepository,
|
|
@@ -870,6 +881,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
870
881
|
},
|
|
871
882
|
deps: ['HasuraConfig'],
|
|
872
883
|
},
|
|
884
|
+
{
|
|
885
|
+
provide: 'ProductStockNotificationRepository',
|
|
886
|
+
useExisting: ProductStockNotificationHasuraGraphQLRepository,
|
|
887
|
+
},
|
|
888
|
+
{
|
|
889
|
+
provide: ProductStockNotificationHasuraGraphQLRepository,
|
|
890
|
+
useFactory: (hasuraConfig) => {
|
|
891
|
+
return new ProductStockNotificationHasuraGraphQLRepository(hasuraConfig);
|
|
892
|
+
},
|
|
893
|
+
deps: ['HasuraConfig'],
|
|
894
|
+
},
|
|
873
895
|
{
|
|
874
896
|
provide: 'CategoryFilterRepository',
|
|
875
897
|
useExisting: CategoryFilterHasuraGraphQLRepository,
|
|
@@ -927,6 +949,25 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
927
949
|
}]
|
|
928
950
|
}] });
|
|
929
951
|
|
|
952
|
+
const STORAGE_BASE_URL = 'STORAGE_BASE_URL';
|
|
953
|
+
|
|
954
|
+
class CookieDataPersistence {
|
|
955
|
+
get(key) {
|
|
956
|
+
return of(cookie.get(key));
|
|
957
|
+
}
|
|
958
|
+
remove(key) {
|
|
959
|
+
return of(cookie.remove(key));
|
|
960
|
+
}
|
|
961
|
+
set(key, value) {
|
|
962
|
+
return from(cookie.set(key, value)).pipe(map(() => { }));
|
|
963
|
+
}
|
|
964
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CookieDataPersistence, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
965
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CookieDataPersistence }); }
|
|
966
|
+
}
|
|
967
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CookieDataPersistence, decorators: [{
|
|
968
|
+
type: Injectable
|
|
969
|
+
}] });
|
|
970
|
+
|
|
930
971
|
class AuthService {
|
|
931
972
|
constructor(angularFireAuth, userRepository) {
|
|
932
973
|
this.angularFireAuth = angularFireAuth;
|
|
@@ -1033,32 +1074,33 @@ class CouponService {
|
|
|
1033
1074
|
return of(discount);
|
|
1034
1075
|
}
|
|
1035
1076
|
async calcDiscountShopping(coupon, checkout) {
|
|
1036
|
-
let
|
|
1077
|
+
let discountInfo = null;
|
|
1037
1078
|
if (checkout.user.isSubscriber && coupon.discount.subscriber.value) {
|
|
1038
|
-
|
|
1079
|
+
discountInfo = await this.calcDiscountByType(coupon.discount.subscriber.type, coupon.discount.subscriber.value, coupon.productsCategories, checkout);
|
|
1039
1080
|
}
|
|
1040
1081
|
else {
|
|
1041
|
-
|
|
1082
|
+
discountInfo = await this.calcDiscountByType(coupon.discount.non_subscriber.type, coupon.discount.non_subscriber.value, coupon.productsCategories, checkout);
|
|
1042
1083
|
}
|
|
1043
|
-
return discount;
|
|
1084
|
+
return { discount: discountInfo.discount, lineItems: discountInfo.lineItems };
|
|
1044
1085
|
}
|
|
1045
1086
|
async calcDiscountByType(type, value, categories, checkout) {
|
|
1046
1087
|
let discount = 0;
|
|
1047
|
-
let
|
|
1048
|
-
const subTotal = this.calcCheckoutSubtotal(
|
|
1088
|
+
let lineItensElegibleForDiscount = await this.getLineItensEligebleForDiscount(categories, checkout);
|
|
1089
|
+
const subTotal = this.calcCheckoutSubtotal(lineItensElegibleForDiscount, checkout.user);
|
|
1049
1090
|
if (type == CouponTypes.ABSOLUTE) {
|
|
1050
1091
|
discount = value > subTotal ? subTotal : value;
|
|
1051
1092
|
}
|
|
1052
1093
|
else {
|
|
1053
1094
|
discount = subTotal * (value / 100);
|
|
1054
1095
|
}
|
|
1055
|
-
|
|
1096
|
+
const lineItems = this.calcLineItenDiscount(type, lineItensElegibleForDiscount, value, subTotal);
|
|
1097
|
+
return { discount, lineItems };
|
|
1056
1098
|
}
|
|
1057
1099
|
async hasMinSubTotal(coupon, checkout) {
|
|
1058
1100
|
if (!coupon.minSubTotalValue)
|
|
1059
1101
|
return true;
|
|
1060
1102
|
let lineItensDiscount = await this.getLineItensEligebleForDiscount(coupon.productsCategories, checkout);
|
|
1061
|
-
const subTotal = this.calcCheckoutSubtotal(lineItensDiscount, checkout.user
|
|
1103
|
+
const subTotal = this.calcCheckoutSubtotal(lineItensDiscount, checkout.user);
|
|
1062
1104
|
if (coupon.minSubTotalValue <= subTotal)
|
|
1063
1105
|
return true;
|
|
1064
1106
|
return false;
|
|
@@ -1126,7 +1168,7 @@ class CouponService {
|
|
|
1126
1168
|
}
|
|
1127
1169
|
return lineItensDiscount;
|
|
1128
1170
|
}
|
|
1129
|
-
calcCheckoutSubtotal(lineItens, user
|
|
1171
|
+
calcCheckoutSubtotal(lineItens, user) {
|
|
1130
1172
|
return (lineItens?.reduce((acc, curr) => user?.isSubscriber && curr.price.subscriberPrice
|
|
1131
1173
|
? acc + curr.price?.subscriberPrice * curr.quantity
|
|
1132
1174
|
: acc + curr.pricePaid * curr.quantity, 0) || 0);
|
|
@@ -1164,6 +1206,30 @@ class CouponService {
|
|
|
1164
1206
|
}
|
|
1165
1207
|
return couponUseLimits;
|
|
1166
1208
|
}
|
|
1209
|
+
calcLineItenDiscount(type, lineItems, couponDiscount, subTotal) {
|
|
1210
|
+
let lineItemsDiscount = [];
|
|
1211
|
+
if (type === CouponTypes.ABSOLUTE) {
|
|
1212
|
+
const couponDiscountMax = couponDiscount > subTotal ? subTotal : couponDiscount;
|
|
1213
|
+
lineItemsDiscount = lineItems.map((item) => {
|
|
1214
|
+
const totalItemPercentage = item.pricePaid / subTotal;
|
|
1215
|
+
const discountItem = couponDiscountMax * totalItemPercentage;
|
|
1216
|
+
return {
|
|
1217
|
+
...item,
|
|
1218
|
+
discount: Number(discountItem.toFixed(2)),
|
|
1219
|
+
};
|
|
1220
|
+
});
|
|
1221
|
+
}
|
|
1222
|
+
else {
|
|
1223
|
+
lineItemsDiscount = lineItems.map((item) => {
|
|
1224
|
+
const discountItem = item.pricePaid * (couponDiscount / 100);
|
|
1225
|
+
return {
|
|
1226
|
+
...item,
|
|
1227
|
+
discount: Number(discountItem.toFixed(2)),
|
|
1228
|
+
};
|
|
1229
|
+
});
|
|
1230
|
+
}
|
|
1231
|
+
return lineItemsDiscount;
|
|
1232
|
+
}
|
|
1167
1233
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CouponService, deps: [{ token: 'CouponRepository' }, { token: DEFAULT_SHOP }, { token: 'OrderRepository' }, { token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1168
1234
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CouponService, providedIn: 'root' }); }
|
|
1169
1235
|
}
|
|
@@ -1187,18 +1253,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
1187
1253
|
}] }] });
|
|
1188
1254
|
|
|
1189
1255
|
class CheckoutService {
|
|
1190
|
-
constructor(couponService, checkoutRepository,
|
|
1256
|
+
constructor(couponService, checkoutRepository, userRepository, defaultShop, dataPersistence) {
|
|
1191
1257
|
this.couponService = couponService;
|
|
1192
1258
|
this.checkoutRepository = checkoutRepository;
|
|
1193
|
-
this.orderRepository = orderRepository;
|
|
1194
1259
|
this.userRepository = userRepository;
|
|
1195
1260
|
this.defaultShop = defaultShop;
|
|
1261
|
+
this.dataPersistence = dataPersistence;
|
|
1196
1262
|
}
|
|
1197
1263
|
getCheckout(checkoutData) {
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
return from(this.createCheckout(checkoutData));
|
|
1264
|
+
return this.dataPersistence
|
|
1265
|
+
.get('checkoutId')
|
|
1266
|
+
.pipe(concatMap((id) => (!isNil(id) ? this.checkoutRepository.get({ id }) : this.createCheckout(checkoutData))));
|
|
1202
1267
|
}
|
|
1203
1268
|
getUserByCheckout(checkoutId) {
|
|
1204
1269
|
return from(this.checkoutRepository.get({ id: checkoutId })).pipe(concatMap((checkout) => checkout?.user?.id ? of(checkout.user) : from(this.userRepository.get({ id: checkout.user.id }))), concatMap((user) => of(user) || throwError(() => new NotFoundError('User is not found'))));
|
|
@@ -1210,8 +1275,7 @@ class CheckoutService {
|
|
|
1210
1275
|
return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, user: checkout.user })));
|
|
1211
1276
|
}
|
|
1212
1277
|
clearCheckoutFromSession() {
|
|
1213
|
-
|
|
1214
|
-
return of();
|
|
1278
|
+
return this.dataPersistence.remove('checkoutId');
|
|
1215
1279
|
}
|
|
1216
1280
|
calcDiscount(coupon) {
|
|
1217
1281
|
return this.getCheckout().pipe(concatMap(async (checkout) => await this.couponService.calcDiscountShopping(coupon, checkout)));
|
|
@@ -1225,10 +1289,10 @@ class CheckoutService {
|
|
|
1225
1289
|
...Checkout.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain(),
|
|
1226
1290
|
shop: checkoutData?.shop || this.defaultShop,
|
|
1227
1291
|
});
|
|
1228
|
-
|
|
1292
|
+
await this.dataPersistence.set('checkoutId', checkout.id).toPromise();
|
|
1229
1293
|
return checkout;
|
|
1230
1294
|
}
|
|
1231
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CheckoutService, deps: [{ token: CouponService }, { token: 'CheckoutRepository' }, { token: '
|
|
1295
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CheckoutService, deps: [{ token: CouponService }, { token: 'CheckoutRepository' }, { token: 'UserRepository' }, { token: DEFAULT_SHOP }, { token: PERSISTENCE_PROVIDER }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1232
1296
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CheckoutService }); }
|
|
1233
1297
|
}
|
|
1234
1298
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CheckoutService, decorators: [{
|
|
@@ -1236,15 +1300,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
1236
1300
|
}], ctorParameters: () => [{ type: CouponService }, { type: undefined, decorators: [{
|
|
1237
1301
|
type: Inject,
|
|
1238
1302
|
args: ['CheckoutRepository']
|
|
1239
|
-
}] }, { type: undefined, decorators: [{
|
|
1240
|
-
type: Inject,
|
|
1241
|
-
args: ['OrderRepository']
|
|
1242
1303
|
}] }, { type: undefined, decorators: [{
|
|
1243
1304
|
type: Inject,
|
|
1244
1305
|
args: ['UserRepository']
|
|
1245
1306
|
}] }, { type: i1$2.Shops, decorators: [{
|
|
1246
1307
|
type: Inject,
|
|
1247
1308
|
args: [DEFAULT_SHOP]
|
|
1309
|
+
}] }, { type: undefined, decorators: [{
|
|
1310
|
+
type: Inject,
|
|
1311
|
+
args: [PERSISTENCE_PROVIDER]
|
|
1248
1312
|
}] }] });
|
|
1249
1313
|
|
|
1250
1314
|
class CartService {
|
|
@@ -1280,8 +1344,8 @@ class CartService {
|
|
|
1280
1344
|
this.buildLineItem = async ({ checkout, item, quantity, }) => {
|
|
1281
1345
|
const product = await this.getProductData(item.id);
|
|
1282
1346
|
item.quantity = item?.quantity || checkout?.lineItems?.find((lineItem) => lineItem.id === item.id)?.quantity || 0;
|
|
1283
|
-
if (this.checkMaxStock(item, quantity || 0))
|
|
1284
|
-
throw new Error('Desculpe! Temos apenas ' +
|
|
1347
|
+
if (this.checkMaxStock(product.stock.quantity, item.quantity || 0, quantity || 0))
|
|
1348
|
+
throw new Error('Desculpe! Temos apenas ' + product.stock?.quantity + ' em estoque.');
|
|
1285
1349
|
const image = item.image || item.images?.shift();
|
|
1286
1350
|
const { id, name, EAN, slug, stock, price, weight, sku, type } = item;
|
|
1287
1351
|
const isGift = item.isGift || null;
|
|
@@ -1306,6 +1370,7 @@ class CartService {
|
|
|
1306
1370
|
weight: weight ?? product.weight,
|
|
1307
1371
|
quantity: (item.quantity || 0) + (quantity || 0),
|
|
1308
1372
|
pricePaid,
|
|
1373
|
+
discount: 0,
|
|
1309
1374
|
categories: product.categories ?? [],
|
|
1310
1375
|
isGift: isGift ?? null,
|
|
1311
1376
|
costPrice: product.costPrice ?? 0,
|
|
@@ -1321,10 +1386,10 @@ class CartService {
|
|
|
1321
1386
|
? Number(info.subscriberPrice.toFixed(2))
|
|
1322
1387
|
: Number(info.price.toFixed(2));
|
|
1323
1388
|
};
|
|
1324
|
-
this.checkMaxStock = (
|
|
1325
|
-
const maxStock =
|
|
1326
|
-
const currentItemAmount =
|
|
1327
|
-
return currentItemAmount +
|
|
1389
|
+
this.checkMaxStock = (currentStock, currentItemQtd, quantityToAdd) => {
|
|
1390
|
+
const maxStock = currentStock || 0;
|
|
1391
|
+
const currentItemAmount = currentItemQtd || 0;
|
|
1392
|
+
return currentItemAmount + quantityToAdd > maxStock;
|
|
1328
1393
|
};
|
|
1329
1394
|
}
|
|
1330
1395
|
addItem(item, quantity = 1) {
|
|
@@ -1357,7 +1422,7 @@ class CartService {
|
|
|
1357
1422
|
}), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
|
|
1358
1423
|
}
|
|
1359
1424
|
updateUserCart(user) {
|
|
1360
|
-
return this.checkoutService.getCheckout().pipe(concatMap((checkout) => this.checkoutService.updateCheckoutUser(Checkout.toInstance({ ...checkout.toPlain(), user }))), concatMap(async (checkout) => this.checkoutService
|
|
1425
|
+
return this.checkoutService.getCheckout().pipe(concatMap((checkout) => this.checkoutService.updateCheckoutUser(Checkout.toInstance({ ...checkout.toPlain(), user }))), concatMap(async (checkout) => await this.checkoutService
|
|
1361
1426
|
.updateCheckoutLineItems(Checkout.toInstance({
|
|
1362
1427
|
...checkout.toPlain(),
|
|
1363
1428
|
lineItems: checkout.lineItems?.length
|
|
@@ -1541,9 +1606,11 @@ class NewCategoryStructureAdapter {
|
|
|
1541
1606
|
.then((categories) => categories.map((category) => category.id.toString()));
|
|
1542
1607
|
}
|
|
1543
1608
|
async getCategory(category) {
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1609
|
+
const collectionCategory = category.isCollection ||
|
|
1610
|
+
(isNil(category.isCollection) && !category.products?.length) ||
|
|
1611
|
+
category.isWishlist ||
|
|
1612
|
+
category.brandCategory;
|
|
1613
|
+
return collectionCategory ? this.categoryRepository.get({ id: category.id }) : category;
|
|
1547
1614
|
}
|
|
1548
1615
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: NewCategoryStructureAdapter, deps: [{ token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1549
1616
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: NewCategoryStructureAdapter }); }
|
|
@@ -1576,8 +1643,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
1576
1643
|
}] }] });
|
|
1577
1644
|
|
|
1578
1645
|
class CatalogService {
|
|
1579
|
-
constructor(productRepository, categoryRepository, categoryStructureAdapter, shop, productIndex) {
|
|
1646
|
+
constructor(productRepository, productStockNotificationRepository, categoryRepository, categoryStructureAdapter, shop, productIndex) {
|
|
1580
1647
|
this.productRepository = productRepository;
|
|
1648
|
+
this.productStockNotificationRepository = productStockNotificationRepository;
|
|
1581
1649
|
this.categoryRepository = categoryRepository;
|
|
1582
1650
|
this.categoryStructureAdapter = categoryStructureAdapter;
|
|
1583
1651
|
this.shop = shop;
|
|
@@ -1608,17 +1676,22 @@ class CatalogService {
|
|
|
1608
1676
|
if (!sort || sort === 'most-relevant')
|
|
1609
1677
|
return {};
|
|
1610
1678
|
if (sort === 'best-sellers')
|
|
1611
|
-
return {
|
|
1679
|
+
return {
|
|
1680
|
+
shoppingCount: 'desc',
|
|
1681
|
+
rate: 'desc',
|
|
1682
|
+
stock: 'desc',
|
|
1683
|
+
name: 'asc',
|
|
1684
|
+
};
|
|
1612
1685
|
if (sort === 'biggest-price')
|
|
1613
|
-
return { subscriberPrice: 'desc' };
|
|
1686
|
+
return { subscriberPrice: 'desc', rate: 'desc', shoppingCount: 'desc' };
|
|
1614
1687
|
if (sort === 'lowest-price')
|
|
1615
|
-
return { subscriberPrice: 'asc' };
|
|
1688
|
+
return { subscriberPrice: 'asc', rate: 'desc', shoppingCount: 'desc' };
|
|
1616
1689
|
if (sort === 'best-rating')
|
|
1617
|
-
return { rate: 'desc' };
|
|
1690
|
+
return { rate: 'desc', shoppingCount: 'desc', stock: 'desc', name: 'asc' };
|
|
1618
1691
|
if (sort === 'news')
|
|
1619
1692
|
return { createdAt: 'desc' };
|
|
1620
1693
|
if (sort === 'biggest-discount')
|
|
1621
|
-
return { subscriberDiscountPercentage: 'desc' };
|
|
1694
|
+
return { subscriberDiscountPercentage: 'desc', rate: 'desc', shoppingCount: 'desc' };
|
|
1622
1695
|
};
|
|
1623
1696
|
this.buildLimitQuery = (options) => {
|
|
1624
1697
|
const limit = options?.perPage || 20;
|
|
@@ -1652,16 +1725,26 @@ class CatalogService {
|
|
|
1652
1725
|
brands: distinct?.brand,
|
|
1653
1726
|
}));
|
|
1654
1727
|
}
|
|
1728
|
+
async addCustomerToStockNotification(shop, productId, name, email) {
|
|
1729
|
+
return this.productStockNotificationRepository.addCustomerEmail(shop, productId, name, email);
|
|
1730
|
+
}
|
|
1655
1731
|
async findCatalog(options, limits) {
|
|
1656
1732
|
if (this.hasTerm(options) && options.sort === 'most-relevant') {
|
|
1657
1733
|
const productsIds = await this.findCatalogIdsByElasticSearch(options.term);
|
|
1658
|
-
return this.
|
|
1734
|
+
return this.findCatalogAndSortByMostRevelantByTerm(productsIds, options, limits);
|
|
1659
1735
|
}
|
|
1660
1736
|
if (this.hasCategory(options) && options.sort === 'most-relevant') {
|
|
1661
|
-
const
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1737
|
+
const mostRelevant = options.category.isWishlist ? [] : options.category.getMostRelevantByShop(this.shop);
|
|
1738
|
+
const productsIds = await this.productRepository
|
|
1739
|
+
.findCatalog({
|
|
1740
|
+
fields: ['id'],
|
|
1741
|
+
filters: {
|
|
1742
|
+
...(await this.buildMainFilter(options)),
|
|
1743
|
+
...this.buildFilterQuery(options?.filters || {}),
|
|
1744
|
+
},
|
|
1745
|
+
})
|
|
1746
|
+
.then((products) => products.data.map((product) => product.id));
|
|
1747
|
+
return this.findCatalogAndSortByMostRevelant(mostRelevant, productsIds, options, limits);
|
|
1665
1748
|
}
|
|
1666
1749
|
const repoParams = {
|
|
1667
1750
|
filters: {
|
|
@@ -1690,7 +1773,33 @@ class CatalogService {
|
|
|
1690
1773
|
.search(term, 999, this.shop)
|
|
1691
1774
|
.then((data) => ({ id: { operator: Where.IN, value: data.hits.map(({ _source }) => _source.id) } }));
|
|
1692
1775
|
}
|
|
1693
|
-
async findCatalogAndSortByMostRevelant(productIds, options, limits) {
|
|
1776
|
+
async findCatalogAndSortByMostRevelant(mostRelevants, productIds, options, limits) {
|
|
1777
|
+
const mostRelevantProductsIds = [...new Set(mostRelevants.concat(productIds))];
|
|
1778
|
+
const totalResult = await this.productRepository.findCatalog({
|
|
1779
|
+
filters: {
|
|
1780
|
+
id: { operator: Where.IN, value: mostRelevantProductsIds },
|
|
1781
|
+
...this.buildFilterQuery(options?.filters || {}),
|
|
1782
|
+
},
|
|
1783
|
+
orderBy: this.buildSortQuery('news'),
|
|
1784
|
+
options: {
|
|
1785
|
+
minimal: ['price'],
|
|
1786
|
+
maximum: ['price'],
|
|
1787
|
+
distinct: ['brand'],
|
|
1788
|
+
},
|
|
1789
|
+
}, options?.mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female');
|
|
1790
|
+
const firstProducts = totalResult.data.filter((product) => mostRelevants.includes(product.id));
|
|
1791
|
+
const lastProducts = totalResult.data.filter((product) => !mostRelevants.includes(product.id));
|
|
1792
|
+
const categoryMostRelevants = firstProducts.concat(lastProducts);
|
|
1793
|
+
const resultFinal = categoryMostRelevants.slice(limits.offset, limits.offset + limits.limit);
|
|
1794
|
+
return {
|
|
1795
|
+
data: resultFinal,
|
|
1796
|
+
count: totalResult.count,
|
|
1797
|
+
maximum: totalResult.maximum,
|
|
1798
|
+
minimal: totalResult.minimal,
|
|
1799
|
+
distinct: totalResult.distinct,
|
|
1800
|
+
};
|
|
1801
|
+
}
|
|
1802
|
+
async findCatalogAndSortByMostRevelantByTerm(productIds, options, limits) {
|
|
1694
1803
|
const totalResult = await this.productRepository.findCatalog({
|
|
1695
1804
|
fields: ['id', 'stock'],
|
|
1696
1805
|
filters: {
|
|
@@ -1736,7 +1845,7 @@ class CatalogService {
|
|
|
1736
1845
|
return [...new Set(sorted.map(({ _source }) => _source.id))];
|
|
1737
1846
|
}));
|
|
1738
1847
|
}
|
|
1739
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CatalogService, deps: [{ token: 'ProductRepository' }, { token: 'CategoryRepository' }, { token: CATEGORY_STRUCTURE }, { token: DEFAULT_SHOP }, { token: i1$2.ProductsIndex }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1848
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CatalogService, deps: [{ token: 'ProductRepository' }, { token: 'ProductStockNotificationRepository' }, { token: 'CategoryRepository' }, { token: CATEGORY_STRUCTURE }, { token: DEFAULT_SHOP }, { token: i1$2.ProductsIndex }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1740
1849
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CatalogService }); }
|
|
1741
1850
|
}
|
|
1742
1851
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CatalogService, decorators: [{
|
|
@@ -1744,6 +1853,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
1744
1853
|
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
1745
1854
|
type: Inject,
|
|
1746
1855
|
args: ['ProductRepository']
|
|
1856
|
+
}] }, { type: undefined, decorators: [{
|
|
1857
|
+
type: Inject,
|
|
1858
|
+
args: ['ProductStockNotificationRepository']
|
|
1747
1859
|
}] }, { type: undefined, decorators: [{
|
|
1748
1860
|
type: Inject,
|
|
1749
1861
|
args: ['CategoryRepository']
|
|
@@ -1763,15 +1875,15 @@ class CategoryService {
|
|
|
1763
1875
|
this.categoryStructureAdapter = categoryStructureAdapter;
|
|
1764
1876
|
this.shop = shop;
|
|
1765
1877
|
}
|
|
1766
|
-
async fetchBrands(category,
|
|
1878
|
+
async fetchBrands(category, options) {
|
|
1767
1879
|
const brands = await this.productRepository
|
|
1768
1880
|
.findCatalog({
|
|
1769
1881
|
filters: await this.categoryStructureAdapter.buildProductFilterByCategory(category),
|
|
1770
1882
|
fields: ['brand'],
|
|
1771
|
-
}, mainGender
|
|
1883
|
+
}, options?.mainGender ? options?.mainGender : this.shop === Shops.MENSMARKET ? 'male' : 'female')
|
|
1772
1884
|
.then(({ data }) => Object.keys(data.map((product) => product.brand).reduce((brands, brand) => ({ ...brands, [brand]: true }), {})));
|
|
1773
1885
|
return this.categoryRepository
|
|
1774
|
-
.find({ filters: { brandCategory: true, shop: this.shop }, orderBy: { name: 'asc' } })
|
|
1886
|
+
.find({ filters: { brandCategory: true, shop: options?.shop || this.shop }, orderBy: { name: 'asc' } })
|
|
1775
1887
|
.then(({ data }) => data.filter((category) => brands.includes(category.conditions.brand)));
|
|
1776
1888
|
}
|
|
1777
1889
|
async fetchFilterOptions(category) {
|
|
@@ -1820,11 +1932,11 @@ __decorate([
|
|
|
1820
1932
|
], CategoryWithTree.prototype, "children", void 0);
|
|
1821
1933
|
|
|
1822
1934
|
class WishlistService {
|
|
1823
|
-
constructor(wishlistRepository, shop, productRepository, categoryFilterRepository, categoryRepository, productIndex) {
|
|
1935
|
+
constructor(wishlistRepository, shop, productRepository, categoryFilterRepository, categoryRepository, productStockNotificationRepository, productIndex) {
|
|
1824
1936
|
this.wishlistRepository = wishlistRepository;
|
|
1825
1937
|
this.shop = shop;
|
|
1826
1938
|
const categoryStructureAdapter = new NewCategoryStructureAdapter(wishlistRepository);
|
|
1827
|
-
this.catalogService = new CatalogService(productRepository, categoryRepository, categoryStructureAdapter, shop, productIndex);
|
|
1939
|
+
this.catalogService = new CatalogService(productRepository, productStockNotificationRepository, categoryRepository, categoryStructureAdapter, shop, productIndex);
|
|
1828
1940
|
this.categoryService = new CategoryService(productRepository, categoryRepository, categoryFilterRepository, categoryStructureAdapter, shop);
|
|
1829
1941
|
}
|
|
1830
1942
|
getCatalogService() {
|
|
@@ -1833,42 +1945,53 @@ class WishlistService {
|
|
|
1833
1945
|
getCategoryService() {
|
|
1834
1946
|
return this.categoryService;
|
|
1835
1947
|
}
|
|
1836
|
-
async create({ personId, title, description, userFullName, userPhoto, theme, bannerUrl, }) {
|
|
1948
|
+
async create({ personId, title, description, published, userFullName, userPhoto, theme, bannerUrl, personType, personIsSubscriber, }) {
|
|
1837
1949
|
const data = {
|
|
1838
1950
|
slug: '',
|
|
1839
1951
|
name: title,
|
|
1840
1952
|
description,
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1953
|
+
metadatas: [
|
|
1954
|
+
{
|
|
1955
|
+
shop: this.shop,
|
|
1956
|
+
title: `${userFullName} - ${title}`,
|
|
1957
|
+
description: `${userFullName} - ${description}`,
|
|
1958
|
+
},
|
|
1959
|
+
],
|
|
1845
1960
|
shop: this.shop,
|
|
1846
1961
|
shops: [this.shop],
|
|
1847
1962
|
personId,
|
|
1848
1963
|
personName: userFullName,
|
|
1849
1964
|
personPhoto: userPhoto,
|
|
1850
1965
|
brandCategory: false,
|
|
1851
|
-
published
|
|
1966
|
+
published,
|
|
1852
1967
|
theme,
|
|
1853
1968
|
bannerUrl,
|
|
1969
|
+
personType: personType ?? PersonTypes.NONE,
|
|
1970
|
+
personIsSubscriber: personIsSubscriber ?? false,
|
|
1854
1971
|
};
|
|
1855
1972
|
const newWishlist = await this.wishlistRepository.create(data);
|
|
1856
1973
|
await this.wishlistRepository.update({ id: newWishlist.id, slug: newWishlist.id });
|
|
1857
1974
|
return Wishlist.toInstance({ ...newWishlist.toPlain(), slug: newWishlist.id });
|
|
1858
1975
|
}
|
|
1859
|
-
update({ id, title, description, userFullName, userPhoto, theme, bannerUrl, }) {
|
|
1976
|
+
update({ id, title, description, published, userFullName, userPhoto, theme, bannerUrl, personType, personIsSubscriber, }) {
|
|
1860
1977
|
const data = {
|
|
1861
1978
|
id,
|
|
1862
1979
|
name: title,
|
|
1863
1980
|
description,
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1981
|
+
published,
|
|
1982
|
+
metadatas: [
|
|
1983
|
+
{
|
|
1984
|
+
shop: this.shop,
|
|
1985
|
+
title: `${userFullName} - ${title}`,
|
|
1986
|
+
description: `${userFullName} - ${description}`,
|
|
1987
|
+
},
|
|
1988
|
+
],
|
|
1868
1989
|
personName: userFullName,
|
|
1869
1990
|
personPhoto: userPhoto,
|
|
1870
1991
|
theme,
|
|
1871
1992
|
bannerUrl,
|
|
1993
|
+
personType: personType ?? PersonTypes.NONE,
|
|
1994
|
+
personIsSubscriber: personIsSubscriber ?? false,
|
|
1872
1995
|
};
|
|
1873
1996
|
return this.wishlistRepository.update(data);
|
|
1874
1997
|
}
|
|
@@ -1904,7 +2027,7 @@ class WishlistService {
|
|
|
1904
2027
|
}
|
|
1905
2028
|
return wishlist;
|
|
1906
2029
|
}
|
|
1907
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: WishlistService, deps: [{ token: 'WishlistRepository' }, { token: DEFAULT_SHOP }, { token: 'ProductRepository' }, { token: 'CategoryFilterRepository' }, { token: 'CategoryRepository' }, { token: i1$2.ProductsIndex }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2030
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: WishlistService, deps: [{ token: 'WishlistRepository' }, { token: DEFAULT_SHOP }, { token: 'ProductRepository' }, { token: 'CategoryFilterRepository' }, { token: 'CategoryRepository' }, { token: 'ProductStockNotificationRepository' }, { token: i1$2.ProductsIndex }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1908
2031
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: WishlistService }); }
|
|
1909
2032
|
}
|
|
1910
2033
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: WishlistService, decorators: [{
|
|
@@ -1924,31 +2047,24 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
1924
2047
|
}] }, { type: undefined, decorators: [{
|
|
1925
2048
|
type: Inject,
|
|
1926
2049
|
args: ['CategoryRepository']
|
|
2050
|
+
}] }, { type: undefined, decorators: [{
|
|
2051
|
+
type: Inject,
|
|
2052
|
+
args: ['ProductStockNotificationRepository']
|
|
1927
2053
|
}] }, { type: i1$2.ProductsIndex }] });
|
|
1928
2054
|
|
|
1929
2055
|
class CheckoutSubscriptionService {
|
|
1930
|
-
constructor(checkoutSubscriptionRepository,
|
|
2056
|
+
constructor(checkoutSubscriptionRepository, dataPersistence, couponService) {
|
|
1931
2057
|
this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
|
|
1932
|
-
this.
|
|
2058
|
+
this.dataPersistence = dataPersistence;
|
|
1933
2059
|
this.couponService = couponService;
|
|
1934
2060
|
}
|
|
1935
2061
|
getCheckoutSubscription(checkoutData) {
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
return from(this.createCheckoutSubscription(checkoutData));
|
|
1940
|
-
}
|
|
1941
|
-
async createCheckoutSubscription(checkoutData) {
|
|
1942
|
-
const checkout = await this.checkoutSubscriptionRepository.create({
|
|
1943
|
-
createdAt: new Date(),
|
|
1944
|
-
...CheckoutSubscription.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain(),
|
|
1945
|
-
});
|
|
1946
|
-
cookie.set('checkoutSubscriptionId', checkout.id);
|
|
1947
|
-
return checkout;
|
|
2062
|
+
return this.dataPersistence
|
|
2063
|
+
.get('checkoutSubscriptionId')
|
|
2064
|
+
.pipe(concatMap((id) => !isNil(id) ? this.checkoutSubscriptionRepository.get({ id }) : this.createCheckoutSubscription(checkoutData)));
|
|
1948
2065
|
}
|
|
1949
2066
|
clearCheckoutSubscriptionFromSession() {
|
|
1950
|
-
|
|
1951
|
-
return of();
|
|
2067
|
+
return this.dataPersistence.remove('checkoutSubscriptionId');
|
|
1952
2068
|
}
|
|
1953
2069
|
checkCoupon(nickname, userEmail) {
|
|
1954
2070
|
return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService
|
|
@@ -1958,7 +2074,15 @@ class CheckoutSubscriptionService {
|
|
|
1958
2074
|
calcDiscountSubscription(coupon) {
|
|
1959
2075
|
return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService.calcDiscountSubscription(coupon, checkout).pipe()));
|
|
1960
2076
|
}
|
|
1961
|
-
|
|
2077
|
+
async createCheckoutSubscription(checkoutData) {
|
|
2078
|
+
const checkout = await this.checkoutSubscriptionRepository.create({
|
|
2079
|
+
createdAt: new Date(),
|
|
2080
|
+
...CheckoutSubscription.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain(),
|
|
2081
|
+
});
|
|
2082
|
+
await this.dataPersistence.set('checkoutSubscriptionId', checkout.id).toPromise();
|
|
2083
|
+
return checkout;
|
|
2084
|
+
}
|
|
2085
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CheckoutSubscriptionService, deps: [{ token: 'CheckoutSubscriptionRepository' }, { token: PERSISTENCE_PROVIDER }, { token: CouponService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1962
2086
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CheckoutSubscriptionService }); }
|
|
1963
2087
|
}
|
|
1964
2088
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CheckoutSubscriptionService, decorators: [{
|
|
@@ -1968,7 +2092,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
1968
2092
|
args: ['CheckoutSubscriptionRepository']
|
|
1969
2093
|
}] }, { type: undefined, decorators: [{
|
|
1970
2094
|
type: Inject,
|
|
1971
|
-
args: [
|
|
2095
|
+
args: [PERSISTENCE_PROVIDER]
|
|
1972
2096
|
}] }, { type: CouponService }] });
|
|
1973
2097
|
|
|
1974
2098
|
class UtilHelper {
|
|
@@ -2226,6 +2350,7 @@ class AngularConnectModule {
|
|
|
2226
2350
|
? OldCategoryStructureAdapter
|
|
2227
2351
|
: NewCategoryStructureAdapter,
|
|
2228
2352
|
},
|
|
2353
|
+
{ provide: PERSISTENCE_PROVIDER, useClass: options?.persistenceProvider || CookieDataPersistence },
|
|
2229
2354
|
...(isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]),
|
|
2230
2355
|
...(isNil(options?.firebase) ? [] : [{ provide: FIREBASE_OPTIONS, useValue: options?.firebase }]),
|
|
2231
2356
|
...(isNil(options?.firebase) ? [] : [{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig }]),
|
|
@@ -2237,7 +2362,7 @@ class AngularConnectModule {
|
|
|
2237
2362
|
};
|
|
2238
2363
|
}
|
|
2239
2364
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AngularConnectModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
2240
|
-
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.0.3", ngImport: i0, type: AngularConnectModule, imports: [i1$4.FirebaseAppModule, AngularElasticSeachModule,
|
|
2365
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.0.3", ngImport: i0, type: AngularConnectModule, imports: [i1$4.FirebaseAppModule, i2.StorageModule, AngularElasticSeachModule,
|
|
2241
2366
|
AngularFirebaseAuthModule,
|
|
2242
2367
|
AngularFirestoreModule,
|
|
2243
2368
|
AngularHasuraGraphQLModule] }); }
|
|
@@ -2260,6 +2385,13 @@ class AngularConnectModule {
|
|
|
2260
2385
|
},
|
|
2261
2386
|
deps: ['UserRepository', 'FileUploaderService'],
|
|
2262
2387
|
},
|
|
2388
|
+
{
|
|
2389
|
+
provide: 'FileUploaderService',
|
|
2390
|
+
useFactory: (storage, baseUrl) => {
|
|
2391
|
+
return new FirebaseFileUploaderService(storage, baseUrl);
|
|
2392
|
+
},
|
|
2393
|
+
deps: [Storage, STORAGE_BASE_URL],
|
|
2394
|
+
},
|
|
2263
2395
|
], imports: [provideFirebaseApp((injector) => {
|
|
2264
2396
|
const appName = injector.get(FIREBASE_APP_NAME) || '[DEFAULT]';
|
|
2265
2397
|
try {
|
|
@@ -2269,6 +2401,7 @@ class AngularConnectModule {
|
|
|
2269
2401
|
return initializeApp(injector.get(FIREBASE_OPTIONS), appName);
|
|
2270
2402
|
}
|
|
2271
2403
|
}),
|
|
2404
|
+
provideStorage((injector) => getStorage(injector.get(FirebaseApp))),
|
|
2272
2405
|
AngularElasticSeachModule,
|
|
2273
2406
|
AngularFirebaseAuthModule,
|
|
2274
2407
|
AngularFirestoreModule,
|
|
@@ -2287,6 +2420,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
2287
2420
|
return initializeApp(injector.get(FIREBASE_OPTIONS), appName);
|
|
2288
2421
|
}
|
|
2289
2422
|
}),
|
|
2423
|
+
provideStorage((injector) => getStorage(injector.get(FirebaseApp))),
|
|
2290
2424
|
AngularElasticSeachModule,
|
|
2291
2425
|
AngularFirebaseAuthModule,
|
|
2292
2426
|
AngularFirestoreModule,
|
|
@@ -2311,6 +2445,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
2311
2445
|
},
|
|
2312
2446
|
deps: ['UserRepository', 'FileUploaderService'],
|
|
2313
2447
|
},
|
|
2448
|
+
{
|
|
2449
|
+
provide: 'FileUploaderService',
|
|
2450
|
+
useFactory: (storage, baseUrl) => {
|
|
2451
|
+
return new FirebaseFileUploaderService(storage, baseUrl);
|
|
2452
|
+
},
|
|
2453
|
+
deps: [Storage, STORAGE_BASE_URL],
|
|
2454
|
+
},
|
|
2314
2455
|
],
|
|
2315
2456
|
}]
|
|
2316
2457
|
}] });
|
|
@@ -2319,5 +2460,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
2319
2460
|
* Generated bundle index. Do not edit.
|
|
2320
2461
|
*/
|
|
2321
2462
|
|
|
2322
|
-
export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule, AuthService, CartService, CatalogService, CategoryService, CategoryWithTree, CheckoutService, CheckoutSubscriptionService, CouponService, HomeShopService, NewCategoryStructureAdapter, OldCategoryStructureAdapter, OrderService, ProductSorts, ShippingService, UtilHelper, WishlistService };
|
|
2463
|
+
export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule, AuthService, CartService, CatalogService, CategoryService, CategoryWithTree, CheckoutService, CheckoutSubscriptionService, CookieDataPersistence, CouponService, HomeShopService, NewCategoryStructureAdapter, OldCategoryStructureAdapter, OrderService, ProductSorts, ShippingService, UtilHelper, WishlistService };
|
|
2323
2464
|
//# sourceMappingURL=infrab4a-connect-angular.mjs.map
|