@infrab4a/connect-angular 5.0.0-beta.48 → 5.0.0-beta.5
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-elastic-search.module.mjs +1 -1
- package/esm2022/angular-firebase-auth.module.mjs +1 -1
- package/esm2022/angular-firestore.module.mjs +34 -17
- package/esm2022/angular-hasura-graphql.module.mjs +2 -32
- 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 +1 -2
- 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 +1 -2
- package/esm2022/services/auth.service.mjs +1 -1
- package/esm2022/services/cart.service.mjs +10 -11
- 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 +4 -6
- package/esm2022/services/catalog/adapters/old-category-structure.adapter.mjs +1 -1
- package/esm2022/services/catalog/catalog.service.mjs +15 -60
- 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 +8 -16
- 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/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 +113 -242
- package/fesm2022/infrab4a-connect-angular.mjs.map +1 -1
- package/index.d.ts +0 -1
- package/package.json +5 -5
- package/services/catalog/catalog.service.d.ts +2 -5
- package/services/catalog/category.service.d.ts +1 -6
- package/services/catalog/wishlist.service.d.ts +4 -10
- 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,
|
|
@@ -794,10 +797,6 @@ class AngularHasuraGraphQLModule {
|
|
|
794
797
|
provide: 'WishlistRepository',
|
|
795
798
|
useExisting: WishlistHasuraGraphQLRepository,
|
|
796
799
|
},
|
|
797
|
-
{
|
|
798
|
-
provide: 'OrderBlockedRepository',
|
|
799
|
-
useExisting: OrderBlockedFirestoreRepository,
|
|
800
|
-
},
|
|
801
800
|
] }); }
|
|
802
801
|
}
|
|
803
802
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AngularHasuraGraphQLModule, decorators: [{
|
|
@@ -871,17 +870,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
871
870
|
},
|
|
872
871
|
deps: ['HasuraConfig'],
|
|
873
872
|
},
|
|
874
|
-
{
|
|
875
|
-
provide: 'ProductStockNotificationRepository',
|
|
876
|
-
useExisting: ProductStockNotificationHasuraGraphQLRepository,
|
|
877
|
-
},
|
|
878
|
-
{
|
|
879
|
-
provide: ProductStockNotificationHasuraGraphQLRepository,
|
|
880
|
-
useFactory: (hasuraConfig) => {
|
|
881
|
-
return new ProductStockNotificationHasuraGraphQLRepository(hasuraConfig);
|
|
882
|
-
},
|
|
883
|
-
deps: ['HasuraConfig'],
|
|
884
|
-
},
|
|
885
873
|
{
|
|
886
874
|
provide: 'CategoryFilterRepository',
|
|
887
875
|
useExisting: CategoryFilterHasuraGraphQLRepository,
|
|
@@ -935,33 +923,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
935
923
|
provide: 'WishlistRepository',
|
|
936
924
|
useExisting: WishlistHasuraGraphQLRepository,
|
|
937
925
|
},
|
|
938
|
-
{
|
|
939
|
-
provide: 'OrderBlockedRepository',
|
|
940
|
-
useExisting: OrderBlockedFirestoreRepository,
|
|
941
|
-
},
|
|
942
926
|
],
|
|
943
927
|
}]
|
|
944
928
|
}] });
|
|
945
929
|
|
|
946
|
-
const STORAGE_BASE_URL = 'STORAGE_BASE_URL';
|
|
947
|
-
|
|
948
|
-
class CookieDataPersistence {
|
|
949
|
-
get(key) {
|
|
950
|
-
return of(cookie.get(key));
|
|
951
|
-
}
|
|
952
|
-
remove(key) {
|
|
953
|
-
return of(cookie.remove(key));
|
|
954
|
-
}
|
|
955
|
-
set(key, value) {
|
|
956
|
-
return from(cookie.set(key, value)).pipe(map(() => { }));
|
|
957
|
-
}
|
|
958
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CookieDataPersistence, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
959
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CookieDataPersistence }); }
|
|
960
|
-
}
|
|
961
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CookieDataPersistence, decorators: [{
|
|
962
|
-
type: Injectable
|
|
963
|
-
}] });
|
|
964
|
-
|
|
965
930
|
class AuthService {
|
|
966
931
|
constructor(angularFireAuth, userRepository) {
|
|
967
932
|
this.angularFireAuth = angularFireAuth;
|
|
@@ -1068,33 +1033,32 @@ class CouponService {
|
|
|
1068
1033
|
return of(discount);
|
|
1069
1034
|
}
|
|
1070
1035
|
async calcDiscountShopping(coupon, checkout) {
|
|
1071
|
-
let
|
|
1036
|
+
let discount = 0;
|
|
1072
1037
|
if (checkout.user.isSubscriber && coupon.discount.subscriber.value) {
|
|
1073
|
-
|
|
1038
|
+
discount = await this.calcDiscountByType(coupon.discount.subscriber.type, coupon.discount.subscriber.value, coupon.productsCategories, checkout);
|
|
1074
1039
|
}
|
|
1075
1040
|
else {
|
|
1076
|
-
|
|
1041
|
+
discount = await this.calcDiscountByType(coupon.discount.non_subscriber.type, coupon.discount.non_subscriber.value, coupon.productsCategories, checkout);
|
|
1077
1042
|
}
|
|
1078
|
-
return
|
|
1043
|
+
return discount;
|
|
1079
1044
|
}
|
|
1080
1045
|
async calcDiscountByType(type, value, categories, checkout) {
|
|
1081
1046
|
let discount = 0;
|
|
1082
|
-
let
|
|
1083
|
-
const subTotal = this.calcCheckoutSubtotal(
|
|
1047
|
+
let lineItensDiscount = await this.getLineItensEligebleForDiscount(categories, checkout);
|
|
1048
|
+
const subTotal = this.calcCheckoutSubtotal(lineItensDiscount, checkout.user, checkout.shop);
|
|
1084
1049
|
if (type == CouponTypes.ABSOLUTE) {
|
|
1085
1050
|
discount = value > subTotal ? subTotal : value;
|
|
1086
1051
|
}
|
|
1087
1052
|
else {
|
|
1088
1053
|
discount = subTotal * (value / 100);
|
|
1089
1054
|
}
|
|
1090
|
-
|
|
1091
|
-
return { discount, lineItems };
|
|
1055
|
+
return discount;
|
|
1092
1056
|
}
|
|
1093
1057
|
async hasMinSubTotal(coupon, checkout) {
|
|
1094
1058
|
if (!coupon.minSubTotalValue)
|
|
1095
1059
|
return true;
|
|
1096
1060
|
let lineItensDiscount = await this.getLineItensEligebleForDiscount(coupon.productsCategories, checkout);
|
|
1097
|
-
const subTotal = this.calcCheckoutSubtotal(lineItensDiscount, checkout.user);
|
|
1061
|
+
const subTotal = this.calcCheckoutSubtotal(lineItensDiscount, checkout.user, checkout.shop);
|
|
1098
1062
|
if (coupon.minSubTotalValue <= subTotal)
|
|
1099
1063
|
return true;
|
|
1100
1064
|
return false;
|
|
@@ -1162,7 +1126,7 @@ class CouponService {
|
|
|
1162
1126
|
}
|
|
1163
1127
|
return lineItensDiscount;
|
|
1164
1128
|
}
|
|
1165
|
-
calcCheckoutSubtotal(lineItens, user) {
|
|
1129
|
+
calcCheckoutSubtotal(lineItens, user, shop) {
|
|
1166
1130
|
return (lineItens?.reduce((acc, curr) => user?.isSubscriber && curr.price.subscriberPrice
|
|
1167
1131
|
? acc + curr.price?.subscriberPrice * curr.quantity
|
|
1168
1132
|
: acc + curr.pricePaid * curr.quantity, 0) || 0);
|
|
@@ -1200,30 +1164,6 @@ class CouponService {
|
|
|
1200
1164
|
}
|
|
1201
1165
|
return couponUseLimits;
|
|
1202
1166
|
}
|
|
1203
|
-
calcLineItenDiscount(type, lineItems, couponDiscount, subTotal) {
|
|
1204
|
-
let lineItemsDiscount = [];
|
|
1205
|
-
if (type === CouponTypes.ABSOLUTE) {
|
|
1206
|
-
const couponDiscountMax = couponDiscount > subTotal ? subTotal : couponDiscount;
|
|
1207
|
-
lineItemsDiscount = lineItems.map((item) => {
|
|
1208
|
-
const totalItemPercentage = item.pricePaid / subTotal;
|
|
1209
|
-
const discountItem = couponDiscountMax * totalItemPercentage;
|
|
1210
|
-
return {
|
|
1211
|
-
...item,
|
|
1212
|
-
discount: Number(discountItem.toFixed(2)),
|
|
1213
|
-
};
|
|
1214
|
-
});
|
|
1215
|
-
}
|
|
1216
|
-
else {
|
|
1217
|
-
lineItemsDiscount = lineItems.map((item) => {
|
|
1218
|
-
const discountItem = item.pricePaid * (couponDiscount / 100);
|
|
1219
|
-
return {
|
|
1220
|
-
...item,
|
|
1221
|
-
discount: Number(discountItem.toFixed(2)),
|
|
1222
|
-
};
|
|
1223
|
-
});
|
|
1224
|
-
}
|
|
1225
|
-
return lineItemsDiscount;
|
|
1226
|
-
}
|
|
1227
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 }); }
|
|
1228
1168
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CouponService, providedIn: 'root' }); }
|
|
1229
1169
|
}
|
|
@@ -1247,17 +1187,18 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
1247
1187
|
}] }] });
|
|
1248
1188
|
|
|
1249
1189
|
class CheckoutService {
|
|
1250
|
-
constructor(couponService, checkoutRepository, userRepository, defaultShop
|
|
1190
|
+
constructor(couponService, checkoutRepository, orderRepository, userRepository, defaultShop) {
|
|
1251
1191
|
this.couponService = couponService;
|
|
1252
1192
|
this.checkoutRepository = checkoutRepository;
|
|
1193
|
+
this.orderRepository = orderRepository;
|
|
1253
1194
|
this.userRepository = userRepository;
|
|
1254
1195
|
this.defaultShop = defaultShop;
|
|
1255
|
-
this.dataPersistence = dataPersistence;
|
|
1256
1196
|
}
|
|
1257
1197
|
getCheckout(checkoutData) {
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1198
|
+
const checkoutId = cookie.get('checkoutId');
|
|
1199
|
+
if (!isNil(checkoutId))
|
|
1200
|
+
return from(this.checkoutRepository.get({ id: checkoutId }));
|
|
1201
|
+
return from(this.createCheckout(checkoutData));
|
|
1261
1202
|
}
|
|
1262
1203
|
getUserByCheckout(checkoutId) {
|
|
1263
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'))));
|
|
@@ -1269,7 +1210,8 @@ class CheckoutService {
|
|
|
1269
1210
|
return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, user: checkout.user })));
|
|
1270
1211
|
}
|
|
1271
1212
|
clearCheckoutFromSession() {
|
|
1272
|
-
|
|
1213
|
+
cookie.remove('checkoutId');
|
|
1214
|
+
return of();
|
|
1273
1215
|
}
|
|
1274
1216
|
calcDiscount(coupon) {
|
|
1275
1217
|
return this.getCheckout().pipe(concatMap(async (checkout) => await this.couponService.calcDiscountShopping(coupon, checkout)));
|
|
@@ -1283,10 +1225,10 @@ class CheckoutService {
|
|
|
1283
1225
|
...Checkout.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain(),
|
|
1284
1226
|
shop: checkoutData?.shop || this.defaultShop,
|
|
1285
1227
|
});
|
|
1286
|
-
|
|
1228
|
+
cookie.set('checkoutId', checkout.id);
|
|
1287
1229
|
return checkout;
|
|
1288
1230
|
}
|
|
1289
|
-
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 }); }
|
|
1290
1232
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CheckoutService }); }
|
|
1291
1233
|
}
|
|
1292
1234
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CheckoutService, decorators: [{
|
|
@@ -1294,15 +1236,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
1294
1236
|
}], ctorParameters: () => [{ type: CouponService }, { type: undefined, decorators: [{
|
|
1295
1237
|
type: Inject,
|
|
1296
1238
|
args: ['CheckoutRepository']
|
|
1239
|
+
}] }, { type: undefined, decorators: [{
|
|
1240
|
+
type: Inject,
|
|
1241
|
+
args: ['OrderRepository']
|
|
1297
1242
|
}] }, { type: undefined, decorators: [{
|
|
1298
1243
|
type: Inject,
|
|
1299
1244
|
args: ['UserRepository']
|
|
1300
1245
|
}] }, { type: i1$2.Shops, decorators: [{
|
|
1301
1246
|
type: Inject,
|
|
1302
1247
|
args: [DEFAULT_SHOP]
|
|
1303
|
-
}] }, { type: undefined, decorators: [{
|
|
1304
|
-
type: Inject,
|
|
1305
|
-
args: [PERSISTENCE_PROVIDER]
|
|
1306
1248
|
}] }] });
|
|
1307
1249
|
|
|
1308
1250
|
class CartService {
|
|
@@ -1338,8 +1280,8 @@ class CartService {
|
|
|
1338
1280
|
this.buildLineItem = async ({ checkout, item, quantity, }) => {
|
|
1339
1281
|
const product = await this.getProductData(item.id);
|
|
1340
1282
|
item.quantity = item?.quantity || checkout?.lineItems?.find((lineItem) => lineItem.id === item.id)?.quantity || 0;
|
|
1341
|
-
if (this.checkMaxStock(
|
|
1342
|
-
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.');
|
|
1343
1285
|
const image = item.image || item.images?.shift();
|
|
1344
1286
|
const { id, name, EAN, slug, stock, price, weight, sku, type } = item;
|
|
1345
1287
|
const isGift = item.isGift || null;
|
|
@@ -1364,7 +1306,6 @@ class CartService {
|
|
|
1364
1306
|
weight: weight ?? product.weight,
|
|
1365
1307
|
quantity: (item.quantity || 0) + (quantity || 0),
|
|
1366
1308
|
pricePaid,
|
|
1367
|
-
discount: 0,
|
|
1368
1309
|
categories: product.categories ?? [],
|
|
1369
1310
|
isGift: isGift ?? null,
|
|
1370
1311
|
costPrice: product.costPrice ?? 0,
|
|
@@ -1380,10 +1321,10 @@ class CartService {
|
|
|
1380
1321
|
? Number(info.subscriberPrice.toFixed(2))
|
|
1381
1322
|
: Number(info.price.toFixed(2));
|
|
1382
1323
|
};
|
|
1383
|
-
this.checkMaxStock = (
|
|
1384
|
-
const maxStock =
|
|
1385
|
-
const currentItemAmount =
|
|
1386
|
-
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;
|
|
1387
1328
|
};
|
|
1388
1329
|
}
|
|
1389
1330
|
addItem(item, quantity = 1) {
|
|
@@ -1416,7 +1357,7 @@ class CartService {
|
|
|
1416
1357
|
}), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
|
|
1417
1358
|
}
|
|
1418
1359
|
updateUserCart(user) {
|
|
1419
|
-
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
|
|
1420
1361
|
.updateCheckoutLineItems(Checkout.toInstance({
|
|
1421
1362
|
...checkout.toPlain(),
|
|
1422
1363
|
lineItems: checkout.lineItems?.length
|
|
@@ -1600,11 +1541,9 @@ class NewCategoryStructureAdapter {
|
|
|
1600
1541
|
.then((categories) => categories.map((category) => category.id.toString()));
|
|
1601
1542
|
}
|
|
1602
1543
|
async getCategory(category) {
|
|
1603
|
-
|
|
1604
|
-
(
|
|
1605
|
-
category
|
|
1606
|
-
category.brandCategory;
|
|
1607
|
-
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;
|
|
1608
1547
|
}
|
|
1609
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 }); }
|
|
1610
1549
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: NewCategoryStructureAdapter }); }
|
|
@@ -1637,9 +1576,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
1637
1576
|
}] }] });
|
|
1638
1577
|
|
|
1639
1578
|
class CatalogService {
|
|
1640
|
-
constructor(productRepository,
|
|
1579
|
+
constructor(productRepository, categoryRepository, categoryStructureAdapter, shop, productIndex) {
|
|
1641
1580
|
this.productRepository = productRepository;
|
|
1642
|
-
this.productStockNotificationRepository = productStockNotificationRepository;
|
|
1643
1581
|
this.categoryRepository = categoryRepository;
|
|
1644
1582
|
this.categoryStructureAdapter = categoryStructureAdapter;
|
|
1645
1583
|
this.shop = shop;
|
|
@@ -1670,22 +1608,17 @@ class CatalogService {
|
|
|
1670
1608
|
if (!sort || sort === 'most-relevant')
|
|
1671
1609
|
return {};
|
|
1672
1610
|
if (sort === 'best-sellers')
|
|
1673
|
-
return {
|
|
1674
|
-
shoppingCount: 'desc',
|
|
1675
|
-
rate: 'desc',
|
|
1676
|
-
stock: 'desc',
|
|
1677
|
-
name: 'asc',
|
|
1678
|
-
};
|
|
1611
|
+
return { shoppingCount: 'desc' };
|
|
1679
1612
|
if (sort === 'biggest-price')
|
|
1680
|
-
return { subscriberPrice: 'desc'
|
|
1613
|
+
return { subscriberPrice: 'desc' };
|
|
1681
1614
|
if (sort === 'lowest-price')
|
|
1682
|
-
return { subscriberPrice: 'asc'
|
|
1615
|
+
return { subscriberPrice: 'asc' };
|
|
1683
1616
|
if (sort === 'best-rating')
|
|
1684
|
-
return { rate: 'desc'
|
|
1617
|
+
return { rate: 'desc' };
|
|
1685
1618
|
if (sort === 'news')
|
|
1686
1619
|
return { createdAt: 'desc' };
|
|
1687
1620
|
if (sort === 'biggest-discount')
|
|
1688
|
-
return { subscriberDiscountPercentage: 'desc'
|
|
1621
|
+
return { subscriberDiscountPercentage: 'desc' };
|
|
1689
1622
|
};
|
|
1690
1623
|
this.buildLimitQuery = (options) => {
|
|
1691
1624
|
const limit = options?.perPage || 20;
|
|
@@ -1719,26 +1652,16 @@ class CatalogService {
|
|
|
1719
1652
|
brands: distinct?.brand,
|
|
1720
1653
|
}));
|
|
1721
1654
|
}
|
|
1722
|
-
async addCustomerToStockNotification(shop, productId, name, email) {
|
|
1723
|
-
return this.productStockNotificationRepository.addCustomerEmail(shop, productId, name, email);
|
|
1724
|
-
}
|
|
1725
1655
|
async findCatalog(options, limits) {
|
|
1726
1656
|
if (this.hasTerm(options) && options.sort === 'most-relevant') {
|
|
1727
1657
|
const productsIds = await this.findCatalogIdsByElasticSearch(options.term);
|
|
1728
|
-
return this.
|
|
1658
|
+
return this.findCatalogAndSortByMostRevelant(productsIds, options, limits);
|
|
1729
1659
|
}
|
|
1730
1660
|
if (this.hasCategory(options) && options.sort === 'most-relevant') {
|
|
1731
|
-
const
|
|
1732
|
-
|
|
1733
|
-
.
|
|
1734
|
-
|
|
1735
|
-
filters: {
|
|
1736
|
-
...(await this.buildMainFilter(options)),
|
|
1737
|
-
...this.buildFilterQuery(options?.filters || {}),
|
|
1738
|
-
},
|
|
1739
|
-
})
|
|
1740
|
-
.then((products) => products.data.map((product) => product.id));
|
|
1741
|
-
return this.findCatalogAndSortByMostRevelant(mostRelevant, productsIds, options, limits);
|
|
1661
|
+
const productsIds = options.category.products?.length
|
|
1662
|
+
? options.category.products
|
|
1663
|
+
: await this.categoryRepository.get({ id: options.category.id }).then((categoryFound) => categoryFound.products);
|
|
1664
|
+
return this.findCatalogAndSortByMostRevelant(productsIds, options, limits);
|
|
1742
1665
|
}
|
|
1743
1666
|
const repoParams = {
|
|
1744
1667
|
filters: {
|
|
@@ -1767,33 +1690,7 @@ class CatalogService {
|
|
|
1767
1690
|
.search(term, 999, this.shop)
|
|
1768
1691
|
.then((data) => ({ id: { operator: Where.IN, value: data.hits.map(({ _source }) => _source.id) } }));
|
|
1769
1692
|
}
|
|
1770
|
-
async findCatalogAndSortByMostRevelant(
|
|
1771
|
-
const mostRelevantProductsIds = [...new Set(mostRelevants.concat(productIds))];
|
|
1772
|
-
const totalResult = await this.productRepository.findCatalog({
|
|
1773
|
-
filters: {
|
|
1774
|
-
id: { operator: Where.IN, value: mostRelevantProductsIds },
|
|
1775
|
-
...this.buildFilterQuery(options?.filters || {}),
|
|
1776
|
-
},
|
|
1777
|
-
orderBy: this.buildSortQuery('news'),
|
|
1778
|
-
options: {
|
|
1779
|
-
minimal: ['price'],
|
|
1780
|
-
maximum: ['price'],
|
|
1781
|
-
distinct: ['brand'],
|
|
1782
|
-
},
|
|
1783
|
-
}, options?.mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female');
|
|
1784
|
-
const firstProducts = totalResult.data.filter((product) => mostRelevants.includes(product.id));
|
|
1785
|
-
const lastProducts = totalResult.data.filter((product) => !mostRelevants.includes(product.id));
|
|
1786
|
-
const categoryMostRelevants = firstProducts.concat(lastProducts);
|
|
1787
|
-
const resultFinal = categoryMostRelevants.slice(limits.offset, limits.offset + limits.limit);
|
|
1788
|
-
return {
|
|
1789
|
-
data: resultFinal,
|
|
1790
|
-
count: totalResult.count,
|
|
1791
|
-
maximum: totalResult.maximum,
|
|
1792
|
-
minimal: totalResult.minimal,
|
|
1793
|
-
distinct: totalResult.distinct,
|
|
1794
|
-
};
|
|
1795
|
-
}
|
|
1796
|
-
async findCatalogAndSortByMostRevelantByTerm(productIds, options, limits) {
|
|
1693
|
+
async findCatalogAndSortByMostRevelant(productIds, options, limits) {
|
|
1797
1694
|
const totalResult = await this.productRepository.findCatalog({
|
|
1798
1695
|
fields: ['id', 'stock'],
|
|
1799
1696
|
filters: {
|
|
@@ -1839,7 +1736,7 @@ class CatalogService {
|
|
|
1839
1736
|
return [...new Set(sorted.map(({ _source }) => _source.id))];
|
|
1840
1737
|
}));
|
|
1841
1738
|
}
|
|
1842
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CatalogService, deps: [{ token: 'ProductRepository' }, { token: '
|
|
1739
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CatalogService, deps: [{ token: 'ProductRepository' }, { token: 'CategoryRepository' }, { token: CATEGORY_STRUCTURE }, { token: DEFAULT_SHOP }, { token: i1$2.ProductsIndex }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1843
1740
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CatalogService }); }
|
|
1844
1741
|
}
|
|
1845
1742
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CatalogService, decorators: [{
|
|
@@ -1847,9 +1744,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
1847
1744
|
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
1848
1745
|
type: Inject,
|
|
1849
1746
|
args: ['ProductRepository']
|
|
1850
|
-
}] }, { type: undefined, decorators: [{
|
|
1851
|
-
type: Inject,
|
|
1852
|
-
args: ['ProductStockNotificationRepository']
|
|
1853
1747
|
}] }, { type: undefined, decorators: [{
|
|
1854
1748
|
type: Inject,
|
|
1855
1749
|
args: ['CategoryRepository']
|
|
@@ -1869,15 +1763,15 @@ class CategoryService {
|
|
|
1869
1763
|
this.categoryStructureAdapter = categoryStructureAdapter;
|
|
1870
1764
|
this.shop = shop;
|
|
1871
1765
|
}
|
|
1872
|
-
async fetchBrands(category,
|
|
1766
|
+
async fetchBrands(category, mainGender) {
|
|
1873
1767
|
const brands = await this.productRepository
|
|
1874
1768
|
.findCatalog({
|
|
1875
1769
|
filters: await this.categoryStructureAdapter.buildProductFilterByCategory(category),
|
|
1876
1770
|
fields: ['brand'],
|
|
1877
|
-
},
|
|
1771
|
+
}, mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female')
|
|
1878
1772
|
.then(({ data }) => Object.keys(data.map((product) => product.brand).reduce((brands, brand) => ({ ...brands, [brand]: true }), {})));
|
|
1879
1773
|
return this.categoryRepository
|
|
1880
|
-
.find({ filters: { brandCategory: true, shop:
|
|
1774
|
+
.find({ filters: { brandCategory: true, shop: this.shop }, orderBy: { name: 'asc' } })
|
|
1881
1775
|
.then(({ data }) => data.filter((category) => brands.includes(category.conditions.brand)));
|
|
1882
1776
|
}
|
|
1883
1777
|
async fetchFilterOptions(category) {
|
|
@@ -1926,11 +1820,11 @@ __decorate([
|
|
|
1926
1820
|
], CategoryWithTree.prototype, "children", void 0);
|
|
1927
1821
|
|
|
1928
1822
|
class WishlistService {
|
|
1929
|
-
constructor(wishlistRepository, shop, productRepository, categoryFilterRepository, categoryRepository,
|
|
1823
|
+
constructor(wishlistRepository, shop, productRepository, categoryFilterRepository, categoryRepository, productIndex) {
|
|
1930
1824
|
this.wishlistRepository = wishlistRepository;
|
|
1931
1825
|
this.shop = shop;
|
|
1932
1826
|
const categoryStructureAdapter = new NewCategoryStructureAdapter(wishlistRepository);
|
|
1933
|
-
this.catalogService = new CatalogService(productRepository,
|
|
1827
|
+
this.catalogService = new CatalogService(productRepository, categoryRepository, categoryStructureAdapter, shop, productIndex);
|
|
1934
1828
|
this.categoryService = new CategoryService(productRepository, categoryRepository, categoryFilterRepository, categoryStructureAdapter, shop);
|
|
1935
1829
|
}
|
|
1936
1830
|
getCatalogService() {
|
|
@@ -1939,7 +1833,7 @@ class WishlistService {
|
|
|
1939
1833
|
getCategoryService() {
|
|
1940
1834
|
return this.categoryService;
|
|
1941
1835
|
}
|
|
1942
|
-
async create({ personId, title, description,
|
|
1836
|
+
async create({ personId, title, description, userFullName, userPhoto, theme, bannerUrl, }) {
|
|
1943
1837
|
const data = {
|
|
1944
1838
|
slug: '',
|
|
1945
1839
|
name: title,
|
|
@@ -1954,22 +1848,19 @@ class WishlistService {
|
|
|
1954
1848
|
personName: userFullName,
|
|
1955
1849
|
personPhoto: userPhoto,
|
|
1956
1850
|
brandCategory: false,
|
|
1957
|
-
published,
|
|
1851
|
+
published: true,
|
|
1958
1852
|
theme,
|
|
1959
1853
|
bannerUrl,
|
|
1960
|
-
personType: personType ?? PersonTypes.NONE,
|
|
1961
|
-
personIsSubscriber: personIsSubscriber ?? false,
|
|
1962
1854
|
};
|
|
1963
1855
|
const newWishlist = await this.wishlistRepository.create(data);
|
|
1964
1856
|
await this.wishlistRepository.update({ id: newWishlist.id, slug: newWishlist.id });
|
|
1965
1857
|
return Wishlist.toInstance({ ...newWishlist.toPlain(), slug: newWishlist.id });
|
|
1966
1858
|
}
|
|
1967
|
-
update({ id, title, description,
|
|
1859
|
+
update({ id, title, description, userFullName, userPhoto, theme, bannerUrl, }) {
|
|
1968
1860
|
const data = {
|
|
1969
1861
|
id,
|
|
1970
1862
|
name: title,
|
|
1971
1863
|
description,
|
|
1972
|
-
published,
|
|
1973
1864
|
metadata: {
|
|
1974
1865
|
title: `${userFullName} - ${title}`,
|
|
1975
1866
|
description: `${userFullName} - ${description}`,
|
|
@@ -1978,8 +1869,6 @@ class WishlistService {
|
|
|
1978
1869
|
personPhoto: userPhoto,
|
|
1979
1870
|
theme,
|
|
1980
1871
|
bannerUrl,
|
|
1981
|
-
personType: personType ?? PersonTypes.NONE,
|
|
1982
|
-
personIsSubscriber: personIsSubscriber ?? false,
|
|
1983
1872
|
};
|
|
1984
1873
|
return this.wishlistRepository.update(data);
|
|
1985
1874
|
}
|
|
@@ -2015,7 +1904,7 @@ class WishlistService {
|
|
|
2015
1904
|
}
|
|
2016
1905
|
return wishlist;
|
|
2017
1906
|
}
|
|
2018
|
-
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:
|
|
1907
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: WishlistService, deps: [{ token: 'WishlistRepository' }, { token: DEFAULT_SHOP }, { token: 'ProductRepository' }, { token: 'CategoryFilterRepository' }, { token: 'CategoryRepository' }, { token: i1$2.ProductsIndex }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2019
1908
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: WishlistService }); }
|
|
2020
1909
|
}
|
|
2021
1910
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: WishlistService, decorators: [{
|
|
@@ -2035,24 +1924,31 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
2035
1924
|
}] }, { type: undefined, decorators: [{
|
|
2036
1925
|
type: Inject,
|
|
2037
1926
|
args: ['CategoryRepository']
|
|
2038
|
-
}] }, { type: undefined, decorators: [{
|
|
2039
|
-
type: Inject,
|
|
2040
|
-
args: ['ProductStockNotificationRepository']
|
|
2041
1927
|
}] }, { type: i1$2.ProductsIndex }] });
|
|
2042
1928
|
|
|
2043
1929
|
class CheckoutSubscriptionService {
|
|
2044
|
-
constructor(checkoutSubscriptionRepository,
|
|
1930
|
+
constructor(checkoutSubscriptionRepository, subscriptionRepository, couponService) {
|
|
2045
1931
|
this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
|
|
2046
|
-
this.
|
|
1932
|
+
this.subscriptionRepository = subscriptionRepository;
|
|
2047
1933
|
this.couponService = couponService;
|
|
2048
1934
|
}
|
|
2049
1935
|
getCheckoutSubscription(checkoutData) {
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
1936
|
+
const checkoutId = cookie.get('checkoutSubscriptionId');
|
|
1937
|
+
if (!isNil(checkoutId))
|
|
1938
|
+
return from(this.checkoutSubscriptionRepository.get({ id: checkoutId }));
|
|
1939
|
+
return from(this.createCheckoutSubscription(checkoutData));
|
|
1940
|
+
}
|
|
1941
|
+
async createCheckoutSubscription(checkoutData) {
|
|
1942
|
+
const checkout = await this.checkoutSubscriptionRepository.create({
|
|
1943
|
+
createdAt: new Date(),
|
|
1944
|
+
...CheckoutSubscription.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain(),
|
|
1945
|
+
});
|
|
1946
|
+
cookie.set('checkoutSubscriptionId', checkout.id);
|
|
1947
|
+
return checkout;
|
|
2053
1948
|
}
|
|
2054
1949
|
clearCheckoutSubscriptionFromSession() {
|
|
2055
|
-
|
|
1950
|
+
cookie.remove('checkoutSubscriptionId');
|
|
1951
|
+
return of();
|
|
2056
1952
|
}
|
|
2057
1953
|
checkCoupon(nickname, userEmail) {
|
|
2058
1954
|
return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService
|
|
@@ -2062,15 +1958,7 @@ class CheckoutSubscriptionService {
|
|
|
2062
1958
|
calcDiscountSubscription(coupon) {
|
|
2063
1959
|
return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService.calcDiscountSubscription(coupon, checkout).pipe()));
|
|
2064
1960
|
}
|
|
2065
|
-
|
|
2066
|
-
const checkout = await this.checkoutSubscriptionRepository.create({
|
|
2067
|
-
createdAt: new Date(),
|
|
2068
|
-
...CheckoutSubscription.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain(),
|
|
2069
|
-
});
|
|
2070
|
-
await this.dataPersistence.set('checkoutSubscriptionId', checkout.id).toPromise();
|
|
2071
|
-
return checkout;
|
|
2072
|
-
}
|
|
2073
|
-
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 }); }
|
|
1961
|
+
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 }); }
|
|
2074
1962
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CheckoutSubscriptionService }); }
|
|
2075
1963
|
}
|
|
2076
1964
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CheckoutSubscriptionService, decorators: [{
|
|
@@ -2080,7 +1968,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
2080
1968
|
args: ['CheckoutSubscriptionRepository']
|
|
2081
1969
|
}] }, { type: undefined, decorators: [{
|
|
2082
1970
|
type: Inject,
|
|
2083
|
-
args: [
|
|
1971
|
+
args: ['SubscriptionRepository']
|
|
2084
1972
|
}] }, { type: CouponService }] });
|
|
2085
1973
|
|
|
2086
1974
|
class UtilHelper {
|
|
@@ -2338,7 +2226,6 @@ class AngularConnectModule {
|
|
|
2338
2226
|
? OldCategoryStructureAdapter
|
|
2339
2227
|
: NewCategoryStructureAdapter,
|
|
2340
2228
|
},
|
|
2341
|
-
{ provide: PERSISTENCE_PROVIDER, useClass: options?.persistenceProvider || CookieDataPersistence },
|
|
2342
2229
|
...(isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]),
|
|
2343
2230
|
...(isNil(options?.firebase) ? [] : [{ provide: FIREBASE_OPTIONS, useValue: options?.firebase }]),
|
|
2344
2231
|
...(isNil(options?.firebase) ? [] : [{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig }]),
|
|
@@ -2350,7 +2237,7 @@ class AngularConnectModule {
|
|
|
2350
2237
|
};
|
|
2351
2238
|
}
|
|
2352
2239
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AngularConnectModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
2353
|
-
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.0.3", ngImport: i0, type: AngularConnectModule, imports: [i1$4.FirebaseAppModule,
|
|
2240
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.0.3", ngImport: i0, type: AngularConnectModule, imports: [i1$4.FirebaseAppModule, AngularElasticSeachModule,
|
|
2354
2241
|
AngularFirebaseAuthModule,
|
|
2355
2242
|
AngularFirestoreModule,
|
|
2356
2243
|
AngularHasuraGraphQLModule] }); }
|
|
@@ -2373,13 +2260,6 @@ class AngularConnectModule {
|
|
|
2373
2260
|
},
|
|
2374
2261
|
deps: ['UserRepository', 'FileUploaderService'],
|
|
2375
2262
|
},
|
|
2376
|
-
{
|
|
2377
|
-
provide: 'FileUploaderService',
|
|
2378
|
-
useFactory: (storage, baseUrl) => {
|
|
2379
|
-
return new FirebaseFileUploaderService(storage, baseUrl);
|
|
2380
|
-
},
|
|
2381
|
-
deps: [Storage, STORAGE_BASE_URL],
|
|
2382
|
-
},
|
|
2383
2263
|
], imports: [provideFirebaseApp((injector) => {
|
|
2384
2264
|
const appName = injector.get(FIREBASE_APP_NAME) || '[DEFAULT]';
|
|
2385
2265
|
try {
|
|
@@ -2389,7 +2269,6 @@ class AngularConnectModule {
|
|
|
2389
2269
|
return initializeApp(injector.get(FIREBASE_OPTIONS), appName);
|
|
2390
2270
|
}
|
|
2391
2271
|
}),
|
|
2392
|
-
provideStorage((injector) => getStorage(injector.get(FirebaseApp))),
|
|
2393
2272
|
AngularElasticSeachModule,
|
|
2394
2273
|
AngularFirebaseAuthModule,
|
|
2395
2274
|
AngularFirestoreModule,
|
|
@@ -2408,7 +2287,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
2408
2287
|
return initializeApp(injector.get(FIREBASE_OPTIONS), appName);
|
|
2409
2288
|
}
|
|
2410
2289
|
}),
|
|
2411
|
-
provideStorage((injector) => getStorage(injector.get(FirebaseApp))),
|
|
2412
2290
|
AngularElasticSeachModule,
|
|
2413
2291
|
AngularFirebaseAuthModule,
|
|
2414
2292
|
AngularFirestoreModule,
|
|
@@ -2433,13 +2311,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
2433
2311
|
},
|
|
2434
2312
|
deps: ['UserRepository', 'FileUploaderService'],
|
|
2435
2313
|
},
|
|
2436
|
-
{
|
|
2437
|
-
provide: 'FileUploaderService',
|
|
2438
|
-
useFactory: (storage, baseUrl) => {
|
|
2439
|
-
return new FirebaseFileUploaderService(storage, baseUrl);
|
|
2440
|
-
},
|
|
2441
|
-
deps: [Storage, STORAGE_BASE_URL],
|
|
2442
|
-
},
|
|
2443
2314
|
],
|
|
2444
2315
|
}]
|
|
2445
2316
|
}] });
|
|
@@ -2448,5 +2319,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
2448
2319
|
* Generated bundle index. Do not edit.
|
|
2449
2320
|
*/
|
|
2450
2321
|
|
|
2451
|
-
export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule, AuthService, CartService, CatalogService, CategoryService, CategoryWithTree, CheckoutService, CheckoutSubscriptionService,
|
|
2322
|
+
export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule, AuthService, CartService, CatalogService, CategoryService, CategoryWithTree, CheckoutService, CheckoutSubscriptionService, CouponService, HomeShopService, NewCategoryStructureAdapter, OldCategoryStructureAdapter, OrderService, ProductSorts, ShippingService, UtilHelper, WishlistService };
|
|
2452
2323
|
//# sourceMappingURL=infrab4a-connect-angular.mjs.map
|