@infrab4a/connect-angular 5.0.0-beta.2 → 5.0.0-beta.21
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 +17 -34
- 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 +3 -2
- 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 +67 -13
- 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 +14 -11
- 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 +234 -109
- package/fesm2022/infrab4a-connect-angular.mjs.map +1 -1
- package/index.d.ts +1 -0
- package/package.json +3 -3
- 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 +10 -4
- package/services/catalog/category.service.d.ts +6 -1
- package/services/catalog/wishlist.service.d.ts +6 -5
- 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, CategoryHasuraGraphQLRepository, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository, ProductReviewsHasuraGraphQLRepository, VariantHasuraGraphQLRepository, ProductStockNotificationHasuraGraphQLRepository, FilterOptionHasuraGraphQLRepository, FilterHasuraGraphQLRepository, CategoryCollectionChildrenHasuraGraphQLRepository, WishlistHasuraGraphQLRepository, Where, Shops, CheckoutTypes, CouponTypes, Exclusivities, isNil, NotFoundError, Checkout, pick, LineItem, RoundProductPricesHelper, set, InvalidArgumentError, Category, 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))
|
|
@@ -403,27 +403,20 @@ class AngularFirestoreModule {
|
|
|
403
403
|
},
|
|
404
404
|
deps: ['FirestoreOptions', ProductFirestoreRepository],
|
|
405
405
|
},
|
|
406
|
-
{
|
|
407
|
-
provide: 'FileUploaderService',
|
|
408
|
-
useFactory: (storage, baseUrl) => {
|
|
409
|
-
return new FirebaseFileUploaderService(storage, baseUrl);
|
|
410
|
-
},
|
|
411
|
-
deps: [Storage, STORAGE_BASE_URL],
|
|
412
|
-
},
|
|
413
406
|
], imports: [AngularElasticSeachModule,
|
|
414
407
|
provideFirestore((injector) => {
|
|
415
408
|
const platformId = injector.get(PLATFORM_ID);
|
|
416
|
-
if (isPlatformServer(platformId))
|
|
417
|
-
return
|
|
418
|
-
|
|
419
|
-
|
|
409
|
+
if (isPlatformServer(platformId) || !MobileOperationSystemCheckerHelper.isAppleDevice())
|
|
410
|
+
return initializeFirestore(injector.get(FirebaseApp), {
|
|
411
|
+
ignoreUndefinedProperties: true,
|
|
412
|
+
});
|
|
420
413
|
const firestore = initializeFirestore(injector.get(FirebaseApp), {
|
|
421
414
|
experimentalForceLongPolling: true,
|
|
415
|
+
ignoreUndefinedProperties: true,
|
|
422
416
|
localCache: memoryLocalCache(),
|
|
423
417
|
});
|
|
424
418
|
return firestore;
|
|
425
|
-
})
|
|
426
|
-
provideStorage(() => getStorage())] }); }
|
|
419
|
+
})] }); }
|
|
427
420
|
}
|
|
428
421
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AngularFirestoreModule, decorators: [{
|
|
429
422
|
type: NgModule,
|
|
@@ -432,23 +425,23 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
432
425
|
AngularElasticSeachModule,
|
|
433
426
|
provideFirestore((injector) => {
|
|
434
427
|
const platformId = injector.get(PLATFORM_ID);
|
|
435
|
-
if (isPlatformServer(platformId))
|
|
436
|
-
return
|
|
437
|
-
|
|
438
|
-
|
|
428
|
+
if (isPlatformServer(platformId) || !MobileOperationSystemCheckerHelper.isAppleDevice())
|
|
429
|
+
return initializeFirestore(injector.get(FirebaseApp), {
|
|
430
|
+
ignoreUndefinedProperties: true,
|
|
431
|
+
});
|
|
439
432
|
const firestore = initializeFirestore(injector.get(FirebaseApp), {
|
|
440
433
|
experimentalForceLongPolling: true,
|
|
434
|
+
ignoreUndefinedProperties: true,
|
|
441
435
|
localCache: memoryLocalCache(),
|
|
442
436
|
});
|
|
443
437
|
return firestore;
|
|
444
438
|
}),
|
|
445
|
-
provideStorage(() => getStorage()),
|
|
446
439
|
],
|
|
447
440
|
providers: [
|
|
448
441
|
{
|
|
449
442
|
provide: 'FirestoreOptions',
|
|
450
443
|
useFactory: (firestore, platformId) => ({
|
|
451
|
-
firestore,
|
|
444
|
+
firestore: new ConnectFirestoreService(firestore),
|
|
452
445
|
interceptors: {
|
|
453
446
|
request: (request) => {
|
|
454
447
|
if (isPlatformBrowser(platformId))
|
|
@@ -656,13 +649,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
656
649
|
},
|
|
657
650
|
deps: ['FirestoreOptions', ProductFirestoreRepository],
|
|
658
651
|
},
|
|
659
|
-
{
|
|
660
|
-
provide: 'FileUploaderService',
|
|
661
|
-
useFactory: (storage, baseUrl) => {
|
|
662
|
-
return new FirebaseFileUploaderService(storage, baseUrl);
|
|
663
|
-
},
|
|
664
|
-
deps: [Storage, STORAGE_BASE_URL],
|
|
665
|
-
},
|
|
666
652
|
],
|
|
667
653
|
}]
|
|
668
654
|
}] });
|
|
@@ -744,6 +730,17 @@ class AngularHasuraGraphQLModule {
|
|
|
744
730
|
},
|
|
745
731
|
deps: ['HasuraConfig'],
|
|
746
732
|
},
|
|
733
|
+
{
|
|
734
|
+
provide: 'ProductStockNotificationRepository',
|
|
735
|
+
useExisting: ProductStockNotificationHasuraGraphQLRepository,
|
|
736
|
+
},
|
|
737
|
+
{
|
|
738
|
+
provide: ProductStockNotificationHasuraGraphQLRepository,
|
|
739
|
+
useFactory: (hasuraConfig) => {
|
|
740
|
+
return new ProductStockNotificationHasuraGraphQLRepository(hasuraConfig);
|
|
741
|
+
},
|
|
742
|
+
deps: ['HasuraConfig'],
|
|
743
|
+
},
|
|
747
744
|
{
|
|
748
745
|
provide: 'CategoryFilterRepository',
|
|
749
746
|
useExisting: CategoryFilterHasuraGraphQLRepository,
|
|
@@ -870,6 +867,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
870
867
|
},
|
|
871
868
|
deps: ['HasuraConfig'],
|
|
872
869
|
},
|
|
870
|
+
{
|
|
871
|
+
provide: 'ProductStockNotificationRepository',
|
|
872
|
+
useExisting: ProductStockNotificationHasuraGraphQLRepository,
|
|
873
|
+
},
|
|
874
|
+
{
|
|
875
|
+
provide: ProductStockNotificationHasuraGraphQLRepository,
|
|
876
|
+
useFactory: (hasuraConfig) => {
|
|
877
|
+
return new ProductStockNotificationHasuraGraphQLRepository(hasuraConfig);
|
|
878
|
+
},
|
|
879
|
+
deps: ['HasuraConfig'],
|
|
880
|
+
},
|
|
873
881
|
{
|
|
874
882
|
provide: 'CategoryFilterRepository',
|
|
875
883
|
useExisting: CategoryFilterHasuraGraphQLRepository,
|
|
@@ -927,6 +935,25 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
927
935
|
}]
|
|
928
936
|
}] });
|
|
929
937
|
|
|
938
|
+
const STORAGE_BASE_URL = 'STORAGE_BASE_URL';
|
|
939
|
+
|
|
940
|
+
class CookieDataPersistence {
|
|
941
|
+
get(key) {
|
|
942
|
+
return of(cookie.get(key));
|
|
943
|
+
}
|
|
944
|
+
remove(key) {
|
|
945
|
+
return of(cookie.remove(key));
|
|
946
|
+
}
|
|
947
|
+
set(key, value) {
|
|
948
|
+
return from(cookie.set(key, value)).pipe(map(() => { }));
|
|
949
|
+
}
|
|
950
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CookieDataPersistence, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
951
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CookieDataPersistence }); }
|
|
952
|
+
}
|
|
953
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CookieDataPersistence, decorators: [{
|
|
954
|
+
type: Injectable
|
|
955
|
+
}] });
|
|
956
|
+
|
|
930
957
|
class AuthService {
|
|
931
958
|
constructor(angularFireAuth, userRepository) {
|
|
932
959
|
this.angularFireAuth = angularFireAuth;
|
|
@@ -1033,32 +1060,33 @@ class CouponService {
|
|
|
1033
1060
|
return of(discount);
|
|
1034
1061
|
}
|
|
1035
1062
|
async calcDiscountShopping(coupon, checkout) {
|
|
1036
|
-
let
|
|
1063
|
+
let discountInfo = null;
|
|
1037
1064
|
if (checkout.user.isSubscriber && coupon.discount.subscriber.value) {
|
|
1038
|
-
|
|
1065
|
+
discountInfo = await this.calcDiscountByType(coupon.discount.subscriber.type, coupon.discount.subscriber.value, coupon.productsCategories, checkout);
|
|
1039
1066
|
}
|
|
1040
1067
|
else {
|
|
1041
|
-
|
|
1068
|
+
discountInfo = await this.calcDiscountByType(coupon.discount.non_subscriber.type, coupon.discount.non_subscriber.value, coupon.productsCategories, checkout);
|
|
1042
1069
|
}
|
|
1043
|
-
return discount;
|
|
1070
|
+
return { discount: discountInfo.discount, lineItems: discountInfo.lineItems };
|
|
1044
1071
|
}
|
|
1045
1072
|
async calcDiscountByType(type, value, categories, checkout) {
|
|
1046
1073
|
let discount = 0;
|
|
1047
|
-
let
|
|
1048
|
-
const subTotal = this.calcCheckoutSubtotal(
|
|
1074
|
+
let lineItensElegibleForDiscount = await this.getLineItensEligebleForDiscount(categories, checkout);
|
|
1075
|
+
const subTotal = this.calcCheckoutSubtotal(lineItensElegibleForDiscount, checkout.user);
|
|
1049
1076
|
if (type == CouponTypes.ABSOLUTE) {
|
|
1050
1077
|
discount = value > subTotal ? subTotal : value;
|
|
1051
1078
|
}
|
|
1052
1079
|
else {
|
|
1053
1080
|
discount = subTotal * (value / 100);
|
|
1054
1081
|
}
|
|
1055
|
-
|
|
1082
|
+
const lineItems = this.calcLineItenDiscount(type, lineItensElegibleForDiscount, value, subTotal);
|
|
1083
|
+
return { discount, lineItems };
|
|
1056
1084
|
}
|
|
1057
1085
|
async hasMinSubTotal(coupon, checkout) {
|
|
1058
1086
|
if (!coupon.minSubTotalValue)
|
|
1059
1087
|
return true;
|
|
1060
1088
|
let lineItensDiscount = await this.getLineItensEligebleForDiscount(coupon.productsCategories, checkout);
|
|
1061
|
-
const subTotal = this.calcCheckoutSubtotal(lineItensDiscount, checkout.user
|
|
1089
|
+
const subTotal = this.calcCheckoutSubtotal(lineItensDiscount, checkout.user);
|
|
1062
1090
|
if (coupon.minSubTotalValue <= subTotal)
|
|
1063
1091
|
return true;
|
|
1064
1092
|
return false;
|
|
@@ -1126,7 +1154,7 @@ class CouponService {
|
|
|
1126
1154
|
}
|
|
1127
1155
|
return lineItensDiscount;
|
|
1128
1156
|
}
|
|
1129
|
-
calcCheckoutSubtotal(lineItens, user
|
|
1157
|
+
calcCheckoutSubtotal(lineItens, user) {
|
|
1130
1158
|
return (lineItens?.reduce((acc, curr) => user?.isSubscriber && curr.price.subscriberPrice
|
|
1131
1159
|
? acc + curr.price?.subscriberPrice * curr.quantity
|
|
1132
1160
|
: acc + curr.pricePaid * curr.quantity, 0) || 0);
|
|
@@ -1164,6 +1192,30 @@ class CouponService {
|
|
|
1164
1192
|
}
|
|
1165
1193
|
return couponUseLimits;
|
|
1166
1194
|
}
|
|
1195
|
+
calcLineItenDiscount(type, lineItems, couponDiscount, subTotal) {
|
|
1196
|
+
let lineItemsDiscount = [];
|
|
1197
|
+
if (type === CouponTypes.ABSOLUTE) {
|
|
1198
|
+
const couponDiscountMax = couponDiscount > subTotal ? subTotal : couponDiscount;
|
|
1199
|
+
lineItemsDiscount = lineItems.map((item) => {
|
|
1200
|
+
const totalItemPercentage = item.pricePaid / subTotal;
|
|
1201
|
+
const discountItem = couponDiscountMax * totalItemPercentage;
|
|
1202
|
+
return {
|
|
1203
|
+
...item,
|
|
1204
|
+
discount: Number(discountItem.toFixed(2)),
|
|
1205
|
+
};
|
|
1206
|
+
});
|
|
1207
|
+
}
|
|
1208
|
+
else {
|
|
1209
|
+
lineItemsDiscount = lineItems.map((item) => {
|
|
1210
|
+
const discountItem = item.pricePaid * (couponDiscount / 100);
|
|
1211
|
+
return {
|
|
1212
|
+
...item,
|
|
1213
|
+
discount: Number(discountItem.toFixed(2)),
|
|
1214
|
+
};
|
|
1215
|
+
});
|
|
1216
|
+
}
|
|
1217
|
+
return lineItemsDiscount;
|
|
1218
|
+
}
|
|
1167
1219
|
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
1220
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CouponService, providedIn: 'root' }); }
|
|
1169
1221
|
}
|
|
@@ -1187,18 +1239,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
1187
1239
|
}] }] });
|
|
1188
1240
|
|
|
1189
1241
|
class CheckoutService {
|
|
1190
|
-
constructor(couponService, checkoutRepository,
|
|
1242
|
+
constructor(couponService, checkoutRepository, userRepository, defaultShop, dataPersistence) {
|
|
1191
1243
|
this.couponService = couponService;
|
|
1192
1244
|
this.checkoutRepository = checkoutRepository;
|
|
1193
|
-
this.orderRepository = orderRepository;
|
|
1194
1245
|
this.userRepository = userRepository;
|
|
1195
1246
|
this.defaultShop = defaultShop;
|
|
1247
|
+
this.dataPersistence = dataPersistence;
|
|
1196
1248
|
}
|
|
1197
1249
|
getCheckout(checkoutData) {
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
return from(this.createCheckout(checkoutData));
|
|
1250
|
+
return this.dataPersistence
|
|
1251
|
+
.get('checkoutId')
|
|
1252
|
+
.pipe(concatMap((id) => (!isNil(id) ? this.checkoutRepository.get({ id }) : this.createCheckout(checkoutData))));
|
|
1202
1253
|
}
|
|
1203
1254
|
getUserByCheckout(checkoutId) {
|
|
1204
1255
|
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 +1261,7 @@ class CheckoutService {
|
|
|
1210
1261
|
return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, user: checkout.user })));
|
|
1211
1262
|
}
|
|
1212
1263
|
clearCheckoutFromSession() {
|
|
1213
|
-
|
|
1214
|
-
return of();
|
|
1264
|
+
return this.dataPersistence.remove('checkoutId');
|
|
1215
1265
|
}
|
|
1216
1266
|
calcDiscount(coupon) {
|
|
1217
1267
|
return this.getCheckout().pipe(concatMap(async (checkout) => await this.couponService.calcDiscountShopping(coupon, checkout)));
|
|
@@ -1225,10 +1275,10 @@ class CheckoutService {
|
|
|
1225
1275
|
...Checkout.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain(),
|
|
1226
1276
|
shop: checkoutData?.shop || this.defaultShop,
|
|
1227
1277
|
});
|
|
1228
|
-
|
|
1278
|
+
await this.dataPersistence.set('checkoutId', checkout.id).toPromise();
|
|
1229
1279
|
return checkout;
|
|
1230
1280
|
}
|
|
1231
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CheckoutService, deps: [{ token: CouponService }, { token: 'CheckoutRepository' }, { token: '
|
|
1281
|
+
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
1282
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CheckoutService }); }
|
|
1233
1283
|
}
|
|
1234
1284
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CheckoutService, decorators: [{
|
|
@@ -1236,15 +1286,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
1236
1286
|
}], ctorParameters: () => [{ type: CouponService }, { type: undefined, decorators: [{
|
|
1237
1287
|
type: Inject,
|
|
1238
1288
|
args: ['CheckoutRepository']
|
|
1239
|
-
}] }, { type: undefined, decorators: [{
|
|
1240
|
-
type: Inject,
|
|
1241
|
-
args: ['OrderRepository']
|
|
1242
1289
|
}] }, { type: undefined, decorators: [{
|
|
1243
1290
|
type: Inject,
|
|
1244
1291
|
args: ['UserRepository']
|
|
1245
1292
|
}] }, { type: i1$2.Shops, decorators: [{
|
|
1246
1293
|
type: Inject,
|
|
1247
1294
|
args: [DEFAULT_SHOP]
|
|
1295
|
+
}] }, { type: undefined, decorators: [{
|
|
1296
|
+
type: Inject,
|
|
1297
|
+
args: [PERSISTENCE_PROVIDER]
|
|
1248
1298
|
}] }] });
|
|
1249
1299
|
|
|
1250
1300
|
class CartService {
|
|
@@ -1306,6 +1356,7 @@ class CartService {
|
|
|
1306
1356
|
weight: weight ?? product.weight,
|
|
1307
1357
|
quantity: (item.quantity || 0) + (quantity || 0),
|
|
1308
1358
|
pricePaid,
|
|
1359
|
+
discount: 0,
|
|
1309
1360
|
categories: product.categories ?? [],
|
|
1310
1361
|
isGift: isGift ?? null,
|
|
1311
1362
|
costPrice: product.costPrice ?? 0,
|
|
@@ -1357,7 +1408,7 @@ class CartService {
|
|
|
1357
1408
|
}), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
|
|
1358
1409
|
}
|
|
1359
1410
|
updateUserCart(user) {
|
|
1360
|
-
return this.checkoutService.getCheckout().pipe(concatMap((checkout) => this.checkoutService.updateCheckoutUser(Checkout.toInstance({ ...checkout.toPlain(), user }))), concatMap(async (checkout) => this.checkoutService
|
|
1411
|
+
return this.checkoutService.getCheckout().pipe(concatMap((checkout) => this.checkoutService.updateCheckoutUser(Checkout.toInstance({ ...checkout.toPlain(), user }))), concatMap(async (checkout) => await this.checkoutService
|
|
1361
1412
|
.updateCheckoutLineItems(Checkout.toInstance({
|
|
1362
1413
|
...checkout.toPlain(),
|
|
1363
1414
|
lineItems: checkout.lineItems?.length
|
|
@@ -1541,9 +1592,11 @@ class NewCategoryStructureAdapter {
|
|
|
1541
1592
|
.then((categories) => categories.map((category) => category.id.toString()));
|
|
1542
1593
|
}
|
|
1543
1594
|
async getCategory(category) {
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1595
|
+
const collectionCategory = category.isCollection ||
|
|
1596
|
+
(isNil(category.isCollection) && !category.products?.length) ||
|
|
1597
|
+
category.isWishlist ||
|
|
1598
|
+
category.brandCategory;
|
|
1599
|
+
return collectionCategory ? this.categoryRepository.get({ id: category.id }) : category;
|
|
1547
1600
|
}
|
|
1548
1601
|
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
1602
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: NewCategoryStructureAdapter }); }
|
|
@@ -1576,8 +1629,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
1576
1629
|
}] }] });
|
|
1577
1630
|
|
|
1578
1631
|
class CatalogService {
|
|
1579
|
-
constructor(productRepository, categoryStructureAdapter, shop, productIndex) {
|
|
1632
|
+
constructor(productRepository, productStockNotificationRepository, categoryRepository, categoryStructureAdapter, shop, productIndex) {
|
|
1580
1633
|
this.productRepository = productRepository;
|
|
1634
|
+
this.productStockNotificationRepository = productStockNotificationRepository;
|
|
1635
|
+
this.categoryRepository = categoryRepository;
|
|
1581
1636
|
this.categoryStructureAdapter = categoryStructureAdapter;
|
|
1582
1637
|
this.shop = shop;
|
|
1583
1638
|
this.productIndex = productIndex;
|
|
@@ -1607,17 +1662,22 @@ class CatalogService {
|
|
|
1607
1662
|
if (!sort || sort === 'most-relevant')
|
|
1608
1663
|
return {};
|
|
1609
1664
|
if (sort === 'best-sellers')
|
|
1610
|
-
return {
|
|
1665
|
+
return {
|
|
1666
|
+
shoppingCount: 'desc',
|
|
1667
|
+
rate: 'desc',
|
|
1668
|
+
stock: 'desc',
|
|
1669
|
+
name: 'asc',
|
|
1670
|
+
};
|
|
1611
1671
|
if (sort === 'biggest-price')
|
|
1612
|
-
return { subscriberPrice: 'desc' };
|
|
1672
|
+
return { subscriberPrice: 'desc', rate: 'desc', shoppingCount: 'desc' };
|
|
1613
1673
|
if (sort === 'lowest-price')
|
|
1614
|
-
return { subscriberPrice: 'asc' };
|
|
1674
|
+
return { subscriberPrice: 'asc', rate: 'desc', shoppingCount: 'desc' };
|
|
1615
1675
|
if (sort === 'best-rating')
|
|
1616
|
-
return { rate: 'desc' };
|
|
1676
|
+
return { rate: 'desc', shoppingCount: 'desc', stock: 'desc', name: 'asc' };
|
|
1617
1677
|
if (sort === 'news')
|
|
1618
1678
|
return { createdAt: 'desc' };
|
|
1619
1679
|
if (sort === 'biggest-discount')
|
|
1620
|
-
return { subscriberDiscountPercentage: 'desc' };
|
|
1680
|
+
return { subscriberDiscountPercentage: 'desc', rate: 'desc', shoppingCount: 'desc' };
|
|
1621
1681
|
};
|
|
1622
1682
|
this.buildLimitQuery = (options) => {
|
|
1623
1683
|
const limit = options?.perPage || 20;
|
|
@@ -1651,9 +1711,26 @@ class CatalogService {
|
|
|
1651
1711
|
brands: distinct?.brand,
|
|
1652
1712
|
}));
|
|
1653
1713
|
}
|
|
1714
|
+
async addCustomerToStockNotification(shop, productId, name, email) {
|
|
1715
|
+
return this.productStockNotificationRepository.addCustomerEmail(shop, productId, name, email);
|
|
1716
|
+
}
|
|
1654
1717
|
async findCatalog(options, limits) {
|
|
1655
|
-
if (this.hasTerm(options) && options.sort === 'most-relevant')
|
|
1656
|
-
|
|
1718
|
+
if (this.hasTerm(options) && options.sort === 'most-relevant') {
|
|
1719
|
+
const productsIds = await this.findCatalogIdsByElasticSearch(options.term);
|
|
1720
|
+
return this.findCatalogAndSortByMostRevelantByTerm(productsIds, options, limits);
|
|
1721
|
+
}
|
|
1722
|
+
if (this.hasCategory(options) && options.sort === 'most-relevant') {
|
|
1723
|
+
const mostRelevant = options.category.mostRelevant ?? [];
|
|
1724
|
+
const productsIds = await this.productRepository
|
|
1725
|
+
.find({
|
|
1726
|
+
fields: ['id'],
|
|
1727
|
+
filters: {
|
|
1728
|
+
...(await this.buildMainFilter(options)),
|
|
1729
|
+
},
|
|
1730
|
+
})
|
|
1731
|
+
.then((products) => products.data.map((product) => product.id));
|
|
1732
|
+
return this.findCatalogAndSortByMostRevelant(mostRelevant, productsIds, options, limits);
|
|
1733
|
+
}
|
|
1657
1734
|
const repoParams = {
|
|
1658
1735
|
filters: {
|
|
1659
1736
|
...(await this.buildMainFilter(options)),
|
|
@@ -1681,8 +1758,32 @@ class CatalogService {
|
|
|
1681
1758
|
.search(term, 999, this.shop)
|
|
1682
1759
|
.then((data) => ({ id: { operator: Where.IN, value: data.hits.map(({ _source }) => _source.id) } }));
|
|
1683
1760
|
}
|
|
1684
|
-
async
|
|
1685
|
-
const
|
|
1761
|
+
async findCatalogAndSortByMostRevelant(mostRelevants, productIds, options, limits) {
|
|
1762
|
+
const mostRelevantProductsIds = [...new Set(mostRelevants.concat(productIds))];
|
|
1763
|
+
const totalResult = await this.productRepository.findCatalog({
|
|
1764
|
+
filters: {
|
|
1765
|
+
id: { operator: Where.IN, value: mostRelevantProductsIds },
|
|
1766
|
+
},
|
|
1767
|
+
orderBy: this.buildSortQuery('news'),
|
|
1768
|
+
options: {
|
|
1769
|
+
minimal: ['price'],
|
|
1770
|
+
maximum: ['price'],
|
|
1771
|
+
distinct: ['brand'],
|
|
1772
|
+
},
|
|
1773
|
+
}, options?.mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female');
|
|
1774
|
+
const firstProducts = totalResult.data.filter((product) => mostRelevants.includes(product.id));
|
|
1775
|
+
const lastProducts = totalResult.data.filter((product) => !mostRelevants.includes(product.id));
|
|
1776
|
+
const categoryMostRelevants = firstProducts.concat(lastProducts);
|
|
1777
|
+
const resultFinal = categoryMostRelevants.slice(limits.offset, limits.offset + limits.limit);
|
|
1778
|
+
return {
|
|
1779
|
+
data: resultFinal,
|
|
1780
|
+
count: totalResult.count,
|
|
1781
|
+
maximum: totalResult.maximum,
|
|
1782
|
+
minimal: totalResult.minimal,
|
|
1783
|
+
distinct: totalResult.distinct,
|
|
1784
|
+
};
|
|
1785
|
+
}
|
|
1786
|
+
async findCatalogAndSortByMostRevelantByTerm(productIds, options, limits) {
|
|
1686
1787
|
const totalResult = await this.productRepository.findCatalog({
|
|
1687
1788
|
fields: ['id', 'stock'],
|
|
1688
1789
|
filters: {
|
|
@@ -1728,7 +1829,7 @@ class CatalogService {
|
|
|
1728
1829
|
return [...new Set(sorted.map(({ _source }) => _source.id))];
|
|
1729
1830
|
}));
|
|
1730
1831
|
}
|
|
1731
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CatalogService, deps: [{ token: 'ProductRepository' }, { token: CATEGORY_STRUCTURE }, { token: DEFAULT_SHOP }, { token: i1$2.ProductsIndex }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1832
|
+
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 }); }
|
|
1732
1833
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CatalogService }); }
|
|
1733
1834
|
}
|
|
1734
1835
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CatalogService, decorators: [{
|
|
@@ -1736,6 +1837,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
1736
1837
|
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
1737
1838
|
type: Inject,
|
|
1738
1839
|
args: ['ProductRepository']
|
|
1840
|
+
}] }, { type: undefined, decorators: [{
|
|
1841
|
+
type: Inject,
|
|
1842
|
+
args: ['ProductStockNotificationRepository']
|
|
1843
|
+
}] }, { type: undefined, decorators: [{
|
|
1844
|
+
type: Inject,
|
|
1845
|
+
args: ['CategoryRepository']
|
|
1739
1846
|
}] }, { type: undefined, decorators: [{
|
|
1740
1847
|
type: Inject,
|
|
1741
1848
|
args: [CATEGORY_STRUCTURE]
|
|
@@ -1752,15 +1859,15 @@ class CategoryService {
|
|
|
1752
1859
|
this.categoryStructureAdapter = categoryStructureAdapter;
|
|
1753
1860
|
this.shop = shop;
|
|
1754
1861
|
}
|
|
1755
|
-
async fetchBrands(category,
|
|
1862
|
+
async fetchBrands(category, options) {
|
|
1756
1863
|
const brands = await this.productRepository
|
|
1757
1864
|
.findCatalog({
|
|
1758
1865
|
filters: await this.categoryStructureAdapter.buildProductFilterByCategory(category),
|
|
1759
1866
|
fields: ['brand'],
|
|
1760
|
-
}, mainGender
|
|
1867
|
+
}, options?.mainGender ? options?.mainGender : this.shop === Shops.MENSMARKET ? 'male' : 'female')
|
|
1761
1868
|
.then(({ data }) => Object.keys(data.map((product) => product.brand).reduce((brands, brand) => ({ ...brands, [brand]: true }), {})));
|
|
1762
1869
|
return this.categoryRepository
|
|
1763
|
-
.find({ filters: { brandCategory: true, shop: this.shop }, orderBy: { name: 'asc' } })
|
|
1870
|
+
.find({ filters: { brandCategory: true, shop: options?.shop || this.shop }, orderBy: { name: 'asc' } })
|
|
1764
1871
|
.then(({ data }) => data.filter((category) => brands.includes(category.conditions.brand)));
|
|
1765
1872
|
}
|
|
1766
1873
|
async fetchFilterOptions(category) {
|
|
@@ -1809,12 +1916,11 @@ __decorate([
|
|
|
1809
1916
|
], CategoryWithTree.prototype, "children", void 0);
|
|
1810
1917
|
|
|
1811
1918
|
class WishlistService {
|
|
1812
|
-
constructor(wishlistRepository,
|
|
1919
|
+
constructor(wishlistRepository, shop, productRepository, categoryFilterRepository, categoryRepository, productStockNotificationRepository, productIndex) {
|
|
1813
1920
|
this.wishlistRepository = wishlistRepository;
|
|
1814
|
-
this.categoryRepository = categoryRepository;
|
|
1815
1921
|
this.shop = shop;
|
|
1816
1922
|
const categoryStructureAdapter = new NewCategoryStructureAdapter(wishlistRepository);
|
|
1817
|
-
this.catalogService = new CatalogService(productRepository, categoryStructureAdapter, shop, productIndex);
|
|
1923
|
+
this.catalogService = new CatalogService(productRepository, productStockNotificationRepository, categoryRepository, categoryStructureAdapter, shop, productIndex);
|
|
1818
1924
|
this.categoryService = new CategoryService(productRepository, categoryRepository, categoryFilterRepository, categoryStructureAdapter, shop);
|
|
1819
1925
|
}
|
|
1820
1926
|
getCatalogService() {
|
|
@@ -1823,7 +1929,7 @@ class WishlistService {
|
|
|
1823
1929
|
getCategoryService() {
|
|
1824
1930
|
return this.categoryService;
|
|
1825
1931
|
}
|
|
1826
|
-
async create({ personId, title, description, userFullName, userPhoto, theme, bannerUrl, }) {
|
|
1932
|
+
async create({ personId, title, description, published, userFullName, userPhoto, theme, bannerUrl, }) {
|
|
1827
1933
|
const data = {
|
|
1828
1934
|
slug: '',
|
|
1829
1935
|
name: title,
|
|
@@ -1838,7 +1944,7 @@ class WishlistService {
|
|
|
1838
1944
|
personName: userFullName,
|
|
1839
1945
|
personPhoto: userPhoto,
|
|
1840
1946
|
brandCategory: false,
|
|
1841
|
-
published
|
|
1947
|
+
published,
|
|
1842
1948
|
theme,
|
|
1843
1949
|
bannerUrl,
|
|
1844
1950
|
};
|
|
@@ -1846,11 +1952,12 @@ class WishlistService {
|
|
|
1846
1952
|
await this.wishlistRepository.update({ id: newWishlist.id, slug: newWishlist.id });
|
|
1847
1953
|
return Wishlist.toInstance({ ...newWishlist.toPlain(), slug: newWishlist.id });
|
|
1848
1954
|
}
|
|
1849
|
-
update({ id, title, description, userFullName, userPhoto, theme, bannerUrl, }) {
|
|
1955
|
+
update({ id, title, description, published, userFullName, userPhoto, theme, bannerUrl, }) {
|
|
1850
1956
|
const data = {
|
|
1851
1957
|
id,
|
|
1852
1958
|
name: title,
|
|
1853
1959
|
description,
|
|
1960
|
+
published,
|
|
1854
1961
|
metadata: {
|
|
1855
1962
|
title: `${userFullName} - ${title}`,
|
|
1856
1963
|
description: `${userFullName} - ${description}`,
|
|
@@ -1894,7 +2001,7 @@ class WishlistService {
|
|
|
1894
2001
|
}
|
|
1895
2002
|
return wishlist;
|
|
1896
2003
|
}
|
|
1897
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: WishlistService, deps: [{ token: 'WishlistRepository' }, { token: '
|
|
2004
|
+
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 }); }
|
|
1898
2005
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: WishlistService }); }
|
|
1899
2006
|
}
|
|
1900
2007
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: WishlistService, decorators: [{
|
|
@@ -1902,9 +2009,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
1902
2009
|
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
1903
2010
|
type: Inject,
|
|
1904
2011
|
args: ['WishlistRepository']
|
|
1905
|
-
}] }, { type: undefined, decorators: [{
|
|
1906
|
-
type: Inject,
|
|
1907
|
-
args: ['CategoryRepository']
|
|
1908
2012
|
}] }, { type: i1$2.Shops, decorators: [{
|
|
1909
2013
|
type: Inject,
|
|
1910
2014
|
args: [DEFAULT_SHOP]
|
|
@@ -1914,31 +2018,27 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
1914
2018
|
}] }, { type: undefined, decorators: [{
|
|
1915
2019
|
type: Inject,
|
|
1916
2020
|
args: ['CategoryFilterRepository']
|
|
2021
|
+
}] }, { type: undefined, decorators: [{
|
|
2022
|
+
type: Inject,
|
|
2023
|
+
args: ['CategoryRepository']
|
|
2024
|
+
}] }, { type: undefined, decorators: [{
|
|
2025
|
+
type: Inject,
|
|
2026
|
+
args: ['ProductStockNotificationRepository']
|
|
1917
2027
|
}] }, { type: i1$2.ProductsIndex }] });
|
|
1918
2028
|
|
|
1919
2029
|
class CheckoutSubscriptionService {
|
|
1920
|
-
constructor(checkoutSubscriptionRepository,
|
|
2030
|
+
constructor(checkoutSubscriptionRepository, dataPersistence, couponService) {
|
|
1921
2031
|
this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
|
|
1922
|
-
this.
|
|
2032
|
+
this.dataPersistence = dataPersistence;
|
|
1923
2033
|
this.couponService = couponService;
|
|
1924
2034
|
}
|
|
1925
2035
|
getCheckoutSubscription(checkoutData) {
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
return from(this.createCheckoutSubscription(checkoutData));
|
|
1930
|
-
}
|
|
1931
|
-
async createCheckoutSubscription(checkoutData) {
|
|
1932
|
-
const checkout = await this.checkoutSubscriptionRepository.create({
|
|
1933
|
-
createdAt: new Date(),
|
|
1934
|
-
...CheckoutSubscription.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain(),
|
|
1935
|
-
});
|
|
1936
|
-
cookie.set('checkoutSubscriptionId', checkout.id);
|
|
1937
|
-
return checkout;
|
|
2036
|
+
return this.dataPersistence
|
|
2037
|
+
.get('checkoutSubscriptionId')
|
|
2038
|
+
.pipe(concatMap((id) => !isNil(id) ? this.checkoutSubscriptionRepository.get({ id }) : this.createCheckoutSubscription(checkoutData)));
|
|
1938
2039
|
}
|
|
1939
2040
|
clearCheckoutSubscriptionFromSession() {
|
|
1940
|
-
|
|
1941
|
-
return of();
|
|
2041
|
+
return this.dataPersistence.remove('checkoutSubscriptionId');
|
|
1942
2042
|
}
|
|
1943
2043
|
checkCoupon(nickname, userEmail) {
|
|
1944
2044
|
return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService
|
|
@@ -1948,7 +2048,15 @@ class CheckoutSubscriptionService {
|
|
|
1948
2048
|
calcDiscountSubscription(coupon) {
|
|
1949
2049
|
return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService.calcDiscountSubscription(coupon, checkout).pipe()));
|
|
1950
2050
|
}
|
|
1951
|
-
|
|
2051
|
+
async createCheckoutSubscription(checkoutData) {
|
|
2052
|
+
const checkout = await this.checkoutSubscriptionRepository.create({
|
|
2053
|
+
createdAt: new Date(),
|
|
2054
|
+
...CheckoutSubscription.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain(),
|
|
2055
|
+
});
|
|
2056
|
+
await this.dataPersistence.set('checkoutSubscriptionId', checkout.id).toPromise();
|
|
2057
|
+
return checkout;
|
|
2058
|
+
}
|
|
2059
|
+
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 }); }
|
|
1952
2060
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CheckoutSubscriptionService }); }
|
|
1953
2061
|
}
|
|
1954
2062
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CheckoutSubscriptionService, decorators: [{
|
|
@@ -1958,7 +2066,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
1958
2066
|
args: ['CheckoutSubscriptionRepository']
|
|
1959
2067
|
}] }, { type: undefined, decorators: [{
|
|
1960
2068
|
type: Inject,
|
|
1961
|
-
args: [
|
|
2069
|
+
args: [PERSISTENCE_PROVIDER]
|
|
1962
2070
|
}] }, { type: CouponService }] });
|
|
1963
2071
|
|
|
1964
2072
|
class UtilHelper {
|
|
@@ -2216,6 +2324,7 @@ class AngularConnectModule {
|
|
|
2216
2324
|
? OldCategoryStructureAdapter
|
|
2217
2325
|
: NewCategoryStructureAdapter,
|
|
2218
2326
|
},
|
|
2327
|
+
{ provide: PERSISTENCE_PROVIDER, useClass: options?.persistenceProvider || CookieDataPersistence },
|
|
2219
2328
|
...(isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]),
|
|
2220
2329
|
...(isNil(options?.firebase) ? [] : [{ provide: FIREBASE_OPTIONS, useValue: options?.firebase }]),
|
|
2221
2330
|
...(isNil(options?.firebase) ? [] : [{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig }]),
|
|
@@ -2227,7 +2336,7 @@ class AngularConnectModule {
|
|
|
2227
2336
|
};
|
|
2228
2337
|
}
|
|
2229
2338
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AngularConnectModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
2230
|
-
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.0.3", ngImport: i0, type: AngularConnectModule, imports: [i1$4.FirebaseAppModule, AngularElasticSeachModule,
|
|
2339
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.0.3", ngImport: i0, type: AngularConnectModule, imports: [i1$4.FirebaseAppModule, i2.StorageModule, AngularElasticSeachModule,
|
|
2231
2340
|
AngularFirebaseAuthModule,
|
|
2232
2341
|
AngularFirestoreModule,
|
|
2233
2342
|
AngularHasuraGraphQLModule] }); }
|
|
@@ -2250,6 +2359,13 @@ class AngularConnectModule {
|
|
|
2250
2359
|
},
|
|
2251
2360
|
deps: ['UserRepository', 'FileUploaderService'],
|
|
2252
2361
|
},
|
|
2362
|
+
{
|
|
2363
|
+
provide: 'FileUploaderService',
|
|
2364
|
+
useFactory: (storage, baseUrl) => {
|
|
2365
|
+
return new FirebaseFileUploaderService(storage, baseUrl);
|
|
2366
|
+
},
|
|
2367
|
+
deps: [Storage, STORAGE_BASE_URL],
|
|
2368
|
+
},
|
|
2253
2369
|
], imports: [provideFirebaseApp((injector) => {
|
|
2254
2370
|
const appName = injector.get(FIREBASE_APP_NAME) || '[DEFAULT]';
|
|
2255
2371
|
try {
|
|
@@ -2259,6 +2375,7 @@ class AngularConnectModule {
|
|
|
2259
2375
|
return initializeApp(injector.get(FIREBASE_OPTIONS), appName);
|
|
2260
2376
|
}
|
|
2261
2377
|
}),
|
|
2378
|
+
provideStorage((injector) => getStorage(injector.get(FirebaseApp))),
|
|
2262
2379
|
AngularElasticSeachModule,
|
|
2263
2380
|
AngularFirebaseAuthModule,
|
|
2264
2381
|
AngularFirestoreModule,
|
|
@@ -2277,6 +2394,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
2277
2394
|
return initializeApp(injector.get(FIREBASE_OPTIONS), appName);
|
|
2278
2395
|
}
|
|
2279
2396
|
}),
|
|
2397
|
+
provideStorage((injector) => getStorage(injector.get(FirebaseApp))),
|
|
2280
2398
|
AngularElasticSeachModule,
|
|
2281
2399
|
AngularFirebaseAuthModule,
|
|
2282
2400
|
AngularFirestoreModule,
|
|
@@ -2301,6 +2419,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
2301
2419
|
},
|
|
2302
2420
|
deps: ['UserRepository', 'FileUploaderService'],
|
|
2303
2421
|
},
|
|
2422
|
+
{
|
|
2423
|
+
provide: 'FileUploaderService',
|
|
2424
|
+
useFactory: (storage, baseUrl) => {
|
|
2425
|
+
return new FirebaseFileUploaderService(storage, baseUrl);
|
|
2426
|
+
},
|
|
2427
|
+
deps: [Storage, STORAGE_BASE_URL],
|
|
2428
|
+
},
|
|
2304
2429
|
],
|
|
2305
2430
|
}]
|
|
2306
2431
|
}] });
|
|
@@ -2309,5 +2434,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
2309
2434
|
* Generated bundle index. Do not edit.
|
|
2310
2435
|
*/
|
|
2311
2436
|
|
|
2312
|
-
export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule, AuthService, CartService, CatalogService, CategoryService, CategoryWithTree, CheckoutService, CheckoutSubscriptionService, CouponService, HomeShopService, NewCategoryStructureAdapter, OldCategoryStructureAdapter, OrderService, ProductSorts, ShippingService, UtilHelper, WishlistService };
|
|
2437
|
+
export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule, AuthService, CartService, CatalogService, CategoryService, CategoryWithTree, CheckoutService, CheckoutSubscriptionService, CookieDataPersistence, CouponService, HomeShopService, NewCategoryStructureAdapter, OldCategoryStructureAdapter, OrderService, ProductSorts, ShippingService, UtilHelper, WishlistService };
|
|
2313
2438
|
//# sourceMappingURL=infrab4a-connect-angular.mjs.map
|