@infrab4a/connect-angular 5.0.0-beta.39 → 5.0.0-beta.4
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 +6 -9
- package/angular-firestore.module.d.ts +2 -1
- package/consts/index.d.ts +0 -1
- package/esm2022/angular-connect.module.mjs +5 -25
- package/esm2022/angular-firestore.module.mjs +34 -17
- package/esm2022/angular-hasura-graphql.module.mjs +2 -24
- package/esm2022/consts/index.mjs +1 -2
- package/esm2022/index.mjs +1 -2
- package/esm2022/services/cart.service.mjs +10 -11
- package/esm2022/services/catalog/adapters/new-category-structure.adapter.mjs +4 -6
- package/esm2022/services/catalog/catalog.service.mjs +13 -69
- package/esm2022/services/catalog/category.service.mjs +4 -4
- package/esm2022/services/catalog/wishlist.service.mjs +19 -28
- package/esm2022/services/checkout-subscription.service.mjs +21 -18
- package/esm2022/services/checkout.service.mjs +16 -13
- package/esm2022/services/coupon.service.mjs +10 -35
- package/fesm2022/infrab4a-connect-angular.mjs +123 -256
- package/fesm2022/infrab4a-connect-angular.mjs.map +1 -1
- package/index.d.ts +0 -1
- package/package.json +7 -7
- package/services/catalog/catalog.service.d.ts +4 -10
- package/services/catalog/category.service.d.ts +1 -6
- package/services/catalog/wishlist.service.d.ts +5 -6
- package/services/checkout-subscription.service.d.ts +4 -5
- package/services/checkout.service.d.ts +4 -8
- package/services/coupon.service.d.ts +2 -6
- package/consts/persistence.const.d.ts +0 -1
- package/esm2022/consts/persistence.const.mjs +0 -2
- package/esm2022/persistence/cookie-data-persistence.mjs +0 -22
- package/esm2022/persistence/data-persistence.mjs +0 -2
- package/esm2022/persistence/index.mjs +0 -3
- package/persistence/cookie-data-persistence.d.ts +0 -10
- package/persistence/data-persistence.d.ts +0 -6
- package/persistence/index.d.ts +0 -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,
|
|
5
|
-
import * as i2 from '@angular/fire/storage';
|
|
6
|
-
import { Storage, provideStorage, getStorage } from '@angular/fire/storage';
|
|
4
|
+
import { FirebaseApp, getApp, initializeApp, provideFirebaseApp } from '@angular/fire/app';
|
|
7
5
|
import * as i1$2 from '@infrab4a/connect';
|
|
8
|
-
import { ProductsIndex, AxiosAdapter, Authentication, AuthenticationFirebaseAuthService, Register, RegisterFirebaseAuthService, SignOut, RecoveryPassword,
|
|
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, FirebaseFileUploaderService, CategoryHasuraGraphQLRepository, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository, ProductReviewsHasuraGraphQLRepository, VariantHasuraGraphQLRepository, 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 } from '@infrab4a/connect';
|
|
9
7
|
import * as i1 from '@angular/fire/auth';
|
|
10
|
-
import { Auth,
|
|
8
|
+
import { Auth, getAuth, provideAuth, getIdToken, authState } from '@angular/fire/auth';
|
|
11
9
|
import { isPlatformBrowser, isPlatformServer } from '@angular/common';
|
|
12
10
|
import * as i1$1 from '@angular/fire/firestore';
|
|
13
|
-
import { Firestore,
|
|
11
|
+
import { Firestore, getFirestore, memoryLocalCache, initializeFirestore, provideFirestore, doc, docSnapshots } from '@angular/fire/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';
|
|
14
16
|
import cookie from 'js-cookie';
|
|
15
|
-
import {
|
|
16
|
-
import { map, mergeMap, catchError, concatMap, tap } from 'rxjs/operators';
|
|
17
|
-
import { __decorate, __metadata } from 'tslib';
|
|
17
|
+
import { __metadata, __decorate } from 'tslib';
|
|
18
18
|
import { Type } from 'class-transformer';
|
|
19
19
|
import * as i1$3 from '@angular/common/http';
|
|
20
20
|
|
|
@@ -61,8 +61,6 @@ const FIREBASE_OPTIONS = new InjectionToken('firebaseOptions');
|
|
|
61
61
|
|
|
62
62
|
const HASURA_OPTIONS = 'HASURA_OPTIONS';
|
|
63
63
|
|
|
64
|
-
const PERSISTENCE_PROVIDER = 'PERSISTENCE_PROVIDER';
|
|
65
|
-
|
|
66
64
|
class AngularFirebaseAuthModule {
|
|
67
65
|
static initializeApp(options, nameOrConfig) {
|
|
68
66
|
return {
|
|
@@ -171,6 +169,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
171
169
|
}]
|
|
172
170
|
}] });
|
|
173
171
|
|
|
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, i2.StorageModule] }); }
|
|
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,
|
|
199
199
|
interceptors: {
|
|
200
200
|
request: (request) => {
|
|
201
201
|
if (isPlatformBrowser(platformId))
|
|
@@ -403,20 +403,27 @@ 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
|
+
},
|
|
406
413
|
], imports: [AngularElasticSeachModule,
|
|
407
414
|
provideFirestore((injector) => {
|
|
408
415
|
const platformId = injector.get(PLATFORM_ID);
|
|
409
|
-
if (isPlatformServer(platformId)
|
|
410
|
-
return
|
|
411
|
-
|
|
412
|
-
|
|
416
|
+
if (isPlatformServer(platformId))
|
|
417
|
+
return getFirestore(injector.get(FirebaseApp));
|
|
418
|
+
if (!MobileOperationSystemCheckerHelper.isAppleDevice())
|
|
419
|
+
return getFirestore(injector.get(FirebaseApp));
|
|
413
420
|
const firestore = initializeFirestore(injector.get(FirebaseApp), {
|
|
414
421
|
experimentalForceLongPolling: true,
|
|
415
|
-
ignoreUndefinedProperties: true,
|
|
416
422
|
localCache: memoryLocalCache(),
|
|
417
423
|
});
|
|
418
424
|
return firestore;
|
|
419
|
-
})
|
|
425
|
+
}),
|
|
426
|
+
provideStorage(() => getStorage())] }); }
|
|
420
427
|
}
|
|
421
428
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AngularFirestoreModule, decorators: [{
|
|
422
429
|
type: NgModule,
|
|
@@ -425,23 +432,23 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
425
432
|
AngularElasticSeachModule,
|
|
426
433
|
provideFirestore((injector) => {
|
|
427
434
|
const platformId = injector.get(PLATFORM_ID);
|
|
428
|
-
if (isPlatformServer(platformId)
|
|
429
|
-
return
|
|
430
|
-
|
|
431
|
-
|
|
435
|
+
if (isPlatformServer(platformId))
|
|
436
|
+
return getFirestore(injector.get(FirebaseApp));
|
|
437
|
+
if (!MobileOperationSystemCheckerHelper.isAppleDevice())
|
|
438
|
+
return getFirestore(injector.get(FirebaseApp));
|
|
432
439
|
const firestore = initializeFirestore(injector.get(FirebaseApp), {
|
|
433
440
|
experimentalForceLongPolling: true,
|
|
434
|
-
ignoreUndefinedProperties: true,
|
|
435
441
|
localCache: memoryLocalCache(),
|
|
436
442
|
});
|
|
437
443
|
return firestore;
|
|
438
444
|
}),
|
|
445
|
+
provideStorage(() => getStorage()),
|
|
439
446
|
],
|
|
440
447
|
providers: [
|
|
441
448
|
{
|
|
442
449
|
provide: 'FirestoreOptions',
|
|
443
450
|
useFactory: (firestore, platformId) => ({
|
|
444
|
-
firestore
|
|
451
|
+
firestore,
|
|
445
452
|
interceptors: {
|
|
446
453
|
request: (request) => {
|
|
447
454
|
if (isPlatformBrowser(platformId))
|
|
@@ -649,6 +656,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
649
656
|
},
|
|
650
657
|
deps: ['FirestoreOptions', ProductFirestoreRepository],
|
|
651
658
|
},
|
|
659
|
+
{
|
|
660
|
+
provide: 'FileUploaderService',
|
|
661
|
+
useFactory: (storage, baseUrl) => {
|
|
662
|
+
return new FirebaseFileUploaderService(storage, baseUrl);
|
|
663
|
+
},
|
|
664
|
+
deps: [Storage, STORAGE_BASE_URL],
|
|
665
|
+
},
|
|
652
666
|
],
|
|
653
667
|
}]
|
|
654
668
|
}] });
|
|
@@ -730,17 +744,6 @@ class AngularHasuraGraphQLModule {
|
|
|
730
744
|
},
|
|
731
745
|
deps: ['HasuraConfig'],
|
|
732
746
|
},
|
|
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
|
-
},
|
|
744
747
|
{
|
|
745
748
|
provide: 'CategoryFilterRepository',
|
|
746
749
|
useExisting: CategoryFilterHasuraGraphQLRepository,
|
|
@@ -867,17 +870,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
867
870
|
},
|
|
868
871
|
deps: ['HasuraConfig'],
|
|
869
872
|
},
|
|
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
|
-
},
|
|
881
873
|
{
|
|
882
874
|
provide: 'CategoryFilterRepository',
|
|
883
875
|
useExisting: CategoryFilterHasuraGraphQLRepository,
|
|
@@ -935,25 +927,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
935
927
|
}]
|
|
936
928
|
}] });
|
|
937
929
|
|
|
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
|
-
|
|
957
930
|
class AuthService {
|
|
958
931
|
constructor(angularFireAuth, userRepository) {
|
|
959
932
|
this.angularFireAuth = angularFireAuth;
|
|
@@ -1060,33 +1033,32 @@ class CouponService {
|
|
|
1060
1033
|
return of(discount);
|
|
1061
1034
|
}
|
|
1062
1035
|
async calcDiscountShopping(coupon, checkout) {
|
|
1063
|
-
let
|
|
1036
|
+
let discount = 0;
|
|
1064
1037
|
if (checkout.user.isSubscriber && coupon.discount.subscriber.value) {
|
|
1065
|
-
|
|
1038
|
+
discount = await this.calcDiscountByType(coupon.discount.subscriber.type, coupon.discount.subscriber.value, coupon.productsCategories, checkout);
|
|
1066
1039
|
}
|
|
1067
1040
|
else {
|
|
1068
|
-
|
|
1041
|
+
discount = await this.calcDiscountByType(coupon.discount.non_subscriber.type, coupon.discount.non_subscriber.value, coupon.productsCategories, checkout);
|
|
1069
1042
|
}
|
|
1070
|
-
return
|
|
1043
|
+
return discount;
|
|
1071
1044
|
}
|
|
1072
1045
|
async calcDiscountByType(type, value, categories, checkout) {
|
|
1073
1046
|
let discount = 0;
|
|
1074
|
-
let
|
|
1075
|
-
const subTotal = this.calcCheckoutSubtotal(
|
|
1047
|
+
let lineItensDiscount = await this.getLineItensEligebleForDiscount(categories, checkout);
|
|
1048
|
+
const subTotal = this.calcCheckoutSubtotal(lineItensDiscount, checkout.user, checkout.shop);
|
|
1076
1049
|
if (type == CouponTypes.ABSOLUTE) {
|
|
1077
1050
|
discount = value > subTotal ? subTotal : value;
|
|
1078
1051
|
}
|
|
1079
1052
|
else {
|
|
1080
1053
|
discount = subTotal * (value / 100);
|
|
1081
1054
|
}
|
|
1082
|
-
|
|
1083
|
-
return { discount, lineItems };
|
|
1055
|
+
return discount;
|
|
1084
1056
|
}
|
|
1085
1057
|
async hasMinSubTotal(coupon, checkout) {
|
|
1086
1058
|
if (!coupon.minSubTotalValue)
|
|
1087
1059
|
return true;
|
|
1088
1060
|
let lineItensDiscount = await this.getLineItensEligebleForDiscount(coupon.productsCategories, checkout);
|
|
1089
|
-
const subTotal = this.calcCheckoutSubtotal(lineItensDiscount, checkout.user);
|
|
1061
|
+
const subTotal = this.calcCheckoutSubtotal(lineItensDiscount, checkout.user, checkout.shop);
|
|
1090
1062
|
if (coupon.minSubTotalValue <= subTotal)
|
|
1091
1063
|
return true;
|
|
1092
1064
|
return false;
|
|
@@ -1154,7 +1126,7 @@ class CouponService {
|
|
|
1154
1126
|
}
|
|
1155
1127
|
return lineItensDiscount;
|
|
1156
1128
|
}
|
|
1157
|
-
calcCheckoutSubtotal(lineItens, user) {
|
|
1129
|
+
calcCheckoutSubtotal(lineItens, user, shop) {
|
|
1158
1130
|
return (lineItens?.reduce((acc, curr) => user?.isSubscriber && curr.price.subscriberPrice
|
|
1159
1131
|
? acc + curr.price?.subscriberPrice * curr.quantity
|
|
1160
1132
|
: acc + curr.pricePaid * curr.quantity, 0) || 0);
|
|
@@ -1192,30 +1164,6 @@ class CouponService {
|
|
|
1192
1164
|
}
|
|
1193
1165
|
return couponUseLimits;
|
|
1194
1166
|
}
|
|
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
|
-
}
|
|
1219
1167
|
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 }); }
|
|
1220
1168
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CouponService, providedIn: 'root' }); }
|
|
1221
1169
|
}
|
|
@@ -1239,17 +1187,18 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
1239
1187
|
}] }] });
|
|
1240
1188
|
|
|
1241
1189
|
class CheckoutService {
|
|
1242
|
-
constructor(couponService, checkoutRepository, userRepository, defaultShop
|
|
1190
|
+
constructor(couponService, checkoutRepository, orderRepository, userRepository, defaultShop) {
|
|
1243
1191
|
this.couponService = couponService;
|
|
1244
1192
|
this.checkoutRepository = checkoutRepository;
|
|
1193
|
+
this.orderRepository = orderRepository;
|
|
1245
1194
|
this.userRepository = userRepository;
|
|
1246
1195
|
this.defaultShop = defaultShop;
|
|
1247
|
-
this.dataPersistence = dataPersistence;
|
|
1248
1196
|
}
|
|
1249
1197
|
getCheckout(checkoutData) {
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1198
|
+
const checkoutId = cookie.get('checkoutId');
|
|
1199
|
+
if (!isNil(checkoutId))
|
|
1200
|
+
return from(this.checkoutRepository.get({ id: checkoutId }));
|
|
1201
|
+
return from(this.createCheckout(checkoutData));
|
|
1253
1202
|
}
|
|
1254
1203
|
getUserByCheckout(checkoutId) {
|
|
1255
1204
|
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'))));
|
|
@@ -1261,7 +1210,8 @@ class CheckoutService {
|
|
|
1261
1210
|
return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, user: checkout.user })));
|
|
1262
1211
|
}
|
|
1263
1212
|
clearCheckoutFromSession() {
|
|
1264
|
-
|
|
1213
|
+
cookie.remove('checkoutId');
|
|
1214
|
+
return of();
|
|
1265
1215
|
}
|
|
1266
1216
|
calcDiscount(coupon) {
|
|
1267
1217
|
return this.getCheckout().pipe(concatMap(async (checkout) => await this.couponService.calcDiscountShopping(coupon, checkout)));
|
|
@@ -1275,10 +1225,10 @@ class CheckoutService {
|
|
|
1275
1225
|
...Checkout.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain(),
|
|
1276
1226
|
shop: checkoutData?.shop || this.defaultShop,
|
|
1277
1227
|
});
|
|
1278
|
-
|
|
1228
|
+
cookie.set('checkoutId', checkout.id);
|
|
1279
1229
|
return checkout;
|
|
1280
1230
|
}
|
|
1281
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CheckoutService, deps: [{ token: CouponService }, { token: 'CheckoutRepository' }, { token: '
|
|
1231
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CheckoutService, deps: [{ token: CouponService }, { token: 'CheckoutRepository' }, { token: 'OrderRepository' }, { token: 'UserRepository' }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1282
1232
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CheckoutService }); }
|
|
1283
1233
|
}
|
|
1284
1234
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CheckoutService, decorators: [{
|
|
@@ -1286,15 +1236,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
1286
1236
|
}], ctorParameters: () => [{ type: CouponService }, { type: undefined, decorators: [{
|
|
1287
1237
|
type: Inject,
|
|
1288
1238
|
args: ['CheckoutRepository']
|
|
1239
|
+
}] }, { type: undefined, decorators: [{
|
|
1240
|
+
type: Inject,
|
|
1241
|
+
args: ['OrderRepository']
|
|
1289
1242
|
}] }, { type: undefined, decorators: [{
|
|
1290
1243
|
type: Inject,
|
|
1291
1244
|
args: ['UserRepository']
|
|
1292
1245
|
}] }, { type: i1$2.Shops, decorators: [{
|
|
1293
1246
|
type: Inject,
|
|
1294
1247
|
args: [DEFAULT_SHOP]
|
|
1295
|
-
}] }, { type: undefined, decorators: [{
|
|
1296
|
-
type: Inject,
|
|
1297
|
-
args: [PERSISTENCE_PROVIDER]
|
|
1298
1248
|
}] }] });
|
|
1299
1249
|
|
|
1300
1250
|
class CartService {
|
|
@@ -1330,8 +1280,8 @@ class CartService {
|
|
|
1330
1280
|
this.buildLineItem = async ({ checkout, item, quantity, }) => {
|
|
1331
1281
|
const product = await this.getProductData(item.id);
|
|
1332
1282
|
item.quantity = item?.quantity || checkout?.lineItems?.find((lineItem) => lineItem.id === item.id)?.quantity || 0;
|
|
1333
|
-
if (this.checkMaxStock(
|
|
1334
|
-
throw new Error('Desculpe! Temos apenas ' +
|
|
1283
|
+
if (this.checkMaxStock(item, quantity || 0))
|
|
1284
|
+
throw new Error('Desculpe! Temos apenas ' + item.stock?.quantity + ' em estoque.');
|
|
1335
1285
|
const image = item.image || item.images?.shift();
|
|
1336
1286
|
const { id, name, EAN, slug, stock, price, weight, sku, type } = item;
|
|
1337
1287
|
const isGift = item.isGift || null;
|
|
@@ -1356,7 +1306,6 @@ class CartService {
|
|
|
1356
1306
|
weight: weight ?? product.weight,
|
|
1357
1307
|
quantity: (item.quantity || 0) + (quantity || 0),
|
|
1358
1308
|
pricePaid,
|
|
1359
|
-
discount: 0,
|
|
1360
1309
|
categories: product.categories ?? [],
|
|
1361
1310
|
isGift: isGift ?? null,
|
|
1362
1311
|
costPrice: product.costPrice ?? 0,
|
|
@@ -1372,10 +1321,10 @@ class CartService {
|
|
|
1372
1321
|
? Number(info.subscriberPrice.toFixed(2))
|
|
1373
1322
|
: Number(info.price.toFixed(2));
|
|
1374
1323
|
};
|
|
1375
|
-
this.checkMaxStock = (
|
|
1376
|
-
const maxStock =
|
|
1377
|
-
const currentItemAmount =
|
|
1378
|
-
return currentItemAmount +
|
|
1324
|
+
this.checkMaxStock = (item, quantity) => {
|
|
1325
|
+
const maxStock = item.stock?.quantity || 0;
|
|
1326
|
+
const currentItemAmount = item.quantity || 0;
|
|
1327
|
+
return currentItemAmount + quantity > maxStock;
|
|
1379
1328
|
};
|
|
1380
1329
|
}
|
|
1381
1330
|
addItem(item, quantity = 1) {
|
|
@@ -1408,7 +1357,7 @@ class CartService {
|
|
|
1408
1357
|
}), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
|
|
1409
1358
|
}
|
|
1410
1359
|
updateUserCart(user) {
|
|
1411
|
-
return this.checkoutService.getCheckout().pipe(concatMap((checkout) => this.checkoutService.updateCheckoutUser(Checkout.toInstance({ ...checkout.toPlain(), user }))), concatMap(async (checkout) =>
|
|
1360
|
+
return this.checkoutService.getCheckout().pipe(concatMap((checkout) => this.checkoutService.updateCheckoutUser(Checkout.toInstance({ ...checkout.toPlain(), user }))), concatMap(async (checkout) => this.checkoutService
|
|
1412
1361
|
.updateCheckoutLineItems(Checkout.toInstance({
|
|
1413
1362
|
...checkout.toPlain(),
|
|
1414
1363
|
lineItems: checkout.lineItems?.length
|
|
@@ -1592,11 +1541,9 @@ class NewCategoryStructureAdapter {
|
|
|
1592
1541
|
.then((categories) => categories.map((category) => category.id.toString()));
|
|
1593
1542
|
}
|
|
1594
1543
|
async getCategory(category) {
|
|
1595
|
-
|
|
1596
|
-
(
|
|
1597
|
-
category
|
|
1598
|
-
category.brandCategory;
|
|
1599
|
-
return collectionCategory ? this.categoryRepository.get({ id: category.id }) : category;
|
|
1544
|
+
return isNil(category.isCollection) || (category.isCollection && !category.products?.length)
|
|
1545
|
+
? this.categoryRepository.get({ id: category.id })
|
|
1546
|
+
: category;
|
|
1600
1547
|
}
|
|
1601
1548
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: NewCategoryStructureAdapter, deps: [{ token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1602
1549
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: NewCategoryStructureAdapter }); }
|
|
@@ -1629,10 +1576,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
1629
1576
|
}] }] });
|
|
1630
1577
|
|
|
1631
1578
|
class CatalogService {
|
|
1632
|
-
constructor(productRepository,
|
|
1579
|
+
constructor(productRepository, categoryStructureAdapter, shop, productIndex) {
|
|
1633
1580
|
this.productRepository = productRepository;
|
|
1634
|
-
this.productStockNotificationRepository = productStockNotificationRepository;
|
|
1635
|
-
this.categoryRepository = categoryRepository;
|
|
1636
1581
|
this.categoryStructureAdapter = categoryStructureAdapter;
|
|
1637
1582
|
this.shop = shop;
|
|
1638
1583
|
this.productIndex = productIndex;
|
|
@@ -1662,22 +1607,17 @@ class CatalogService {
|
|
|
1662
1607
|
if (!sort || sort === 'most-relevant')
|
|
1663
1608
|
return {};
|
|
1664
1609
|
if (sort === 'best-sellers')
|
|
1665
|
-
return {
|
|
1666
|
-
shoppingCount: 'desc',
|
|
1667
|
-
rate: 'desc',
|
|
1668
|
-
stock: 'desc',
|
|
1669
|
-
name: 'asc',
|
|
1670
|
-
};
|
|
1610
|
+
return { shoppingCount: 'desc' };
|
|
1671
1611
|
if (sort === 'biggest-price')
|
|
1672
|
-
return { subscriberPrice: 'desc'
|
|
1612
|
+
return { subscriberPrice: 'desc' };
|
|
1673
1613
|
if (sort === 'lowest-price')
|
|
1674
|
-
return { subscriberPrice: 'asc'
|
|
1614
|
+
return { subscriberPrice: 'asc' };
|
|
1675
1615
|
if (sort === 'best-rating')
|
|
1676
|
-
return { rate: 'desc'
|
|
1616
|
+
return { rate: 'desc' };
|
|
1677
1617
|
if (sort === 'news')
|
|
1678
1618
|
return { createdAt: 'desc' };
|
|
1679
1619
|
if (sort === 'biggest-discount')
|
|
1680
|
-
return { subscriberDiscountPercentage: 'desc'
|
|
1620
|
+
return { subscriberDiscountPercentage: 'desc' };
|
|
1681
1621
|
};
|
|
1682
1622
|
this.buildLimitQuery = (options) => {
|
|
1683
1623
|
const limit = options?.perPage || 20;
|
|
@@ -1711,27 +1651,9 @@ class CatalogService {
|
|
|
1711
1651
|
brands: distinct?.brand,
|
|
1712
1652
|
}));
|
|
1713
1653
|
}
|
|
1714
|
-
async addCustomerToStockNotification(shop, productId, name, email) {
|
|
1715
|
-
return this.productStockNotificationRepository.addCustomerEmail(shop, productId, name, email);
|
|
1716
|
-
}
|
|
1717
1654
|
async findCatalog(options, limits) {
|
|
1718
|
-
if (this.hasTerm(options) && options.sort === 'most-relevant')
|
|
1719
|
-
|
|
1720
|
-
return this.findCatalogAndSortByMostRevelantByTerm(productsIds, options, limits);
|
|
1721
|
-
}
|
|
1722
|
-
if (this.hasCategory(options) && options.sort === 'most-relevant') {
|
|
1723
|
-
const mostRelevant = options.category.getMostRelevantByShop(this.shop) ?? [];
|
|
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
|
-
}
|
|
1655
|
+
if (this.hasTerm(options) && options.sort === 'most-relevant')
|
|
1656
|
+
return this.findCatalogByTermAndSortByMostRevelant(options, limits);
|
|
1735
1657
|
const repoParams = {
|
|
1736
1658
|
filters: {
|
|
1737
1659
|
...(await this.buildMainFilter(options)),
|
|
@@ -1759,33 +1681,8 @@ class CatalogService {
|
|
|
1759
1681
|
.search(term, 999, this.shop)
|
|
1760
1682
|
.then((data) => ({ id: { operator: Where.IN, value: data.hits.map(({ _source }) => _source.id) } }));
|
|
1761
1683
|
}
|
|
1762
|
-
async
|
|
1763
|
-
const
|
|
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) {
|
|
1684
|
+
async findCatalogByTermAndSortByMostRevelant(options, limits) {
|
|
1685
|
+
const productIds = await this.findCatalogIdsByElasticSearch(options.term);
|
|
1789
1686
|
const totalResult = await this.productRepository.findCatalog({
|
|
1790
1687
|
fields: ['id', 'stock'],
|
|
1791
1688
|
filters: {
|
|
@@ -1831,7 +1728,7 @@ class CatalogService {
|
|
|
1831
1728
|
return [...new Set(sorted.map(({ _source }) => _source.id))];
|
|
1832
1729
|
}));
|
|
1833
1730
|
}
|
|
1834
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CatalogService, deps: [{ token: 'ProductRepository' }, { token:
|
|
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 }); }
|
|
1835
1732
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CatalogService }); }
|
|
1836
1733
|
}
|
|
1837
1734
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CatalogService, decorators: [{
|
|
@@ -1839,12 +1736,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
1839
1736
|
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
1840
1737
|
type: Inject,
|
|
1841
1738
|
args: ['ProductRepository']
|
|
1842
|
-
}] }, { type: undefined, decorators: [{
|
|
1843
|
-
type: Inject,
|
|
1844
|
-
args: ['ProductStockNotificationRepository']
|
|
1845
|
-
}] }, { type: undefined, decorators: [{
|
|
1846
|
-
type: Inject,
|
|
1847
|
-
args: ['CategoryRepository']
|
|
1848
1739
|
}] }, { type: undefined, decorators: [{
|
|
1849
1740
|
type: Inject,
|
|
1850
1741
|
args: [CATEGORY_STRUCTURE]
|
|
@@ -1861,15 +1752,15 @@ class CategoryService {
|
|
|
1861
1752
|
this.categoryStructureAdapter = categoryStructureAdapter;
|
|
1862
1753
|
this.shop = shop;
|
|
1863
1754
|
}
|
|
1864
|
-
async fetchBrands(category,
|
|
1755
|
+
async fetchBrands(category, mainGender) {
|
|
1865
1756
|
const brands = await this.productRepository
|
|
1866
1757
|
.findCatalog({
|
|
1867
1758
|
filters: await this.categoryStructureAdapter.buildProductFilterByCategory(category),
|
|
1868
1759
|
fields: ['brand'],
|
|
1869
|
-
},
|
|
1760
|
+
}, mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female')
|
|
1870
1761
|
.then(({ data }) => Object.keys(data.map((product) => product.brand).reduce((brands, brand) => ({ ...brands, [brand]: true }), {})));
|
|
1871
1762
|
return this.categoryRepository
|
|
1872
|
-
.find({ filters: { brandCategory: true, shop:
|
|
1763
|
+
.find({ filters: { brandCategory: true, shop: this.shop }, orderBy: { name: 'asc' } })
|
|
1873
1764
|
.then(({ data }) => data.filter((category) => brands.includes(category.conditions.brand)));
|
|
1874
1765
|
}
|
|
1875
1766
|
async fetchFilterOptions(category) {
|
|
@@ -1918,11 +1809,12 @@ __decorate([
|
|
|
1918
1809
|
], CategoryWithTree.prototype, "children", void 0);
|
|
1919
1810
|
|
|
1920
1811
|
class WishlistService {
|
|
1921
|
-
constructor(wishlistRepository, shop, productRepository, categoryFilterRepository,
|
|
1812
|
+
constructor(wishlistRepository, categoryRepository, shop, productRepository, categoryFilterRepository, productIndex) {
|
|
1922
1813
|
this.wishlistRepository = wishlistRepository;
|
|
1814
|
+
this.categoryRepository = categoryRepository;
|
|
1923
1815
|
this.shop = shop;
|
|
1924
1816
|
const categoryStructureAdapter = new NewCategoryStructureAdapter(wishlistRepository);
|
|
1925
|
-
this.catalogService = new CatalogService(productRepository,
|
|
1817
|
+
this.catalogService = new CatalogService(productRepository, categoryStructureAdapter, shop, productIndex);
|
|
1926
1818
|
this.categoryService = new CategoryService(productRepository, categoryRepository, categoryFilterRepository, categoryStructureAdapter, shop);
|
|
1927
1819
|
}
|
|
1928
1820
|
getCatalogService() {
|
|
@@ -1931,25 +1823,22 @@ class WishlistService {
|
|
|
1931
1823
|
getCategoryService() {
|
|
1932
1824
|
return this.categoryService;
|
|
1933
1825
|
}
|
|
1934
|
-
async create({ personId, title, description,
|
|
1826
|
+
async create({ personId, title, description, userFullName, userPhoto, theme, bannerUrl, }) {
|
|
1935
1827
|
const data = {
|
|
1936
1828
|
slug: '',
|
|
1937
1829
|
name: title,
|
|
1938
1830
|
description,
|
|
1939
|
-
metadata:
|
|
1940
|
-
{
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
description: `${userFullName} - ${description}`,
|
|
1944
|
-
},
|
|
1945
|
-
],
|
|
1831
|
+
metadata: {
|
|
1832
|
+
title: `${userFullName} - ${title}`,
|
|
1833
|
+
description: `${userFullName} - ${description}`,
|
|
1834
|
+
},
|
|
1946
1835
|
shop: this.shop,
|
|
1947
1836
|
shops: [this.shop],
|
|
1948
1837
|
personId,
|
|
1949
1838
|
personName: userFullName,
|
|
1950
1839
|
personPhoto: userPhoto,
|
|
1951
1840
|
brandCategory: false,
|
|
1952
|
-
published,
|
|
1841
|
+
published: true,
|
|
1953
1842
|
theme,
|
|
1954
1843
|
bannerUrl,
|
|
1955
1844
|
};
|
|
@@ -1957,19 +1846,15 @@ class WishlistService {
|
|
|
1957
1846
|
await this.wishlistRepository.update({ id: newWishlist.id, slug: newWishlist.id });
|
|
1958
1847
|
return Wishlist.toInstance({ ...newWishlist.toPlain(), slug: newWishlist.id });
|
|
1959
1848
|
}
|
|
1960
|
-
update({ id, title, description,
|
|
1849
|
+
update({ id, title, description, userFullName, userPhoto, theme, bannerUrl, }) {
|
|
1961
1850
|
const data = {
|
|
1962
1851
|
id,
|
|
1963
1852
|
name: title,
|
|
1964
1853
|
description,
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
{
|
|
1968
|
-
|
|
1969
|
-
title: `${userFullName} - ${title}`,
|
|
1970
|
-
description: `${userFullName} - ${description}`,
|
|
1971
|
-
},
|
|
1972
|
-
],
|
|
1854
|
+
metadata: {
|
|
1855
|
+
title: `${userFullName} - ${title}`,
|
|
1856
|
+
description: `${userFullName} - ${description}`,
|
|
1857
|
+
},
|
|
1973
1858
|
personName: userFullName,
|
|
1974
1859
|
personPhoto: userPhoto,
|
|
1975
1860
|
theme,
|
|
@@ -2009,7 +1894,7 @@ class WishlistService {
|
|
|
2009
1894
|
}
|
|
2010
1895
|
return wishlist;
|
|
2011
1896
|
}
|
|
2012
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: WishlistService, deps: [{ token: 'WishlistRepository' }, { token:
|
|
1897
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: WishlistService, deps: [{ token: 'WishlistRepository' }, { token: 'CategoryRepository' }, { token: DEFAULT_SHOP }, { token: 'ProductRepository' }, { token: 'CategoryFilterRepository' }, { token: i1$2.ProductsIndex }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2013
1898
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: WishlistService }); }
|
|
2014
1899
|
}
|
|
2015
1900
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: WishlistService, decorators: [{
|
|
@@ -2017,6 +1902,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
2017
1902
|
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
2018
1903
|
type: Inject,
|
|
2019
1904
|
args: ['WishlistRepository']
|
|
1905
|
+
}] }, { type: undefined, decorators: [{
|
|
1906
|
+
type: Inject,
|
|
1907
|
+
args: ['CategoryRepository']
|
|
2020
1908
|
}] }, { type: i1$2.Shops, decorators: [{
|
|
2021
1909
|
type: Inject,
|
|
2022
1910
|
args: [DEFAULT_SHOP]
|
|
@@ -2026,27 +1914,31 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
2026
1914
|
}] }, { type: undefined, decorators: [{
|
|
2027
1915
|
type: Inject,
|
|
2028
1916
|
args: ['CategoryFilterRepository']
|
|
2029
|
-
}] }, { type: undefined, decorators: [{
|
|
2030
|
-
type: Inject,
|
|
2031
|
-
args: ['CategoryRepository']
|
|
2032
|
-
}] }, { type: undefined, decorators: [{
|
|
2033
|
-
type: Inject,
|
|
2034
|
-
args: ['ProductStockNotificationRepository']
|
|
2035
1917
|
}] }, { type: i1$2.ProductsIndex }] });
|
|
2036
1918
|
|
|
2037
1919
|
class CheckoutSubscriptionService {
|
|
2038
|
-
constructor(checkoutSubscriptionRepository,
|
|
1920
|
+
constructor(checkoutSubscriptionRepository, subscriptionRepository, couponService) {
|
|
2039
1921
|
this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
|
|
2040
|
-
this.
|
|
1922
|
+
this.subscriptionRepository = subscriptionRepository;
|
|
2041
1923
|
this.couponService = couponService;
|
|
2042
1924
|
}
|
|
2043
1925
|
getCheckoutSubscription(checkoutData) {
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
1926
|
+
const checkoutId = cookie.get('checkoutSubscriptionId');
|
|
1927
|
+
if (!isNil(checkoutId))
|
|
1928
|
+
return from(this.checkoutSubscriptionRepository.get({ id: checkoutId }));
|
|
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;
|
|
2047
1938
|
}
|
|
2048
1939
|
clearCheckoutSubscriptionFromSession() {
|
|
2049
|
-
|
|
1940
|
+
cookie.remove('checkoutSubscriptionId');
|
|
1941
|
+
return of();
|
|
2050
1942
|
}
|
|
2051
1943
|
checkCoupon(nickname, userEmail) {
|
|
2052
1944
|
return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService
|
|
@@ -2056,15 +1948,7 @@ class CheckoutSubscriptionService {
|
|
|
2056
1948
|
calcDiscountSubscription(coupon) {
|
|
2057
1949
|
return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService.calcDiscountSubscription(coupon, checkout).pipe()));
|
|
2058
1950
|
}
|
|
2059
|
-
|
|
2060
|
-
const checkout = await this.checkoutSubscriptionRepository.create({
|
|
2061
|
-
createdAt: new Date(),
|
|
2062
|
-
...CheckoutSubscription.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain(),
|
|
2063
|
-
});
|
|
2064
|
-
await this.dataPersistence.set('checkoutSubscriptionId', checkout.id).toPromise();
|
|
2065
|
-
return checkout;
|
|
2066
|
-
}
|
|
2067
|
-
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 }); }
|
|
1951
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CheckoutSubscriptionService, deps: [{ token: 'CheckoutSubscriptionRepository' }, { token: 'SubscriptionRepository' }, { token: CouponService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2068
1952
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CheckoutSubscriptionService }); }
|
|
2069
1953
|
}
|
|
2070
1954
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CheckoutSubscriptionService, decorators: [{
|
|
@@ -2074,7 +1958,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
2074
1958
|
args: ['CheckoutSubscriptionRepository']
|
|
2075
1959
|
}] }, { type: undefined, decorators: [{
|
|
2076
1960
|
type: Inject,
|
|
2077
|
-
args: [
|
|
1961
|
+
args: ['SubscriptionRepository']
|
|
2078
1962
|
}] }, { type: CouponService }] });
|
|
2079
1963
|
|
|
2080
1964
|
class UtilHelper {
|
|
@@ -2332,7 +2216,6 @@ class AngularConnectModule {
|
|
|
2332
2216
|
? OldCategoryStructureAdapter
|
|
2333
2217
|
: NewCategoryStructureAdapter,
|
|
2334
2218
|
},
|
|
2335
|
-
{ provide: PERSISTENCE_PROVIDER, useClass: options?.persistenceProvider || CookieDataPersistence },
|
|
2336
2219
|
...(isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]),
|
|
2337
2220
|
...(isNil(options?.firebase) ? [] : [{ provide: FIREBASE_OPTIONS, useValue: options?.firebase }]),
|
|
2338
2221
|
...(isNil(options?.firebase) ? [] : [{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig }]),
|
|
@@ -2344,7 +2227,7 @@ class AngularConnectModule {
|
|
|
2344
2227
|
};
|
|
2345
2228
|
}
|
|
2346
2229
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AngularConnectModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
2347
|
-
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.0.3", ngImport: i0, type: AngularConnectModule, imports: [i1$4.FirebaseAppModule,
|
|
2230
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.0.3", ngImport: i0, type: AngularConnectModule, imports: [i1$4.FirebaseAppModule, AngularElasticSeachModule,
|
|
2348
2231
|
AngularFirebaseAuthModule,
|
|
2349
2232
|
AngularFirestoreModule,
|
|
2350
2233
|
AngularHasuraGraphQLModule] }); }
|
|
@@ -2367,13 +2250,6 @@ class AngularConnectModule {
|
|
|
2367
2250
|
},
|
|
2368
2251
|
deps: ['UserRepository', 'FileUploaderService'],
|
|
2369
2252
|
},
|
|
2370
|
-
{
|
|
2371
|
-
provide: 'FileUploaderService',
|
|
2372
|
-
useFactory: (storage, baseUrl) => {
|
|
2373
|
-
return new FirebaseFileUploaderService(storage, baseUrl);
|
|
2374
|
-
},
|
|
2375
|
-
deps: [Storage, STORAGE_BASE_URL],
|
|
2376
|
-
},
|
|
2377
2253
|
], imports: [provideFirebaseApp((injector) => {
|
|
2378
2254
|
const appName = injector.get(FIREBASE_APP_NAME) || '[DEFAULT]';
|
|
2379
2255
|
try {
|
|
@@ -2383,7 +2259,6 @@ class AngularConnectModule {
|
|
|
2383
2259
|
return initializeApp(injector.get(FIREBASE_OPTIONS), appName);
|
|
2384
2260
|
}
|
|
2385
2261
|
}),
|
|
2386
|
-
provideStorage((injector) => getStorage(injector.get(FirebaseApp))),
|
|
2387
2262
|
AngularElasticSeachModule,
|
|
2388
2263
|
AngularFirebaseAuthModule,
|
|
2389
2264
|
AngularFirestoreModule,
|
|
@@ -2402,7 +2277,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
2402
2277
|
return initializeApp(injector.get(FIREBASE_OPTIONS), appName);
|
|
2403
2278
|
}
|
|
2404
2279
|
}),
|
|
2405
|
-
provideStorage((injector) => getStorage(injector.get(FirebaseApp))),
|
|
2406
2280
|
AngularElasticSeachModule,
|
|
2407
2281
|
AngularFirebaseAuthModule,
|
|
2408
2282
|
AngularFirestoreModule,
|
|
@@ -2427,13 +2301,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
2427
2301
|
},
|
|
2428
2302
|
deps: ['UserRepository', 'FileUploaderService'],
|
|
2429
2303
|
},
|
|
2430
|
-
{
|
|
2431
|
-
provide: 'FileUploaderService',
|
|
2432
|
-
useFactory: (storage, baseUrl) => {
|
|
2433
|
-
return new FirebaseFileUploaderService(storage, baseUrl);
|
|
2434
|
-
},
|
|
2435
|
-
deps: [Storage, STORAGE_BASE_URL],
|
|
2436
|
-
},
|
|
2437
2304
|
],
|
|
2438
2305
|
}]
|
|
2439
2306
|
}] });
|
|
@@ -2442,5 +2309,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
2442
2309
|
* Generated bundle index. Do not edit.
|
|
2443
2310
|
*/
|
|
2444
2311
|
|
|
2445
|
-
export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule, AuthService, CartService, CatalogService, CategoryService, CategoryWithTree, CheckoutService, CheckoutSubscriptionService,
|
|
2312
|
+
export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule, AuthService, CartService, CatalogService, CategoryService, CategoryWithTree, CheckoutService, CheckoutSubscriptionService, CouponService, HomeShopService, NewCategoryStructureAdapter, OldCategoryStructureAdapter, OrderService, ProductSorts, ShippingService, UtilHelper, WishlistService };
|
|
2446
2313
|
//# sourceMappingURL=infrab4a-connect-angular.mjs.map
|