@infrab4a/connect-angular 5.0.0-beta.58 → 5.0.0-beta.6
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 +28 -25
- 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 +11 -14
- package/esm2022/services/catalog/adapters/new-category-structure.adapter.mjs +4 -6
- package/esm2022/services/catalog/catalog.service.mjs +15 -65
- package/esm2022/services/catalog/wishlist.service.mjs +16 -30
- package/esm2022/services/checkout-subscription.service.mjs +21 -18
- package/esm2022/services/checkout.service.mjs +16 -13
- package/esm2022/services/coupon.service.mjs +17 -47
- package/fesm2022/infrab4a-connect-angular.mjs +118 -271
- 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/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
|
@@ -2,18 +2,18 @@ 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
4
|
import { FirebaseApp, provideFirebaseApp, getApp, initializeApp } from '@angular/fire/app';
|
|
5
|
-
import * as i2 from '@angular/fire/storage';
|
|
6
|
-
import { Storage, provideStorage, getStorage } from '@angular/fire/storage';
|
|
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
8
|
import { Auth, provideAuth, getAuth, 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, provideFirestore, initializeFirestore, memoryLocalCache, docSnapshots, doc } from '@angular/fire/firestore';
|
|
14
|
-
import
|
|
15
|
-
import {
|
|
11
|
+
import { Firestore, provideFirestore, getFirestore, initializeFirestore, memoryLocalCache, docSnapshots, doc } from '@angular/fire/firestore';
|
|
12
|
+
import * as i2 from '@angular/fire/storage';
|
|
13
|
+
import { Storage, provideStorage, getStorage } from '@angular/fire/storage';
|
|
14
|
+
import { combineLatest, from, of, throwError, Subject, iif, forkJoin } from 'rxjs';
|
|
16
15
|
import { map, mergeMap, catchError, concatMap, tap } from 'rxjs/operators';
|
|
16
|
+
import cookie from 'js-cookie';
|
|
17
17
|
import { __decorate, __metadata } from 'tslib';
|
|
18
18
|
import { Type } from 'class-transformer';
|
|
19
19
|
import * as i1$3 from '@angular/common/http';
|
|
@@ -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))
|
|
@@ -404,26 +404,26 @@ class AngularFirestoreModule {
|
|
|
404
404
|
deps: ['FirestoreOptions', ProductFirestoreRepository],
|
|
405
405
|
},
|
|
406
406
|
{
|
|
407
|
-
provide: '
|
|
408
|
-
useFactory: (
|
|
409
|
-
return new
|
|
407
|
+
provide: 'FileUploaderService',
|
|
408
|
+
useFactory: (storage, baseUrl) => {
|
|
409
|
+
return new FirebaseFileUploaderService(storage, baseUrl);
|
|
410
410
|
},
|
|
411
|
-
deps: [
|
|
411
|
+
deps: [Storage, STORAGE_BASE_URL],
|
|
412
412
|
},
|
|
413
413
|
], imports: [AngularElasticSeachModule,
|
|
414
414
|
provideFirestore((injector) => {
|
|
415
415
|
const platformId = injector.get(PLATFORM_ID);
|
|
416
|
-
if (isPlatformServer(platformId)
|
|
417
|
-
return
|
|
418
|
-
|
|
419
|
-
|
|
416
|
+
if (isPlatformServer(platformId))
|
|
417
|
+
return getFirestore(injector.get(FirebaseApp));
|
|
418
|
+
if (!MobileOperationSystemCheckerHelper.isAppleDevice())
|
|
419
|
+
return getFirestore(injector.get(FirebaseApp));
|
|
420
420
|
const firestore = initializeFirestore(injector.get(FirebaseApp), {
|
|
421
421
|
experimentalForceLongPolling: true,
|
|
422
|
-
ignoreUndefinedProperties: true,
|
|
423
422
|
localCache: memoryLocalCache(),
|
|
424
423
|
});
|
|
425
424
|
return firestore;
|
|
426
|
-
})
|
|
425
|
+
}),
|
|
426
|
+
provideStorage(() => getStorage())] }); }
|
|
427
427
|
}
|
|
428
428
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AngularFirestoreModule, decorators: [{
|
|
429
429
|
type: NgModule,
|
|
@@ -432,23 +432,23 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
432
432
|
AngularElasticSeachModule,
|
|
433
433
|
provideFirestore((injector) => {
|
|
434
434
|
const platformId = injector.get(PLATFORM_ID);
|
|
435
|
-
if (isPlatformServer(platformId)
|
|
436
|
-
return
|
|
437
|
-
|
|
438
|
-
|
|
435
|
+
if (isPlatformServer(platformId))
|
|
436
|
+
return getFirestore(injector.get(FirebaseApp));
|
|
437
|
+
if (!MobileOperationSystemCheckerHelper.isAppleDevice())
|
|
438
|
+
return getFirestore(injector.get(FirebaseApp));
|
|
439
439
|
const firestore = initializeFirestore(injector.get(FirebaseApp), {
|
|
440
440
|
experimentalForceLongPolling: true,
|
|
441
|
-
ignoreUndefinedProperties: true,
|
|
442
441
|
localCache: memoryLocalCache(),
|
|
443
442
|
});
|
|
444
443
|
return firestore;
|
|
445
444
|
}),
|
|
445
|
+
provideStorage(() => getStorage()),
|
|
446
446
|
],
|
|
447
447
|
providers: [
|
|
448
448
|
{
|
|
449
449
|
provide: 'FirestoreOptions',
|
|
450
450
|
useFactory: (firestore, platformId) => ({
|
|
451
|
-
firestore
|
|
451
|
+
firestore,
|
|
452
452
|
interceptors: {
|
|
453
453
|
request: (request) => {
|
|
454
454
|
if (isPlatformBrowser(platformId))
|
|
@@ -657,11 +657,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
657
657
|
deps: ['FirestoreOptions', ProductFirestoreRepository],
|
|
658
658
|
},
|
|
659
659
|
{
|
|
660
|
-
provide: '
|
|
661
|
-
useFactory: (
|
|
662
|
-
return new
|
|
660
|
+
provide: 'FileUploaderService',
|
|
661
|
+
useFactory: (storage, baseUrl) => {
|
|
662
|
+
return new FirebaseFileUploaderService(storage, baseUrl);
|
|
663
663
|
},
|
|
664
|
-
deps: [
|
|
664
|
+
deps: [Storage, STORAGE_BASE_URL],
|
|
665
665
|
},
|
|
666
666
|
],
|
|
667
667
|
}]
|
|
@@ -744,17 +744,6 @@ class AngularHasuraGraphQLModule {
|
|
|
744
744
|
},
|
|
745
745
|
deps: ['HasuraConfig'],
|
|
746
746
|
},
|
|
747
|
-
{
|
|
748
|
-
provide: 'ProductStockNotificationRepository',
|
|
749
|
-
useExisting: ProductStockNotificationHasuraGraphQLRepository,
|
|
750
|
-
},
|
|
751
|
-
{
|
|
752
|
-
provide: ProductStockNotificationHasuraGraphQLRepository,
|
|
753
|
-
useFactory: (hasuraConfig) => {
|
|
754
|
-
return new ProductStockNotificationHasuraGraphQLRepository(hasuraConfig);
|
|
755
|
-
},
|
|
756
|
-
deps: ['HasuraConfig'],
|
|
757
|
-
},
|
|
758
747
|
{
|
|
759
748
|
provide: 'CategoryFilterRepository',
|
|
760
749
|
useExisting: CategoryFilterHasuraGraphQLRepository,
|
|
@@ -881,17 +870,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
881
870
|
},
|
|
882
871
|
deps: ['HasuraConfig'],
|
|
883
872
|
},
|
|
884
|
-
{
|
|
885
|
-
provide: 'ProductStockNotificationRepository',
|
|
886
|
-
useExisting: ProductStockNotificationHasuraGraphQLRepository,
|
|
887
|
-
},
|
|
888
|
-
{
|
|
889
|
-
provide: ProductStockNotificationHasuraGraphQLRepository,
|
|
890
|
-
useFactory: (hasuraConfig) => {
|
|
891
|
-
return new ProductStockNotificationHasuraGraphQLRepository(hasuraConfig);
|
|
892
|
-
},
|
|
893
|
-
deps: ['HasuraConfig'],
|
|
894
|
-
},
|
|
895
873
|
{
|
|
896
874
|
provide: 'CategoryFilterRepository',
|
|
897
875
|
useExisting: CategoryFilterHasuraGraphQLRepository,
|
|
@@ -949,25 +927,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
949
927
|
}]
|
|
950
928
|
}] });
|
|
951
929
|
|
|
952
|
-
const STORAGE_BASE_URL = 'STORAGE_BASE_URL';
|
|
953
|
-
|
|
954
|
-
class CookieDataPersistence {
|
|
955
|
-
get(key) {
|
|
956
|
-
return of(cookie.get(key));
|
|
957
|
-
}
|
|
958
|
-
remove(key) {
|
|
959
|
-
return of(cookie.remove(key));
|
|
960
|
-
}
|
|
961
|
-
set(key, value) {
|
|
962
|
-
return from(cookie.set(key, value)).pipe(map(() => { }));
|
|
963
|
-
}
|
|
964
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CookieDataPersistence, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
965
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CookieDataPersistence }); }
|
|
966
|
-
}
|
|
967
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CookieDataPersistence, decorators: [{
|
|
968
|
-
type: Injectable
|
|
969
|
-
}] });
|
|
970
|
-
|
|
971
930
|
class AuthService {
|
|
972
931
|
constructor(angularFireAuth, userRepository) {
|
|
973
932
|
this.angularFireAuth = angularFireAuth;
|
|
@@ -1048,11 +1007,11 @@ class CouponService {
|
|
|
1048
1007
|
throw 'Limite de uso atingido';
|
|
1049
1008
|
}
|
|
1050
1009
|
if (!couponUseLimits.unlimited || couponUseLimits.limitedPerUser) {
|
|
1051
|
-
const
|
|
1052
|
-
if (!couponUseLimits.unlimited && couponUseLimits.total &&
|
|
1010
|
+
const orders = await this.getOrdersWithCoupon(coupon);
|
|
1011
|
+
if (!couponUseLimits.unlimited && couponUseLimits.total && orders.length >= couponUseLimits.total)
|
|
1053
1012
|
throw 'Limite de uso atingido.';
|
|
1054
1013
|
if (couponUseLimits.limitedPerUser) {
|
|
1055
|
-
const ordersWithUser = this.countOrdersWithUser(
|
|
1014
|
+
const ordersWithUser = this.countOrdersWithUser(orders, checkout.user.email);
|
|
1056
1015
|
if (ordersWithUser > 0)
|
|
1057
1016
|
throw 'Limite de uso por usuário atingido.';
|
|
1058
1017
|
}
|
|
@@ -1074,33 +1033,32 @@ class CouponService {
|
|
|
1074
1033
|
return of(discount);
|
|
1075
1034
|
}
|
|
1076
1035
|
async calcDiscountShopping(coupon, checkout) {
|
|
1077
|
-
let
|
|
1036
|
+
let discount = 0;
|
|
1078
1037
|
if (checkout.user.isSubscriber && coupon.discount.subscriber.value) {
|
|
1079
|
-
|
|
1038
|
+
discount = await this.calcDiscountByType(coupon.discount.subscriber.type, coupon.discount.subscriber.value, coupon.productsCategories, checkout);
|
|
1080
1039
|
}
|
|
1081
1040
|
else {
|
|
1082
|
-
|
|
1041
|
+
discount = await this.calcDiscountByType(coupon.discount.non_subscriber.type, coupon.discount.non_subscriber.value, coupon.productsCategories, checkout);
|
|
1083
1042
|
}
|
|
1084
|
-
return
|
|
1043
|
+
return discount;
|
|
1085
1044
|
}
|
|
1086
1045
|
async calcDiscountByType(type, value, categories, checkout) {
|
|
1087
1046
|
let discount = 0;
|
|
1088
|
-
let
|
|
1089
|
-
const subTotal = this.calcCheckoutSubtotal(
|
|
1047
|
+
let lineItensDiscount = await this.getLineItensEligebleForDiscount(categories, checkout);
|
|
1048
|
+
const subTotal = this.calcCheckoutSubtotal(lineItensDiscount, checkout.user, checkout.shop);
|
|
1090
1049
|
if (type == CouponTypes.ABSOLUTE) {
|
|
1091
1050
|
discount = value > subTotal ? subTotal : value;
|
|
1092
1051
|
}
|
|
1093
1052
|
else {
|
|
1094
1053
|
discount = subTotal * (value / 100);
|
|
1095
1054
|
}
|
|
1096
|
-
|
|
1097
|
-
return { discount, lineItems };
|
|
1055
|
+
return discount;
|
|
1098
1056
|
}
|
|
1099
1057
|
async hasMinSubTotal(coupon, checkout) {
|
|
1100
1058
|
if (!coupon.minSubTotalValue)
|
|
1101
1059
|
return true;
|
|
1102
1060
|
let lineItensDiscount = await this.getLineItensEligebleForDiscount(coupon.productsCategories, checkout);
|
|
1103
|
-
const subTotal = this.calcCheckoutSubtotal(lineItensDiscount, checkout.user);
|
|
1061
|
+
const subTotal = this.calcCheckoutSubtotal(lineItensDiscount, checkout.user, checkout.shop);
|
|
1104
1062
|
if (coupon.minSubTotalValue <= subTotal)
|
|
1105
1063
|
return true;
|
|
1106
1064
|
return false;
|
|
@@ -1168,7 +1126,7 @@ class CouponService {
|
|
|
1168
1126
|
}
|
|
1169
1127
|
return lineItensDiscount;
|
|
1170
1128
|
}
|
|
1171
|
-
calcCheckoutSubtotal(lineItens, user) {
|
|
1129
|
+
calcCheckoutSubtotal(lineItens, user, shop) {
|
|
1172
1130
|
return (lineItens?.reduce((acc, curr) => user?.isSubscriber && curr.price.subscriberPrice
|
|
1173
1131
|
? acc + curr.price?.subscriberPrice * curr.quantity
|
|
1174
1132
|
: acc + curr.pricePaid * curr.quantity, 0) || 0);
|
|
@@ -1178,7 +1136,7 @@ class CouponService {
|
|
|
1178
1136
|
.find({
|
|
1179
1137
|
filters: {
|
|
1180
1138
|
coupon: { id: coupon.id },
|
|
1181
|
-
|
|
1139
|
+
payment: { status: 'paid' },
|
|
1182
1140
|
},
|
|
1183
1141
|
})
|
|
1184
1142
|
.then((result) => result.data);
|
|
@@ -1188,7 +1146,7 @@ class CouponService {
|
|
|
1188
1146
|
.find({
|
|
1189
1147
|
filters: {
|
|
1190
1148
|
user: { email: { operator: Where.EQUALS, value: email } },
|
|
1191
|
-
|
|
1149
|
+
payment: { status: 'paid' },
|
|
1192
1150
|
},
|
|
1193
1151
|
})
|
|
1194
1152
|
.then((result) => result.data);
|
|
@@ -1199,42 +1157,13 @@ class CouponService {
|
|
|
1199
1157
|
getCouponUseLimits(coupon, checkoutType, user) {
|
|
1200
1158
|
let couponUseLimits;
|
|
1201
1159
|
if (checkoutType == CheckoutTypes.ECOMMERCE || checkoutType == CheckoutTypes.ALL) {
|
|
1202
|
-
|
|
1203
|
-
(coupon.exclusivityType.at(0) === Exclusivities.SPECIFIC_USER ||
|
|
1204
|
-
coupon.exclusivityType.at(0) === Exclusivities.COLLABORATORS))
|
|
1205
|
-
couponUseLimits = coupon.useLimits.non_subscriber;
|
|
1206
|
-
else
|
|
1207
|
-
couponUseLimits = user && user.isSubscriber ? coupon.useLimits.subscriber : coupon.useLimits.non_subscriber;
|
|
1160
|
+
couponUseLimits = user && user.isSubscriber ? coupon.useLimits.subscriber : coupon.useLimits.non_subscriber;
|
|
1208
1161
|
}
|
|
1209
1162
|
else {
|
|
1210
1163
|
couponUseLimits = coupon.useLimits.subscription;
|
|
1211
1164
|
}
|
|
1212
1165
|
return couponUseLimits;
|
|
1213
1166
|
}
|
|
1214
|
-
calcLineItenDiscount(type, lineItems, couponDiscount, subTotal) {
|
|
1215
|
-
let lineItemsDiscount = [];
|
|
1216
|
-
if (type === CouponTypes.ABSOLUTE) {
|
|
1217
|
-
const couponDiscountMax = couponDiscount > subTotal ? subTotal : couponDiscount;
|
|
1218
|
-
lineItemsDiscount = lineItems.map((item) => {
|
|
1219
|
-
const totalItemPercentage = item.pricePaid / subTotal;
|
|
1220
|
-
const discountItem = couponDiscountMax * totalItemPercentage;
|
|
1221
|
-
return {
|
|
1222
|
-
...item,
|
|
1223
|
-
discount: Number(discountItem.toFixed(2)),
|
|
1224
|
-
};
|
|
1225
|
-
});
|
|
1226
|
-
}
|
|
1227
|
-
else {
|
|
1228
|
-
lineItemsDiscount = lineItems.map((item) => {
|
|
1229
|
-
const discountItem = item.pricePaid * (couponDiscount / 100);
|
|
1230
|
-
return {
|
|
1231
|
-
...item,
|
|
1232
|
-
discount: Number(discountItem.toFixed(2)),
|
|
1233
|
-
};
|
|
1234
|
-
});
|
|
1235
|
-
}
|
|
1236
|
-
return lineItemsDiscount;
|
|
1237
|
-
}
|
|
1238
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 }); }
|
|
1239
1168
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CouponService, providedIn: 'root' }); }
|
|
1240
1169
|
}
|
|
@@ -1258,17 +1187,18 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
1258
1187
|
}] }] });
|
|
1259
1188
|
|
|
1260
1189
|
class CheckoutService {
|
|
1261
|
-
constructor(couponService, checkoutRepository, userRepository, defaultShop
|
|
1190
|
+
constructor(couponService, checkoutRepository, orderRepository, userRepository, defaultShop) {
|
|
1262
1191
|
this.couponService = couponService;
|
|
1263
1192
|
this.checkoutRepository = checkoutRepository;
|
|
1193
|
+
this.orderRepository = orderRepository;
|
|
1264
1194
|
this.userRepository = userRepository;
|
|
1265
1195
|
this.defaultShop = defaultShop;
|
|
1266
|
-
this.dataPersistence = dataPersistence;
|
|
1267
1196
|
}
|
|
1268
1197
|
getCheckout(checkoutData) {
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1198
|
+
const checkoutId = cookie.get('checkoutId');
|
|
1199
|
+
if (!isNil(checkoutId))
|
|
1200
|
+
return from(this.checkoutRepository.get({ id: checkoutId }));
|
|
1201
|
+
return from(this.createCheckout(checkoutData));
|
|
1272
1202
|
}
|
|
1273
1203
|
getUserByCheckout(checkoutId) {
|
|
1274
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'))));
|
|
@@ -1280,7 +1210,8 @@ class CheckoutService {
|
|
|
1280
1210
|
return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, user: checkout.user })));
|
|
1281
1211
|
}
|
|
1282
1212
|
clearCheckoutFromSession() {
|
|
1283
|
-
|
|
1213
|
+
cookie.remove('checkoutId');
|
|
1214
|
+
return of();
|
|
1284
1215
|
}
|
|
1285
1216
|
calcDiscount(coupon) {
|
|
1286
1217
|
return this.getCheckout().pipe(concatMap(async (checkout) => await this.couponService.calcDiscountShopping(coupon, checkout)));
|
|
@@ -1294,10 +1225,10 @@ class CheckoutService {
|
|
|
1294
1225
|
...Checkout.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain(),
|
|
1295
1226
|
shop: checkoutData?.shop || this.defaultShop,
|
|
1296
1227
|
});
|
|
1297
|
-
|
|
1228
|
+
cookie.set('checkoutId', checkout.id);
|
|
1298
1229
|
return checkout;
|
|
1299
1230
|
}
|
|
1300
|
-
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 }); }
|
|
1301
1232
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CheckoutService }); }
|
|
1302
1233
|
}
|
|
1303
1234
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CheckoutService, decorators: [{
|
|
@@ -1305,15 +1236,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
1305
1236
|
}], ctorParameters: () => [{ type: CouponService }, { type: undefined, decorators: [{
|
|
1306
1237
|
type: Inject,
|
|
1307
1238
|
args: ['CheckoutRepository']
|
|
1239
|
+
}] }, { type: undefined, decorators: [{
|
|
1240
|
+
type: Inject,
|
|
1241
|
+
args: ['OrderRepository']
|
|
1308
1242
|
}] }, { type: undefined, decorators: [{
|
|
1309
1243
|
type: Inject,
|
|
1310
1244
|
args: ['UserRepository']
|
|
1311
1245
|
}] }, { type: i1$2.Shops, decorators: [{
|
|
1312
1246
|
type: Inject,
|
|
1313
1247
|
args: [DEFAULT_SHOP]
|
|
1314
|
-
}] }, { type: undefined, decorators: [{
|
|
1315
|
-
type: Inject,
|
|
1316
|
-
args: [PERSISTENCE_PROVIDER]
|
|
1317
1248
|
}] }] });
|
|
1318
1249
|
|
|
1319
1250
|
class CartService {
|
|
@@ -1332,7 +1263,6 @@ class CartService {
|
|
|
1332
1263
|
if (index > -1) {
|
|
1333
1264
|
checkoutLoaded.lineItems[index].quantity += quantity;
|
|
1334
1265
|
checkoutLoaded.lineItems[index].pricePaid = lineItem.pricePaid;
|
|
1335
|
-
checkoutLoaded.lineItems[index].price = lineItem.price;
|
|
1336
1266
|
}
|
|
1337
1267
|
else
|
|
1338
1268
|
checkoutLoaded.lineItems = items.concat(checkoutLoaded.lineItems ? checkoutLoaded.lineItems.concat([lineItem]) : [lineItem]);
|
|
@@ -1350,18 +1280,17 @@ class CartService {
|
|
|
1350
1280
|
this.buildLineItem = async ({ checkout, item, quantity, }) => {
|
|
1351
1281
|
const product = await this.getProductData(item.id);
|
|
1352
1282
|
item.quantity = item?.quantity || checkout?.lineItems?.find((lineItem) => lineItem.id === item.id)?.quantity || 0;
|
|
1353
|
-
if (this.checkMaxStock(
|
|
1354
|
-
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.');
|
|
1355
1285
|
const image = item.image || item.images?.shift();
|
|
1356
|
-
const { id, name, EAN, slug, weight, sku, type } = item;
|
|
1286
|
+
const { id, name, EAN, slug, stock, price, weight, sku, type } = item;
|
|
1357
1287
|
const isGift = item.isGift || null;
|
|
1358
1288
|
const pricePaid = this.getProductPrice({
|
|
1359
|
-
product:
|
|
1289
|
+
product: item,
|
|
1360
1290
|
shop: checkout.shop || this.defaultShop,
|
|
1361
1291
|
isSubscriber: checkout.user?.isSubscriber,
|
|
1362
1292
|
});
|
|
1363
1293
|
RoundProductPricesHelper.roundProductPrices(item);
|
|
1364
|
-
RoundProductPricesHelper.roundProductPrices(product);
|
|
1365
1294
|
return {
|
|
1366
1295
|
checkout,
|
|
1367
1296
|
lineItem: LineItem.toInstance({
|
|
@@ -1371,13 +1300,12 @@ class CartService {
|
|
|
1371
1300
|
brand: product.brand,
|
|
1372
1301
|
slug: slug ?? product.slug,
|
|
1373
1302
|
sku: sku ?? product.sku,
|
|
1374
|
-
stock
|
|
1375
|
-
price: this.roundPrice(
|
|
1303
|
+
stock,
|
|
1304
|
+
price: this.roundPrice(price),
|
|
1376
1305
|
image,
|
|
1377
1306
|
weight: weight ?? product.weight,
|
|
1378
1307
|
quantity: (item.quantity || 0) + (quantity || 0),
|
|
1379
1308
|
pricePaid,
|
|
1380
|
-
discount: 0,
|
|
1381
1309
|
categories: product.categories ?? [],
|
|
1382
1310
|
isGift: isGift ?? null,
|
|
1383
1311
|
costPrice: product.costPrice ?? 0,
|
|
@@ -1393,10 +1321,10 @@ class CartService {
|
|
|
1393
1321
|
? Number(info.subscriberPrice.toFixed(2))
|
|
1394
1322
|
: Number(info.price.toFixed(2));
|
|
1395
1323
|
};
|
|
1396
|
-
this.checkMaxStock = (
|
|
1397
|
-
const maxStock =
|
|
1398
|
-
const currentItemAmount =
|
|
1399
|
-
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;
|
|
1400
1328
|
};
|
|
1401
1329
|
}
|
|
1402
1330
|
addItem(item, quantity = 1) {
|
|
@@ -1613,11 +1541,9 @@ class NewCategoryStructureAdapter {
|
|
|
1613
1541
|
.then((categories) => categories.map((category) => category.id.toString()));
|
|
1614
1542
|
}
|
|
1615
1543
|
async getCategory(category) {
|
|
1616
|
-
|
|
1617
|
-
(
|
|
1618
|
-
category
|
|
1619
|
-
category.brandCategory;
|
|
1620
|
-
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;
|
|
1621
1547
|
}
|
|
1622
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 }); }
|
|
1623
1549
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: NewCategoryStructureAdapter }); }
|
|
@@ -1650,9 +1576,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
1650
1576
|
}] }] });
|
|
1651
1577
|
|
|
1652
1578
|
class CatalogService {
|
|
1653
|
-
constructor(productRepository,
|
|
1579
|
+
constructor(productRepository, categoryRepository, categoryStructureAdapter, shop, productIndex) {
|
|
1654
1580
|
this.productRepository = productRepository;
|
|
1655
|
-
this.productStockNotificationRepository = productStockNotificationRepository;
|
|
1656
1581
|
this.categoryRepository = categoryRepository;
|
|
1657
1582
|
this.categoryStructureAdapter = categoryStructureAdapter;
|
|
1658
1583
|
this.shop = shop;
|
|
@@ -1683,22 +1608,17 @@ class CatalogService {
|
|
|
1683
1608
|
if (!sort || sort === 'most-relevant')
|
|
1684
1609
|
return {};
|
|
1685
1610
|
if (sort === 'best-sellers')
|
|
1686
|
-
return {
|
|
1687
|
-
shoppingCount: 'desc',
|
|
1688
|
-
rate: 'desc',
|
|
1689
|
-
stock: 'desc',
|
|
1690
|
-
name: 'asc',
|
|
1691
|
-
};
|
|
1611
|
+
return { shoppingCount: 'desc' };
|
|
1692
1612
|
if (sort === 'biggest-price')
|
|
1693
|
-
return { subscriberPrice: 'desc'
|
|
1613
|
+
return { subscriberPrice: 'desc' };
|
|
1694
1614
|
if (sort === 'lowest-price')
|
|
1695
|
-
return { subscriberPrice: 'asc'
|
|
1615
|
+
return { subscriberPrice: 'asc' };
|
|
1696
1616
|
if (sort === 'best-rating')
|
|
1697
|
-
return { rate: 'desc'
|
|
1617
|
+
return { rate: 'desc' };
|
|
1698
1618
|
if (sort === 'news')
|
|
1699
1619
|
return { createdAt: 'desc' };
|
|
1700
1620
|
if (sort === 'biggest-discount')
|
|
1701
|
-
return { subscriberDiscountPercentage: 'desc'
|
|
1621
|
+
return { subscriberDiscountPercentage: 'desc' };
|
|
1702
1622
|
};
|
|
1703
1623
|
this.buildLimitQuery = (options) => {
|
|
1704
1624
|
const limit = options?.perPage || 20;
|
|
@@ -1732,26 +1652,16 @@ class CatalogService {
|
|
|
1732
1652
|
brands: distinct?.brand,
|
|
1733
1653
|
}));
|
|
1734
1654
|
}
|
|
1735
|
-
async addCustomerToStockNotification(shop, productId, name, email) {
|
|
1736
|
-
return this.productStockNotificationRepository.addCustomerEmail(shop, productId, name, email);
|
|
1737
|
-
}
|
|
1738
1655
|
async findCatalog(options, limits) {
|
|
1739
1656
|
if (this.hasTerm(options) && options.sort === 'most-relevant') {
|
|
1740
1657
|
const productsIds = await this.findCatalogIdsByElasticSearch(options.term);
|
|
1741
|
-
return this.
|
|
1658
|
+
return this.findCatalogAndSortByMostRevelant(productsIds, options, limits);
|
|
1742
1659
|
}
|
|
1743
1660
|
if (this.hasCategory(options) && options.sort === 'most-relevant') {
|
|
1744
|
-
const
|
|
1745
|
-
|
|
1746
|
-
.
|
|
1747
|
-
|
|
1748
|
-
filters: {
|
|
1749
|
-
...(await this.buildMainFilter(options)),
|
|
1750
|
-
...this.buildFilterQuery(options?.filters || {}),
|
|
1751
|
-
},
|
|
1752
|
-
})
|
|
1753
|
-
.then((products) => products.data.map((product) => product.id));
|
|
1754
|
-
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);
|
|
1755
1665
|
}
|
|
1756
1666
|
const repoParams = {
|
|
1757
1667
|
filters: {
|
|
@@ -1780,38 +1690,7 @@ class CatalogService {
|
|
|
1780
1690
|
.search(term, 999, this.shop)
|
|
1781
1691
|
.then((data) => ({ id: { operator: Where.IN, value: data.hits.map(({ _source }) => _source.id) } }));
|
|
1782
1692
|
}
|
|
1783
|
-
async findCatalogAndSortByMostRevelant(
|
|
1784
|
-
const mostRelevantProductsIds = [...new Set(mostRelevants.concat(productIds))];
|
|
1785
|
-
const totalResult = await this.productRepository.findCatalog({
|
|
1786
|
-
filters: {
|
|
1787
|
-
id: { operator: Where.IN, value: mostRelevantProductsIds },
|
|
1788
|
-
...this.buildFilterQuery(options?.filters || {}),
|
|
1789
|
-
},
|
|
1790
|
-
orderBy: this.buildSortQuery('best-sellers'),
|
|
1791
|
-
options: {
|
|
1792
|
-
minimal: ['price'],
|
|
1793
|
-
maximum: ['price'],
|
|
1794
|
-
distinct: ['brand'],
|
|
1795
|
-
},
|
|
1796
|
-
}, options?.mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female');
|
|
1797
|
-
const mostRelevantWithouyStock = totalResult.data.filter((product) => mostRelevants.includes(product.id) && product.stock.quantity <= 0);
|
|
1798
|
-
const firstProducts = totalResult.data
|
|
1799
|
-
.filter((product) => mostRelevants.includes(product.id) && product.stock.quantity > 0)
|
|
1800
|
-
.sort((a, b) => mostRelevants.indexOf(a.id) - mostRelevants.indexOf(b.id));
|
|
1801
|
-
const lastProducts = totalResult.data
|
|
1802
|
-
.filter((product) => !mostRelevants.includes(product.id))
|
|
1803
|
-
.concat(mostRelevantWithouyStock);
|
|
1804
|
-
const categoryMostRelevants = firstProducts.concat(lastProducts);
|
|
1805
|
-
const resultFinal = categoryMostRelevants.slice(limits.offset, limits.offset + limits.limit);
|
|
1806
|
-
return {
|
|
1807
|
-
data: resultFinal,
|
|
1808
|
-
count: totalResult.count,
|
|
1809
|
-
maximum: totalResult.maximum,
|
|
1810
|
-
minimal: totalResult.minimal,
|
|
1811
|
-
distinct: totalResult.distinct,
|
|
1812
|
-
};
|
|
1813
|
-
}
|
|
1814
|
-
async findCatalogAndSortByMostRevelantByTerm(productIds, options, limits) {
|
|
1693
|
+
async findCatalogAndSortByMostRevelant(productIds, options, limits) {
|
|
1815
1694
|
const totalResult = await this.productRepository.findCatalog({
|
|
1816
1695
|
fields: ['id', 'stock'],
|
|
1817
1696
|
filters: {
|
|
@@ -1857,7 +1736,7 @@ class CatalogService {
|
|
|
1857
1736
|
return [...new Set(sorted.map(({ _source }) => _source.id))];
|
|
1858
1737
|
}));
|
|
1859
1738
|
}
|
|
1860
|
-
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 }); }
|
|
1861
1740
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CatalogService }); }
|
|
1862
1741
|
}
|
|
1863
1742
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CatalogService, decorators: [{
|
|
@@ -1865,9 +1744,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
1865
1744
|
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
1866
1745
|
type: Inject,
|
|
1867
1746
|
args: ['ProductRepository']
|
|
1868
|
-
}] }, { type: undefined, decorators: [{
|
|
1869
|
-
type: Inject,
|
|
1870
|
-
args: ['ProductStockNotificationRepository']
|
|
1871
1747
|
}] }, { type: undefined, decorators: [{
|
|
1872
1748
|
type: Inject,
|
|
1873
1749
|
args: ['CategoryRepository']
|
|
@@ -1944,11 +1820,11 @@ __decorate([
|
|
|
1944
1820
|
], CategoryWithTree.prototype, "children", void 0);
|
|
1945
1821
|
|
|
1946
1822
|
class WishlistService {
|
|
1947
|
-
constructor(wishlistRepository, shop, productRepository, categoryFilterRepository, categoryRepository,
|
|
1823
|
+
constructor(wishlistRepository, shop, productRepository, categoryFilterRepository, categoryRepository, productIndex) {
|
|
1948
1824
|
this.wishlistRepository = wishlistRepository;
|
|
1949
1825
|
this.shop = shop;
|
|
1950
1826
|
const categoryStructureAdapter = new NewCategoryStructureAdapter(wishlistRepository);
|
|
1951
|
-
this.catalogService = new CatalogService(productRepository,
|
|
1827
|
+
this.catalogService = new CatalogService(productRepository, categoryRepository, categoryStructureAdapter, shop, productIndex);
|
|
1952
1828
|
this.categoryService = new CategoryService(productRepository, categoryRepository, categoryFilterRepository, categoryStructureAdapter, shop);
|
|
1953
1829
|
}
|
|
1954
1830
|
getCatalogService() {
|
|
@@ -1957,53 +1833,42 @@ class WishlistService {
|
|
|
1957
1833
|
getCategoryService() {
|
|
1958
1834
|
return this.categoryService;
|
|
1959
1835
|
}
|
|
1960
|
-
async create({ personId, title, description,
|
|
1836
|
+
async create({ personId, title, description, userFullName, userPhoto, theme, bannerUrl, }) {
|
|
1961
1837
|
const data = {
|
|
1962
1838
|
slug: '',
|
|
1963
1839
|
name: title,
|
|
1964
1840
|
description,
|
|
1965
|
-
|
|
1966
|
-
{
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
description: `${userFullName} - ${description}`,
|
|
1970
|
-
},
|
|
1971
|
-
],
|
|
1841
|
+
metadata: {
|
|
1842
|
+
title: `${userFullName} - ${title}`,
|
|
1843
|
+
description: `${userFullName} - ${description}`,
|
|
1844
|
+
},
|
|
1972
1845
|
shop: this.shop,
|
|
1973
1846
|
shops: [this.shop],
|
|
1974
1847
|
personId,
|
|
1975
1848
|
personName: userFullName,
|
|
1976
1849
|
personPhoto: userPhoto,
|
|
1977
1850
|
brandCategory: false,
|
|
1978
|
-
published,
|
|
1851
|
+
published: true,
|
|
1979
1852
|
theme,
|
|
1980
1853
|
bannerUrl,
|
|
1981
|
-
personType: personType ?? PersonTypes.NONE,
|
|
1982
|
-
personIsSubscriber: personIsSubscriber ?? false,
|
|
1983
1854
|
};
|
|
1984
1855
|
const newWishlist = await this.wishlistRepository.create(data);
|
|
1985
1856
|
await this.wishlistRepository.update({ id: newWishlist.id, slug: newWishlist.id });
|
|
1986
1857
|
return Wishlist.toInstance({ ...newWishlist.toPlain(), slug: newWishlist.id });
|
|
1987
1858
|
}
|
|
1988
|
-
update({ id, title, description,
|
|
1859
|
+
update({ id, title, description, userFullName, userPhoto, theme, bannerUrl, }) {
|
|
1989
1860
|
const data = {
|
|
1990
1861
|
id,
|
|
1991
1862
|
name: title,
|
|
1992
1863
|
description,
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
{
|
|
1996
|
-
|
|
1997
|
-
title: `${userFullName} - ${title}`,
|
|
1998
|
-
description: `${userFullName} - ${description}`,
|
|
1999
|
-
},
|
|
2000
|
-
],
|
|
1864
|
+
metadata: {
|
|
1865
|
+
title: `${userFullName} - ${title}`,
|
|
1866
|
+
description: `${userFullName} - ${description}`,
|
|
1867
|
+
},
|
|
2001
1868
|
personName: userFullName,
|
|
2002
1869
|
personPhoto: userPhoto,
|
|
2003
1870
|
theme,
|
|
2004
1871
|
bannerUrl,
|
|
2005
|
-
personType: personType ?? PersonTypes.NONE,
|
|
2006
|
-
personIsSubscriber: personIsSubscriber ?? false,
|
|
2007
1872
|
};
|
|
2008
1873
|
return this.wishlistRepository.update(data);
|
|
2009
1874
|
}
|
|
@@ -2039,7 +1904,7 @@ class WishlistService {
|
|
|
2039
1904
|
}
|
|
2040
1905
|
return wishlist;
|
|
2041
1906
|
}
|
|
2042
|
-
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 }); }
|
|
2043
1908
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: WishlistService }); }
|
|
2044
1909
|
}
|
|
2045
1910
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: WishlistService, decorators: [{
|
|
@@ -2059,24 +1924,31 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
2059
1924
|
}] }, { type: undefined, decorators: [{
|
|
2060
1925
|
type: Inject,
|
|
2061
1926
|
args: ['CategoryRepository']
|
|
2062
|
-
}] }, { type: undefined, decorators: [{
|
|
2063
|
-
type: Inject,
|
|
2064
|
-
args: ['ProductStockNotificationRepository']
|
|
2065
1927
|
}] }, { type: i1$2.ProductsIndex }] });
|
|
2066
1928
|
|
|
2067
1929
|
class CheckoutSubscriptionService {
|
|
2068
|
-
constructor(checkoutSubscriptionRepository,
|
|
1930
|
+
constructor(checkoutSubscriptionRepository, subscriptionRepository, couponService) {
|
|
2069
1931
|
this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
|
|
2070
|
-
this.
|
|
1932
|
+
this.subscriptionRepository = subscriptionRepository;
|
|
2071
1933
|
this.couponService = couponService;
|
|
2072
1934
|
}
|
|
2073
1935
|
getCheckoutSubscription(checkoutData) {
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
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;
|
|
2077
1948
|
}
|
|
2078
1949
|
clearCheckoutSubscriptionFromSession() {
|
|
2079
|
-
|
|
1950
|
+
cookie.remove('checkoutSubscriptionId');
|
|
1951
|
+
return of();
|
|
2080
1952
|
}
|
|
2081
1953
|
checkCoupon(nickname, userEmail) {
|
|
2082
1954
|
return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService
|
|
@@ -2086,15 +1958,7 @@ class CheckoutSubscriptionService {
|
|
|
2086
1958
|
calcDiscountSubscription(coupon) {
|
|
2087
1959
|
return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService.calcDiscountSubscription(coupon, checkout).pipe()));
|
|
2088
1960
|
}
|
|
2089
|
-
|
|
2090
|
-
const checkout = await this.checkoutSubscriptionRepository.create({
|
|
2091
|
-
createdAt: new Date(),
|
|
2092
|
-
...CheckoutSubscription.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain(),
|
|
2093
|
-
});
|
|
2094
|
-
await this.dataPersistence.set('checkoutSubscriptionId', checkout.id).toPromise();
|
|
2095
|
-
return checkout;
|
|
2096
|
-
}
|
|
2097
|
-
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 }); }
|
|
2098
1962
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CheckoutSubscriptionService }); }
|
|
2099
1963
|
}
|
|
2100
1964
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CheckoutSubscriptionService, decorators: [{
|
|
@@ -2104,7 +1968,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
2104
1968
|
args: ['CheckoutSubscriptionRepository']
|
|
2105
1969
|
}] }, { type: undefined, decorators: [{
|
|
2106
1970
|
type: Inject,
|
|
2107
|
-
args: [
|
|
1971
|
+
args: ['SubscriptionRepository']
|
|
2108
1972
|
}] }, { type: CouponService }] });
|
|
2109
1973
|
|
|
2110
1974
|
class UtilHelper {
|
|
@@ -2362,7 +2226,6 @@ class AngularConnectModule {
|
|
|
2362
2226
|
? OldCategoryStructureAdapter
|
|
2363
2227
|
: NewCategoryStructureAdapter,
|
|
2364
2228
|
},
|
|
2365
|
-
{ provide: PERSISTENCE_PROVIDER, useClass: options?.persistenceProvider || CookieDataPersistence },
|
|
2366
2229
|
...(isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]),
|
|
2367
2230
|
...(isNil(options?.firebase) ? [] : [{ provide: FIREBASE_OPTIONS, useValue: options?.firebase }]),
|
|
2368
2231
|
...(isNil(options?.firebase) ? [] : [{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig }]),
|
|
@@ -2374,7 +2237,7 @@ class AngularConnectModule {
|
|
|
2374
2237
|
};
|
|
2375
2238
|
}
|
|
2376
2239
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AngularConnectModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
2377
|
-
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,
|
|
2378
2241
|
AngularFirebaseAuthModule,
|
|
2379
2242
|
AngularFirestoreModule,
|
|
2380
2243
|
AngularHasuraGraphQLModule] }); }
|
|
@@ -2397,13 +2260,6 @@ class AngularConnectModule {
|
|
|
2397
2260
|
},
|
|
2398
2261
|
deps: ['UserRepository', 'FileUploaderService'],
|
|
2399
2262
|
},
|
|
2400
|
-
{
|
|
2401
|
-
provide: 'FileUploaderService',
|
|
2402
|
-
useFactory: (storage, baseUrl) => {
|
|
2403
|
-
return new FirebaseFileUploaderService(storage, baseUrl);
|
|
2404
|
-
},
|
|
2405
|
-
deps: [Storage, STORAGE_BASE_URL],
|
|
2406
|
-
},
|
|
2407
2263
|
], imports: [provideFirebaseApp((injector) => {
|
|
2408
2264
|
const appName = injector.get(FIREBASE_APP_NAME) || '[DEFAULT]';
|
|
2409
2265
|
try {
|
|
@@ -2413,7 +2269,6 @@ class AngularConnectModule {
|
|
|
2413
2269
|
return initializeApp(injector.get(FIREBASE_OPTIONS), appName);
|
|
2414
2270
|
}
|
|
2415
2271
|
}),
|
|
2416
|
-
provideStorage((injector) => getStorage(injector.get(FirebaseApp))),
|
|
2417
2272
|
AngularElasticSeachModule,
|
|
2418
2273
|
AngularFirebaseAuthModule,
|
|
2419
2274
|
AngularFirestoreModule,
|
|
@@ -2432,7 +2287,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
2432
2287
|
return initializeApp(injector.get(FIREBASE_OPTIONS), appName);
|
|
2433
2288
|
}
|
|
2434
2289
|
}),
|
|
2435
|
-
provideStorage((injector) => getStorage(injector.get(FirebaseApp))),
|
|
2436
2290
|
AngularElasticSeachModule,
|
|
2437
2291
|
AngularFirebaseAuthModule,
|
|
2438
2292
|
AngularFirestoreModule,
|
|
@@ -2457,13 +2311,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
2457
2311
|
},
|
|
2458
2312
|
deps: ['UserRepository', 'FileUploaderService'],
|
|
2459
2313
|
},
|
|
2460
|
-
{
|
|
2461
|
-
provide: 'FileUploaderService',
|
|
2462
|
-
useFactory: (storage, baseUrl) => {
|
|
2463
|
-
return new FirebaseFileUploaderService(storage, baseUrl);
|
|
2464
|
-
},
|
|
2465
|
-
deps: [Storage, STORAGE_BASE_URL],
|
|
2466
|
-
},
|
|
2467
2314
|
],
|
|
2468
2315
|
}]
|
|
2469
2316
|
}] });
|
|
@@ -2472,5 +2319,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
2472
2319
|
* Generated bundle index. Do not edit.
|
|
2473
2320
|
*/
|
|
2474
2321
|
|
|
2475
|
-
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 };
|
|
2476
2323
|
//# sourceMappingURL=infrab4a-connect-angular.mjs.map
|