@infrab4a/connect-angular 5.0.0-beta.3 → 5.0.0-beta.30
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 +69 -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 +236 -109
- 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 +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,27 @@ 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
|
+
.findCatalog({
|
|
1726
|
+
fields: ['id'],
|
|
1727
|
+
filters: {
|
|
1728
|
+
...(await this.buildMainFilter(options)),
|
|
1729
|
+
...this.buildFilterQuery(options?.filters || {}),
|
|
1730
|
+
},
|
|
1731
|
+
})
|
|
1732
|
+
.then((products) => products.data.map((product) => product.id));
|
|
1733
|
+
return this.findCatalogAndSortByMostRevelant(mostRelevant, productsIds, options, limits);
|
|
1734
|
+
}
|
|
1657
1735
|
const repoParams = {
|
|
1658
1736
|
filters: {
|
|
1659
1737
|
...(await this.buildMainFilter(options)),
|
|
@@ -1681,8 +1759,33 @@ class CatalogService {
|
|
|
1681
1759
|
.search(term, 999, this.shop)
|
|
1682
1760
|
.then((data) => ({ id: { operator: Where.IN, value: data.hits.map(({ _source }) => _source.id) } }));
|
|
1683
1761
|
}
|
|
1684
|
-
async
|
|
1685
|
-
const
|
|
1762
|
+
async findCatalogAndSortByMostRevelant(mostRelevants, productIds, options, limits) {
|
|
1763
|
+
const mostRelevantProductsIds = [...new Set(mostRelevants.concat(productIds))];
|
|
1764
|
+
const totalResult = await this.productRepository.findCatalog({
|
|
1765
|
+
filters: {
|
|
1766
|
+
id: { operator: Where.IN, value: mostRelevantProductsIds },
|
|
1767
|
+
...this.buildFilterQuery(options?.filters || {}),
|
|
1768
|
+
},
|
|
1769
|
+
orderBy: this.buildSortQuery('news'),
|
|
1770
|
+
options: {
|
|
1771
|
+
minimal: ['price'],
|
|
1772
|
+
maximum: ['price'],
|
|
1773
|
+
distinct: ['brand'],
|
|
1774
|
+
},
|
|
1775
|
+
}, options?.mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female');
|
|
1776
|
+
const firstProducts = totalResult.data.filter((product) => mostRelevants.includes(product.id));
|
|
1777
|
+
const lastProducts = totalResult.data.filter((product) => !mostRelevants.includes(product.id));
|
|
1778
|
+
const categoryMostRelevants = firstProducts.concat(lastProducts);
|
|
1779
|
+
const resultFinal = categoryMostRelevants.slice(limits.offset, limits.offset + limits.limit);
|
|
1780
|
+
return {
|
|
1781
|
+
data: resultFinal,
|
|
1782
|
+
count: totalResult.count,
|
|
1783
|
+
maximum: totalResult.maximum,
|
|
1784
|
+
minimal: totalResult.minimal,
|
|
1785
|
+
distinct: totalResult.distinct,
|
|
1786
|
+
};
|
|
1787
|
+
}
|
|
1788
|
+
async findCatalogAndSortByMostRevelantByTerm(productIds, options, limits) {
|
|
1686
1789
|
const totalResult = await this.productRepository.findCatalog({
|
|
1687
1790
|
fields: ['id', 'stock'],
|
|
1688
1791
|
filters: {
|
|
@@ -1728,7 +1831,7 @@ class CatalogService {
|
|
|
1728
1831
|
return [...new Set(sorted.map(({ _source }) => _source.id))];
|
|
1729
1832
|
}));
|
|
1730
1833
|
}
|
|
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 }); }
|
|
1834
|
+
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
1835
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CatalogService }); }
|
|
1733
1836
|
}
|
|
1734
1837
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CatalogService, decorators: [{
|
|
@@ -1736,6 +1839,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
1736
1839
|
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
1737
1840
|
type: Inject,
|
|
1738
1841
|
args: ['ProductRepository']
|
|
1842
|
+
}] }, { type: undefined, decorators: [{
|
|
1843
|
+
type: Inject,
|
|
1844
|
+
args: ['ProductStockNotificationRepository']
|
|
1845
|
+
}] }, { type: undefined, decorators: [{
|
|
1846
|
+
type: Inject,
|
|
1847
|
+
args: ['CategoryRepository']
|
|
1739
1848
|
}] }, { type: undefined, decorators: [{
|
|
1740
1849
|
type: Inject,
|
|
1741
1850
|
args: [CATEGORY_STRUCTURE]
|
|
@@ -1752,15 +1861,15 @@ class CategoryService {
|
|
|
1752
1861
|
this.categoryStructureAdapter = categoryStructureAdapter;
|
|
1753
1862
|
this.shop = shop;
|
|
1754
1863
|
}
|
|
1755
|
-
async fetchBrands(category,
|
|
1864
|
+
async fetchBrands(category, options) {
|
|
1756
1865
|
const brands = await this.productRepository
|
|
1757
1866
|
.findCatalog({
|
|
1758
1867
|
filters: await this.categoryStructureAdapter.buildProductFilterByCategory(category),
|
|
1759
1868
|
fields: ['brand'],
|
|
1760
|
-
}, mainGender
|
|
1869
|
+
}, options?.mainGender ? options?.mainGender : this.shop === Shops.MENSMARKET ? 'male' : 'female')
|
|
1761
1870
|
.then(({ data }) => Object.keys(data.map((product) => product.brand).reduce((brands, brand) => ({ ...brands, [brand]: true }), {})));
|
|
1762
1871
|
return this.categoryRepository
|
|
1763
|
-
.find({ filters: { brandCategory: true, shop: this.shop }, orderBy: { name: 'asc' } })
|
|
1872
|
+
.find({ filters: { brandCategory: true, shop: options?.shop || this.shop }, orderBy: { name: 'asc' } })
|
|
1764
1873
|
.then(({ data }) => data.filter((category) => brands.includes(category.conditions.brand)));
|
|
1765
1874
|
}
|
|
1766
1875
|
async fetchFilterOptions(category) {
|
|
@@ -1809,12 +1918,11 @@ __decorate([
|
|
|
1809
1918
|
], CategoryWithTree.prototype, "children", void 0);
|
|
1810
1919
|
|
|
1811
1920
|
class WishlistService {
|
|
1812
|
-
constructor(wishlistRepository,
|
|
1921
|
+
constructor(wishlistRepository, shop, productRepository, categoryFilterRepository, categoryRepository, productStockNotificationRepository, productIndex) {
|
|
1813
1922
|
this.wishlistRepository = wishlistRepository;
|
|
1814
|
-
this.categoryRepository = categoryRepository;
|
|
1815
1923
|
this.shop = shop;
|
|
1816
1924
|
const categoryStructureAdapter = new NewCategoryStructureAdapter(wishlistRepository);
|
|
1817
|
-
this.catalogService = new CatalogService(productRepository, categoryStructureAdapter, shop, productIndex);
|
|
1925
|
+
this.catalogService = new CatalogService(productRepository, productStockNotificationRepository, categoryRepository, categoryStructureAdapter, shop, productIndex);
|
|
1818
1926
|
this.categoryService = new CategoryService(productRepository, categoryRepository, categoryFilterRepository, categoryStructureAdapter, shop);
|
|
1819
1927
|
}
|
|
1820
1928
|
getCatalogService() {
|
|
@@ -1823,7 +1931,7 @@ class WishlistService {
|
|
|
1823
1931
|
getCategoryService() {
|
|
1824
1932
|
return this.categoryService;
|
|
1825
1933
|
}
|
|
1826
|
-
async create({ personId, title, description, userFullName, userPhoto, theme, bannerUrl, }) {
|
|
1934
|
+
async create({ personId, title, description, published, userFullName, userPhoto, theme, bannerUrl, }) {
|
|
1827
1935
|
const data = {
|
|
1828
1936
|
slug: '',
|
|
1829
1937
|
name: title,
|
|
@@ -1838,7 +1946,7 @@ class WishlistService {
|
|
|
1838
1946
|
personName: userFullName,
|
|
1839
1947
|
personPhoto: userPhoto,
|
|
1840
1948
|
brandCategory: false,
|
|
1841
|
-
published
|
|
1949
|
+
published,
|
|
1842
1950
|
theme,
|
|
1843
1951
|
bannerUrl,
|
|
1844
1952
|
};
|
|
@@ -1846,11 +1954,12 @@ class WishlistService {
|
|
|
1846
1954
|
await this.wishlistRepository.update({ id: newWishlist.id, slug: newWishlist.id });
|
|
1847
1955
|
return Wishlist.toInstance({ ...newWishlist.toPlain(), slug: newWishlist.id });
|
|
1848
1956
|
}
|
|
1849
|
-
update({ id, title, description, userFullName, userPhoto, theme, bannerUrl, }) {
|
|
1957
|
+
update({ id, title, description, published, userFullName, userPhoto, theme, bannerUrl, }) {
|
|
1850
1958
|
const data = {
|
|
1851
1959
|
id,
|
|
1852
1960
|
name: title,
|
|
1853
1961
|
description,
|
|
1962
|
+
published,
|
|
1854
1963
|
metadata: {
|
|
1855
1964
|
title: `${userFullName} - ${title}`,
|
|
1856
1965
|
description: `${userFullName} - ${description}`,
|
|
@@ -1894,7 +2003,7 @@ class WishlistService {
|
|
|
1894
2003
|
}
|
|
1895
2004
|
return wishlist;
|
|
1896
2005
|
}
|
|
1897
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: WishlistService, deps: [{ token: 'WishlistRepository' }, { token: '
|
|
2006
|
+
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
2007
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: WishlistService }); }
|
|
1899
2008
|
}
|
|
1900
2009
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: WishlistService, decorators: [{
|
|
@@ -1902,9 +2011,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
1902
2011
|
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
1903
2012
|
type: Inject,
|
|
1904
2013
|
args: ['WishlistRepository']
|
|
1905
|
-
}] }, { type: undefined, decorators: [{
|
|
1906
|
-
type: Inject,
|
|
1907
|
-
args: ['CategoryRepository']
|
|
1908
2014
|
}] }, { type: i1$2.Shops, decorators: [{
|
|
1909
2015
|
type: Inject,
|
|
1910
2016
|
args: [DEFAULT_SHOP]
|
|
@@ -1914,31 +2020,27 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
1914
2020
|
}] }, { type: undefined, decorators: [{
|
|
1915
2021
|
type: Inject,
|
|
1916
2022
|
args: ['CategoryFilterRepository']
|
|
2023
|
+
}] }, { type: undefined, decorators: [{
|
|
2024
|
+
type: Inject,
|
|
2025
|
+
args: ['CategoryRepository']
|
|
2026
|
+
}] }, { type: undefined, decorators: [{
|
|
2027
|
+
type: Inject,
|
|
2028
|
+
args: ['ProductStockNotificationRepository']
|
|
1917
2029
|
}] }, { type: i1$2.ProductsIndex }] });
|
|
1918
2030
|
|
|
1919
2031
|
class CheckoutSubscriptionService {
|
|
1920
|
-
constructor(checkoutSubscriptionRepository,
|
|
2032
|
+
constructor(checkoutSubscriptionRepository, dataPersistence, couponService) {
|
|
1921
2033
|
this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
|
|
1922
|
-
this.
|
|
2034
|
+
this.dataPersistence = dataPersistence;
|
|
1923
2035
|
this.couponService = couponService;
|
|
1924
2036
|
}
|
|
1925
2037
|
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;
|
|
2038
|
+
return this.dataPersistence
|
|
2039
|
+
.get('checkoutSubscriptionId')
|
|
2040
|
+
.pipe(concatMap((id) => !isNil(id) ? this.checkoutSubscriptionRepository.get({ id }) : this.createCheckoutSubscription(checkoutData)));
|
|
1938
2041
|
}
|
|
1939
2042
|
clearCheckoutSubscriptionFromSession() {
|
|
1940
|
-
|
|
1941
|
-
return of();
|
|
2043
|
+
return this.dataPersistence.remove('checkoutSubscriptionId');
|
|
1942
2044
|
}
|
|
1943
2045
|
checkCoupon(nickname, userEmail) {
|
|
1944
2046
|
return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService
|
|
@@ -1948,7 +2050,15 @@ class CheckoutSubscriptionService {
|
|
|
1948
2050
|
calcDiscountSubscription(coupon) {
|
|
1949
2051
|
return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService.calcDiscountSubscription(coupon, checkout).pipe()));
|
|
1950
2052
|
}
|
|
1951
|
-
|
|
2053
|
+
async createCheckoutSubscription(checkoutData) {
|
|
2054
|
+
const checkout = await this.checkoutSubscriptionRepository.create({
|
|
2055
|
+
createdAt: new Date(),
|
|
2056
|
+
...CheckoutSubscription.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain(),
|
|
2057
|
+
});
|
|
2058
|
+
await this.dataPersistence.set('checkoutSubscriptionId', checkout.id).toPromise();
|
|
2059
|
+
return checkout;
|
|
2060
|
+
}
|
|
2061
|
+
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
2062
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CheckoutSubscriptionService }); }
|
|
1953
2063
|
}
|
|
1954
2064
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CheckoutSubscriptionService, decorators: [{
|
|
@@ -1958,7 +2068,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
1958
2068
|
args: ['CheckoutSubscriptionRepository']
|
|
1959
2069
|
}] }, { type: undefined, decorators: [{
|
|
1960
2070
|
type: Inject,
|
|
1961
|
-
args: [
|
|
2071
|
+
args: [PERSISTENCE_PROVIDER]
|
|
1962
2072
|
}] }, { type: CouponService }] });
|
|
1963
2073
|
|
|
1964
2074
|
class UtilHelper {
|
|
@@ -2216,6 +2326,7 @@ class AngularConnectModule {
|
|
|
2216
2326
|
? OldCategoryStructureAdapter
|
|
2217
2327
|
: NewCategoryStructureAdapter,
|
|
2218
2328
|
},
|
|
2329
|
+
{ provide: PERSISTENCE_PROVIDER, useClass: options?.persistenceProvider || CookieDataPersistence },
|
|
2219
2330
|
...(isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]),
|
|
2220
2331
|
...(isNil(options?.firebase) ? [] : [{ provide: FIREBASE_OPTIONS, useValue: options?.firebase }]),
|
|
2221
2332
|
...(isNil(options?.firebase) ? [] : [{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig }]),
|
|
@@ -2227,7 +2338,7 @@ class AngularConnectModule {
|
|
|
2227
2338
|
};
|
|
2228
2339
|
}
|
|
2229
2340
|
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,
|
|
2341
|
+
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
2342
|
AngularFirebaseAuthModule,
|
|
2232
2343
|
AngularFirestoreModule,
|
|
2233
2344
|
AngularHasuraGraphQLModule] }); }
|
|
@@ -2250,6 +2361,13 @@ class AngularConnectModule {
|
|
|
2250
2361
|
},
|
|
2251
2362
|
deps: ['UserRepository', 'FileUploaderService'],
|
|
2252
2363
|
},
|
|
2364
|
+
{
|
|
2365
|
+
provide: 'FileUploaderService',
|
|
2366
|
+
useFactory: (storage, baseUrl) => {
|
|
2367
|
+
return new FirebaseFileUploaderService(storage, baseUrl);
|
|
2368
|
+
},
|
|
2369
|
+
deps: [Storage, STORAGE_BASE_URL],
|
|
2370
|
+
},
|
|
2253
2371
|
], imports: [provideFirebaseApp((injector) => {
|
|
2254
2372
|
const appName = injector.get(FIREBASE_APP_NAME) || '[DEFAULT]';
|
|
2255
2373
|
try {
|
|
@@ -2259,6 +2377,7 @@ class AngularConnectModule {
|
|
|
2259
2377
|
return initializeApp(injector.get(FIREBASE_OPTIONS), appName);
|
|
2260
2378
|
}
|
|
2261
2379
|
}),
|
|
2380
|
+
provideStorage((injector) => getStorage(injector.get(FirebaseApp))),
|
|
2262
2381
|
AngularElasticSeachModule,
|
|
2263
2382
|
AngularFirebaseAuthModule,
|
|
2264
2383
|
AngularFirestoreModule,
|
|
@@ -2277,6 +2396,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
2277
2396
|
return initializeApp(injector.get(FIREBASE_OPTIONS), appName);
|
|
2278
2397
|
}
|
|
2279
2398
|
}),
|
|
2399
|
+
provideStorage((injector) => getStorage(injector.get(FirebaseApp))),
|
|
2280
2400
|
AngularElasticSeachModule,
|
|
2281
2401
|
AngularFirebaseAuthModule,
|
|
2282
2402
|
AngularFirestoreModule,
|
|
@@ -2301,6 +2421,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
2301
2421
|
},
|
|
2302
2422
|
deps: ['UserRepository', 'FileUploaderService'],
|
|
2303
2423
|
},
|
|
2424
|
+
{
|
|
2425
|
+
provide: 'FileUploaderService',
|
|
2426
|
+
useFactory: (storage, baseUrl) => {
|
|
2427
|
+
return new FirebaseFileUploaderService(storage, baseUrl);
|
|
2428
|
+
},
|
|
2429
|
+
deps: [Storage, STORAGE_BASE_URL],
|
|
2430
|
+
},
|
|
2304
2431
|
],
|
|
2305
2432
|
}]
|
|
2306
2433
|
}] });
|
|
@@ -2309,5 +2436,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
2309
2436
|
* Generated bundle index. Do not edit.
|
|
2310
2437
|
*/
|
|
2311
2438
|
|
|
2312
|
-
export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule, AuthService, CartService, CatalogService, CategoryService, CategoryWithTree, CheckoutService, CheckoutSubscriptionService, CouponService, HomeShopService, NewCategoryStructureAdapter, OldCategoryStructureAdapter, OrderService, ProductSorts, ShippingService, UtilHelper, WishlistService };
|
|
2439
|
+
export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule, AuthService, CartService, CatalogService, CategoryService, CategoryWithTree, CheckoutService, CheckoutSubscriptionService, CookieDataPersistence, CouponService, HomeShopService, NewCategoryStructureAdapter, OldCategoryStructureAdapter, OrderService, ProductSorts, ShippingService, UtilHelper, WishlistService };
|
|
2313
2440
|
//# sourceMappingURL=infrab4a-connect-angular.mjs.map
|