@infrab4a/connect-angular 4.17.3-beta.0 → 4.17.3-beta.10

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.
@@ -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
- import * as i1$3 from '@angular/fire/app';
3
+ import * as i1$4 from '@angular/fire/app';
4
4
  import { FirebaseApp, provideFirebaseApp, getApp, initializeApp } from '@angular/fire/app';
5
5
  import * as i2 from '@angular/fire/storage';
6
6
  import { Storage, provideStorage, getStorage } from '@angular/fire/storage';
7
- import * as i1$2 from '@infrab4a/connect';
8
- import { ProductsIndex, AxiosAdapter, Authentication, AuthenticationFirebaseAuthService, Register, RegisterFirebaseAuthService, SignOut, RecoveryPassword, ConnectFirestoreService, UserBeautyProfileFirestoreRepository, Buy2WinFirestoreRepository, CategoryFirestoreRepository, CheckoutFirestoreRepository, CheckoutSubscriptionFirestoreRepository, CouponFirestoreRepository, CampaignHashtagFirestoreRepository, CampaignDashboardFirestoreRepository, SubscriptionEditionFirestoreRepository, HomeFirestoreRepository, LeadFirestoreRepository, LegacyOrderFirestoreRepository, ShopMenuFirestoreRepository, OrderFirestoreRepository, PaymentFirestoreRepository, ProductFirestoreRepository, ShopSettingsFirestoreRepository, SubscriptionPaymentFirestoreRepository, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionFirestoreRepository, UserFirestoreRepository, UserAddressFirestoreRepository, UserPaymentMethodFirestoreRepository, SubscriptionMaterializationFirestoreRepository, SubscriptionSummaryFirestoreRepository, ProductVariantFirestoreRepository, OrderBlockedFirestoreRepository, LogFirestoreRepository, SequenceFirestoreRepository, CategoryHasuraGraphQLRepository, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository, ProductReviewsHasuraGraphQLRepository, VariantHasuraGraphQLRepository, ProductStockNotificationHasuraGraphQLRepository, FilterOptionHasuraGraphQLRepository, FilterHasuraGraphQLRepository, CategoryCollectionChildrenHasuraGraphQLRepository, CategoryProductHasuraGraphQLRepository, WishlistHasuraGraphQLRepository, ProductsVertexSearch, VertexAxiosAdapter, Where, Shops, CheckoutTypes, CouponTypes, Exclusivities, OrderStatus, isNil, NotFoundError, Checkout, pick, LineItem, RoundProductPricesHelper, set, InvalidArgumentError, isEmpty, Category, PersonTypes, WishlistLogType, Wishlist, CheckoutSubscription, Product, RequiredArgumentError, add, Order, UpdateUserImage, FirebaseFileUploaderService } from '@infrab4a/connect';
7
+ import * as i1$3 from '@infrab4a/connect';
8
+ import { ProductsIndex, AxiosAdapter, Authentication, AuthenticationFirebaseAuthService, Register, RegisterFirebaseAuthService, SignOut, RecoveryPassword, ConnectFirestoreService, UserBeautyProfileFirestoreRepository, Buy2WinFirestoreRepository, CategoryFirestoreRepository, CheckoutFirestoreRepository, CheckoutSubscriptionFirestoreRepository, CouponFirestoreRepository, CampaignHashtagFirestoreRepository, CampaignDashboardFirestoreRepository, SubscriptionEditionFirestoreRepository, HomeFirestoreRepository, LeadFirestoreRepository, LegacyOrderFirestoreRepository, ShopMenuFirestoreRepository, OrderFirestoreRepository, PaymentFirestoreRepository, ProductFirestoreRepository, ShopSettingsFirestoreRepository, SubscriptionPaymentFirestoreRepository, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionFirestoreRepository, UserFirestoreRepository, UserAddressFirestoreRepository, UserPaymentMethodFirestoreRepository, SubscriptionMaterializationFirestoreRepository, SubscriptionSummaryFirestoreRepository, ProductVariantFirestoreRepository, OrderBlockedFirestoreRepository, LogFirestoreRepository, SequenceFirestoreRepository, CategoryHasuraGraphQLRepository, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository, ProductReviewsHasuraGraphQLRepository, VariantHasuraGraphQLRepository, ProductStockNotificationHasuraGraphQLRepository, FilterOptionHasuraGraphQLRepository, FilterHasuraGraphQLRepository, CategoryCollectionChildrenHasuraGraphQLRepository, CategoryProductHasuraGraphQLRepository, WishlistHasuraGraphQLRepository, ProductsVertexSearch, VertexAxiosAdapter, isNil, NotFoundError, Checkout, pick, LineItem, Where, set, InvalidArgumentError, RoundProductPricesHelper, isEmpty, Shops, Category, PersonTypes, WishlistLogType, Wishlist, CheckoutTypes, CouponTypes, Exclusivities, OrderStatus, CheckoutSubscription, Product, RequiredArgumentError, add, Order, UpdateUserImage, FirebaseFileUploaderService } from '@infrab4a/connect';
9
9
  import * as i1 from '@angular/fire/auth';
10
10
  import { Auth, provideAuth, getAuth, getIdToken, authState } from '@angular/fire/auth';
11
11
  import { isPlatformBrowser, isPlatformServer } from '@angular/common';
12
12
  import * as i1$1 from '@angular/fire/firestore';
13
13
  import { Firestore, provideFirestore, initializeFirestore, memoryLocalCache, docSnapshots, doc } from '@angular/fire/firestore';
14
14
  import cookie from 'js-cookie';
15
- import { of, from, combineLatest, throwError, Subject, iif, forkJoin } from 'rxjs';
15
+ import { of, from, combineLatest, throwError, Subject, forkJoin } from 'rxjs';
16
16
  import { map, mergeMap, catchError, concatMap, tap } from 'rxjs/operators';
17
- import * as i3 from '@angular/common/http';
17
+ import * as i1$2 from '@angular/common/http';
18
18
  import { __decorate, __metadata } from 'tslib';
19
19
  import { Type } from 'class-transformer';
20
20
 
@@ -1081,290 +1081,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
1081
1081
  args: ['UserRepository']
1082
1082
  }] }]; } });
1083
1083
 
1084
- class CouponService {
1085
- constructor(couponRepository, defaultShop, orderRepository, categoryRepository) {
1086
- this.couponRepository = couponRepository;
1087
- this.defaultShop = defaultShop;
1088
- this.orderRepository = orderRepository;
1089
- this.categoryRepository = categoryRepository;
1090
- this.emailIsFromCollaborator = (userEmail) => !!userEmail?.match(/@b4a.com.br/g);
1091
- }
1092
- checkCoupon(nickname, checkoutType, checkout, plan) {
1093
- return from(this.couponRepository
1094
- .find({
1095
- filters: {
1096
- nickname: { operator: Where.EQUALS, value: nickname },
1097
- active: { operator: Where.EQUALS, value: true },
1098
- },
1099
- })
1100
- .then((result) => result.data[0])).pipe(concatMap((coupon) => this.couponValidation(coupon, checkoutType)), concatMap((couponValid) => this.couponRulesValidation(couponValid, checkoutType, checkout, plan)), map((couponValidated) => couponValidated));
1101
- }
1102
- async couponValidation(coupon, checkoutType) {
1103
- if (!coupon)
1104
- throw 'Cupom inválido.';
1105
- if (coupon?.beginAt && coupon?.beginAt.getTime() > new Date().getTime())
1106
- throw 'Cupom inválido.';
1107
- if (coupon?.expiresIn && coupon?.expiresIn.getTime() < new Date().getTime())
1108
- throw 'Cupom expirado.';
1109
- const isInShop = coupon.shopAvailability === Shops.ALL || coupon.shopAvailability === this.defaultShop;
1110
- if (!isInShop)
1111
- throw 'Cupom inválido para loja.';
1112
- const isCheckoutType = coupon.checkoutType === CheckoutTypes.ALL || coupon.checkoutType === checkoutType;
1113
- if (!isCheckoutType)
1114
- throw 'Cupom inválido. Erro de checkout.';
1115
- return coupon;
1116
- }
1117
- async couponRulesValidation(coupon, checkoutType, checkout, plan) {
1118
- if (checkoutType == CheckoutTypes.SUBSCRIPTION) {
1119
- if (coupon.plan && coupon.plan.toUpperCase() !== plan.toUpperCase())
1120
- throw 'Cupom inválido para sua assinatura.';
1121
- return coupon;
1122
- }
1123
- const validUser = this.coupomUserValidation(coupon, checkout?.user);
1124
- if (!validUser)
1125
- throw 'Usuário não elegível.';
1126
- const couponUseLimits = this.getCouponUseLimits(coupon, checkoutType, checkout.user);
1127
- if (couponUseLimits.firstOrder) {
1128
- const ordersUser = await this.getOrdersFromUser(checkout.user.email.toLocaleLowerCase());
1129
- if (couponUseLimits.firstOrder && ordersUser.length >= 1)
1130
- throw 'Limite de uso atingido';
1131
- }
1132
- if (!couponUseLimits.unlimited || couponUseLimits.limitedPerUser) {
1133
- const ordersCoupon = await this.getOrdersWithCoupon(coupon);
1134
- if (!couponUseLimits.unlimited && couponUseLimits.total && ordersCoupon.length >= couponUseLimits.total)
1135
- throw 'Limite de uso atingido.';
1136
- if (couponUseLimits.limitedPerUser) {
1137
- const ordersWithUser = this.countOrdersWithUser(ordersCoupon, checkout.user.email);
1138
- if (ordersWithUser > 0)
1139
- throw 'Limite de uso por usuário atingido.';
1140
- }
1141
- }
1142
- const hasProductCategories = await this.hasProductCategories(coupon, checkout);
1143
- if (!hasProductCategories)
1144
- throw 'Seu carrinho não possui produtos elegíveis para desconto.';
1145
- const hasMinSubTotal = await this.hasMinSubTotal(coupon, checkout);
1146
- if (!hasMinSubTotal) {
1147
- if (coupon.productsCategories?.length) {
1148
- throw `Valor mínimo de ${Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' }).format(coupon.minSubTotalValue)} não atingido na(s) categoria(s) elegíveis para o desconto.`;
1149
- }
1150
- throw `Valor mínimo de ${Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' }).format(coupon.minSubTotalValue)} não atingido.`;
1151
- }
1152
- return coupon;
1153
- }
1154
- calcDiscountSubscription(coupon, checkout) {
1155
- let discount = 0;
1156
- if (coupon.discount.subscription.type == CouponTypes.ABSOLUTE)
1157
- discount = coupon.discount.subscription.value;
1158
- else
1159
- discount = checkout.subscriptionPlan.recurrencePrice * (coupon.discount.subscription.value / 100);
1160
- return of(discount);
1161
- }
1162
- async calcDiscountShopping(coupon, checkout) {
1163
- let discountInfo = null;
1164
- if (checkout.user.isSubscriber && coupon.discount.subscriber.value) {
1165
- discountInfo = await this.calcDiscountByType(coupon.discount.subscriber.type, coupon.discount.subscriber.value, coupon.productsCategories, checkout);
1166
- }
1167
- else {
1168
- discountInfo = await this.calcDiscountByType(coupon.discount.non_subscriber.type, coupon.discount.non_subscriber.value, coupon.productsCategories, checkout);
1169
- }
1170
- return { discount: discountInfo.discount, lineItems: discountInfo.lineItems };
1171
- }
1172
- async calcDiscountByType(type, value, categories, checkout) {
1173
- let discount = 0;
1174
- if (type == CouponTypes.SHIPPING) {
1175
- const subTotal = checkout.shipping.ShippingPrice;
1176
- const discount = +(subTotal * ((value > 100 ? 100 : value) / 100)).toFixed(2);
1177
- return { discount, lineItems: checkout.lineItems };
1178
- }
1179
- const lineItensElegibleForDiscount = await this.getLineItensEligebleForDiscount(categories, checkout);
1180
- const subTotal = this.calcCheckoutSubtotal(lineItensElegibleForDiscount, checkout.user);
1181
- if (type == CouponTypes.ABSOLUTE) {
1182
- discount = value > subTotal ? subTotal : value;
1183
- }
1184
- else {
1185
- discount = +(subTotal * ((value > 100 ? 100 : value) / 100)).toFixed(2);
1186
- }
1187
- const lineItems = this.calcLineItenDiscount(type, lineItensElegibleForDiscount, value, subTotal);
1188
- return { discount, lineItems };
1189
- }
1190
- async hasMinSubTotal(coupon, checkout) {
1191
- if (!coupon.minSubTotalValue)
1192
- return true;
1193
- const lineItensDiscount = await this.getLineItensEligebleForDiscount(coupon.productsCategories, checkout);
1194
- const subTotal = this.calcCheckoutSubtotal(lineItensDiscount, checkout.user);
1195
- if (coupon.minSubTotalValue <= subTotal)
1196
- return true;
1197
- return false;
1198
- }
1199
- async hasProductCategories(coupon, checkout) {
1200
- if (!coupon.productsCategories || !coupon.productsCategories?.length) {
1201
- return true;
1202
- }
1203
- const couponCategories = await this.getCouponCategoriesId(coupon.productsCategories);
1204
- const hasCategories = checkout.lineItems?.filter((item) => {
1205
- if (item.isGift)
1206
- return false;
1207
- if (!item.categories || !item.categories?.length)
1208
- return true;
1209
- return item.categories.some((c) => couponCategories.some((cat) => cat == c));
1210
- });
1211
- return hasCategories.length ? true : false;
1212
- }
1213
- coupomUserValidation(coupon, user) {
1214
- if (!user || coupon.exclusivityType.includes(Exclusivities.ALL_USERS))
1215
- return true;
1216
- let userTypes = [];
1217
- if (coupon.exclusivityType.includes(Exclusivities.COLLABORATORS) &&
1218
- this.emailIsFromCollaborator(user.email.toLocaleLowerCase()))
1219
- userTypes.push(Exclusivities.COLLABORATORS);
1220
- if (coupon.exclusivityType.includes(Exclusivities.SPECIFIC_USER) &&
1221
- coupon.userExclusiveEmail.includes(user.email.toLocaleLowerCase()))
1222
- userTypes.push(Exclusivities.SPECIFIC_USER);
1223
- if (coupon.exclusivityType.includes(Exclusivities.ACTIVE_SUBSCRIBER) &&
1224
- user.isSubscriber &&
1225
- user.subscriptionPlan != '')
1226
- userTypes.push(Exclusivities.ACTIVE_SUBSCRIBER);
1227
- if (user.isSubscriber &&
1228
- user.subscriptionPlan == '' &&
1229
- coupon.exclusivityType.includes(Exclusivities.INACTIVE_SUBSCRIBER))
1230
- userTypes.push(Exclusivities.INACTIVE_SUBSCRIBER);
1231
- if (coupon.exclusivityType.includes(Exclusivities.NON_SUBSCRIBER) && !user.isSubscriber)
1232
- userTypes.push(Exclusivities.NON_SUBSCRIBER);
1233
- return coupon.exclusivityType.some((r) => userTypes.includes(r));
1234
- }
1235
- async getCouponCategoriesId(productsCategories) {
1236
- const couponCategories = [];
1237
- for (let index = 0; index < productsCategories.length; index++) {
1238
- const category = await this.categoryRepository.get({
1239
- id: productsCategories[index],
1240
- });
1241
- if (category) {
1242
- const children = await this.categoryRepository.getChildren(parseInt(productsCategories[index]));
1243
- couponCategories.push(category.id, ...children.map((c) => c.id.toString()));
1244
- }
1245
- }
1246
- return [...new Set(couponCategories)];
1247
- }
1248
- async getLineItensEligebleForDiscount(productsCategories, checkout) {
1249
- let lineItensDiscount = [];
1250
- const couponCategories = await this.getCouponCategoriesId(productsCategories);
1251
- if (productsCategories && productsCategories.length) {
1252
- lineItensDiscount = checkout.lineItems?.filter((item) => {
1253
- if (item.isGift)
1254
- return false;
1255
- if (item.categories?.length) {
1256
- return item.categories.some((c) => couponCategories.some((cat) => cat == c));
1257
- }
1258
- return true;
1259
- });
1260
- }
1261
- else {
1262
- lineItensDiscount = checkout.lineItems.filter((item) => !item.isGift);
1263
- }
1264
- return lineItensDiscount;
1265
- }
1266
- calcCheckoutSubtotal(lineItens, user) {
1267
- return (lineItens
1268
- ?.filter((item) => !item.isGift)
1269
- .reduce((acc, curr) => user?.isSubscriber && curr.price.subscriberPrice
1270
- ? acc + curr.price?.subscriberPrice * curr.quantity
1271
- : acc + curr.pricePaid * curr.quantity, 0) || 0);
1272
- }
1273
- async getOrdersWithCoupon(coupon) {
1274
- return await this.orderRepository
1275
- .find({
1276
- filters: {
1277
- coupon: { id: coupon.id },
1278
- status: { operator: Where.NOTEQUALS, value: OrderStatus.CANCELADO },
1279
- },
1280
- })
1281
- .then((result) => result.data);
1282
- }
1283
- async getOrdersFromUser(email) {
1284
- return await this.orderRepository
1285
- .find({
1286
- filters: {
1287
- user: { email: { operator: Where.EQUALS, value: email } },
1288
- status: { operator: Where.NOTEQUALS, value: OrderStatus.CANCELADO },
1289
- },
1290
- })
1291
- .then((result) => result.data);
1292
- }
1293
- countOrdersWithUser(orders, email) {
1294
- return orders.filter((o) => o.user.email == email).length;
1295
- }
1296
- getCouponUseLimits(coupon, checkoutType, user) {
1297
- let couponUseLimits;
1298
- if (checkoutType == CheckoutTypes.ECOMMERCE || checkoutType == CheckoutTypes.ALL) {
1299
- if (coupon.exclusivityType.length === 1 &&
1300
- (coupon.exclusivityType.at(0) === Exclusivities.SPECIFIC_USER ||
1301
- coupon.exclusivityType.at(0) === Exclusivities.COLLABORATORS))
1302
- couponUseLimits = coupon.useLimits.non_subscriber;
1303
- else
1304
- couponUseLimits = user && user.isSubscriber ? coupon.useLimits.subscriber : coupon.useLimits.non_subscriber;
1305
- }
1306
- else {
1307
- couponUseLimits = coupon.useLimits.subscription;
1308
- }
1309
- return couponUseLimits;
1310
- }
1311
- calcLineItenDiscount(type, lineItems, couponDiscount, subTotal) {
1312
- let lineItemsDiscount = [];
1313
- if (type === CouponTypes.ABSOLUTE) {
1314
- const couponDiscountMax = couponDiscount > subTotal ? subTotal : couponDiscount;
1315
- lineItemsDiscount = lineItems.map((item) => {
1316
- if (item.isGift)
1317
- return item;
1318
- const totalItemPercentage = item.pricePaid / subTotal;
1319
- const discountItem = couponDiscountMax * totalItemPercentage;
1320
- return {
1321
- ...item,
1322
- discount: Number(discountItem.toFixed(2)),
1323
- };
1324
- });
1325
- }
1326
- else {
1327
- lineItemsDiscount = lineItems.map((item) => {
1328
- if (item.isGift)
1329
- return item;
1330
- const discountItem = item.pricePaid * (couponDiscount / 100);
1331
- return {
1332
- ...item,
1333
- discount: Number(discountItem.toFixed(2)),
1334
- };
1335
- });
1336
- }
1337
- return lineItemsDiscount;
1338
- }
1339
- }
1340
- CouponService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CouponService, deps: [{ token: 'CouponRepository' }, { token: DEFAULT_SHOP }, { token: 'OrderRepository' }, { token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
1341
- CouponService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CouponService, providedIn: 'root' });
1342
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CouponService, decorators: [{
1343
- type: Injectable,
1344
- args: [{
1345
- providedIn: 'root',
1346
- }]
1347
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1348
- type: Inject,
1349
- args: ['CouponRepository']
1350
- }] }, { type: i1$2.Shops, decorators: [{
1351
- type: Inject,
1352
- args: [DEFAULT_SHOP]
1353
- }] }, { type: undefined, decorators: [{
1354
- type: Inject,
1355
- args: ['OrderRepository']
1356
- }] }, { type: undefined, decorators: [{
1357
- type: Inject,
1358
- args: ['CategoryRepository']
1359
- }] }]; } });
1360
-
1361
1084
  class CheckoutService {
1362
- constructor(couponService, checkoutRepository, userRepository, defaultShop, dataPersistence) {
1363
- this.couponService = couponService;
1085
+ constructor(checkoutRepository, userRepository, defaultShop, dataPersistence, firebaseOptions, http) {
1364
1086
  this.checkoutRepository = checkoutRepository;
1365
1087
  this.userRepository = userRepository;
1366
1088
  this.defaultShop = defaultShop;
1367
1089
  this.dataPersistence = dataPersistence;
1090
+ this.firebaseOptions = firebaseOptions;
1091
+ this.http = http;
1092
+ this.checkoutUrl = null;
1093
+ this.checkoutUrl = `https://southamerica-east1-${this.firebaseOptions.projectId}.cloudfunctions.net`;
1094
+ // this.checkoutUrl = `http://docker.for.localhost:5001/b4astage-cb80a/southamerica-east1`
1368
1095
  }
1369
1096
  getCheckout(checkoutData) {
1370
1097
  return this.dataPersistence
@@ -1383,11 +1110,44 @@ class CheckoutService {
1383
1110
  clearCheckoutFromSession() {
1384
1111
  return this.dataPersistence.remove('checkoutId');
1385
1112
  }
1386
- calcDiscount(coupon) {
1387
- return this.getCheckout().pipe(concatMap(async (checkout) => await this.couponService.calcDiscountShopping(coupon, checkout)));
1388
- }
1389
1113
  checkCoupon(nickname, checkoutType) {
1390
- return this.getCheckout().pipe(concatMap((checkout) => this.couponService.checkCoupon(nickname, CheckoutTypes.ECOMMERCE, checkout, null).pipe()));
1114
+ return this.getCheckout().pipe(concatMap((checkout) => this.http.post(`${this.checkoutUrl}/checkoutApplyDiscount`, {
1115
+ checkoutId: checkout.id,
1116
+ coupon: nickname,
1117
+ checkoutType,
1118
+ })), concatMap(() => this.getCheckout()), map((checkout) => checkout.coupon));
1119
+ }
1120
+ validateStockProducts() {
1121
+ return this.getCheckout().pipe(concatMap((checkout) => this.http.post(`${this.checkoutUrl}/checkoutValidateProductStock`, {
1122
+ checkoutId: checkout.id,
1123
+ })));
1124
+ }
1125
+ getAvailableShippingForProduct(productShipping) {
1126
+ return this.http.post(`${this.checkoutUrl}/checkoutGetAvailableShipping`, {
1127
+ checkoutId: null,
1128
+ productShipping,
1129
+ });
1130
+ }
1131
+ getAvailableShippingForCheckout() {
1132
+ return this.getCheckout().pipe(concatMap((checkout) => this.http.post(`${this.checkoutUrl}/checkoutGetAvailableShipping`, {
1133
+ checkoutId: checkout.id,
1134
+ productShipping: null,
1135
+ })));
1136
+ }
1137
+ selectShipping(option) {
1138
+ return this.getCheckout().pipe(concatMap((checkout) => this.http.post(`${this.checkoutUrl}/checkoutSelectShipping`, {
1139
+ checkoutId: checkout.id,
1140
+ shippingOption: option,
1141
+ })), concatMap(() => this.getCheckout()));
1142
+ }
1143
+ createOrder(checkoutPayload, paymentProvider, applicationVersion) {
1144
+ return this.http.post(`${this.checkoutUrl}/checkout`, {
1145
+ data: {
1146
+ ...checkoutPayload,
1147
+ applicationVersion,
1148
+ paymentProvider,
1149
+ },
1150
+ });
1391
1151
  }
1392
1152
  async createCheckout(checkoutData) {
1393
1153
  const checkout = await this.checkoutRepository.create({
@@ -1399,52 +1159,60 @@ class CheckoutService {
1399
1159
  return checkout;
1400
1160
  }
1401
1161
  }
1402
- CheckoutService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutService, deps: [{ token: CouponService }, { token: 'CheckoutRepository' }, { token: 'UserRepository' }, { token: DEFAULT_SHOP }, { token: PERSISTENCE_PROVIDER }], target: i0.ɵɵFactoryTarget.Injectable });
1162
+ CheckoutService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutService, deps: [{ token: 'CheckoutRepository' }, { token: 'UserRepository' }, { token: DEFAULT_SHOP }, { token: PERSISTENCE_PROVIDER }, { token: FIREBASE_OPTIONS }, { token: i1$2.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
1403
1163
  CheckoutService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutService });
1404
1164
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutService, decorators: [{
1405
1165
  type: Injectable
1406
- }], ctorParameters: function () { return [{ type: CouponService }, { type: undefined, decorators: [{
1166
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1407
1167
  type: Inject,
1408
1168
  args: ['CheckoutRepository']
1409
1169
  }] }, { type: undefined, decorators: [{
1410
1170
  type: Inject,
1411
1171
  args: ['UserRepository']
1412
- }] }, { type: i1$2.Shops, decorators: [{
1172
+ }] }, { type: i1$3.Shops, decorators: [{
1413
1173
  type: Inject,
1414
1174
  args: [DEFAULT_SHOP]
1415
1175
  }] }, { type: undefined, decorators: [{
1416
1176
  type: Inject,
1417
1177
  args: [PERSISTENCE_PROVIDER]
1418
- }] }]; } });
1178
+ }] }, { type: undefined, decorators: [{
1179
+ type: Inject,
1180
+ args: [FIREBASE_OPTIONS]
1181
+ }] }, { type: i1$2.HttpClient }]; } });
1419
1182
 
1420
1183
  class CartService {
1421
- constructor(authService, checkoutService, defaultShop, firebaseOptions, productRepository, categoryRepository, variantRepository, buy2WinRepository, http) {
1184
+ constructor(authService, checkoutService, defaultShop, firebaseOptions,
1185
+ // @Inject('ProductRepository') private readonly productRepository: ProductRepository,
1186
+ // @Inject('CategoryRepository') private readonly categoryRepository: CategoryRepository,
1187
+ // @Inject('VariantRepository') private readonly variantRepository: VariantRepository,
1188
+ // @Inject('Buy2WinRepository') private readonly buy2WinRepository: Buy2WinFirestoreRepository,
1189
+ http) {
1422
1190
  this.authService = authService;
1423
1191
  this.checkoutService = checkoutService;
1424
1192
  this.defaultShop = defaultShop;
1425
1193
  this.firebaseOptions = firebaseOptions;
1426
- this.productRepository = productRepository;
1427
- this.categoryRepository = categoryRepository;
1428
- this.variantRepository = variantRepository;
1429
- this.buy2WinRepository = buy2WinRepository;
1430
1194
  this.http = http;
1431
1195
  this.cartSubject = new Subject();
1432
1196
  this.checkoutUrl = null;
1433
- this.updateLineItemInCart = (lineItem, quantity, checkout) => (isNil(checkout) ? this.checkoutService.getCheckout() : of(checkout)).pipe(concatMap((checkoutLoaded) => {
1434
- const items = [];
1435
- const index = checkoutLoaded.lineItems?.map((checkoutItem) => checkoutItem.id).indexOf(lineItem.id);
1436
- const isGift = checkoutLoaded.lineItems?.[index]?.isGift;
1437
- if (index > -1) {
1438
- checkoutLoaded.lineItems[index].quantity += quantity;
1439
- checkoutLoaded.lineItems[index].pricePaid = isGift ? 0 : lineItem.pricePaid;
1440
- checkoutLoaded.lineItems[index].price = lineItem.price;
1441
- }
1442
- else
1443
- checkoutLoaded.lineItems = items.concat(checkoutLoaded.lineItems ? checkoutLoaded.lineItems.concat([lineItem]) : [lineItem]);
1444
- return this.checkoutService
1445
- .updateCheckoutLineItems(checkoutLoaded)
1446
- .pipe(map((updatedCheckout) => this.generateCartObject(updatedCheckout.lineItems)));
1447
- }));
1197
+ // private updateLineItemInCart = (lineItem: LineItem, quantity: number, checkout?: Checkout): Observable<Cart> =>
1198
+ // (isNil(checkout) ? this.checkoutService.getCheckout() : of(checkout)).pipe(
1199
+ // concatMap((checkoutLoaded) => {
1200
+ // const items: LineItem[] = []
1201
+ // const index = checkoutLoaded.lineItems?.map((checkoutItem) => checkoutItem.id).indexOf(lineItem.id)
1202
+ // const isGift = checkoutLoaded.lineItems?.[index]?.isGift
1203
+ // if (index > -1) {
1204
+ // checkoutLoaded.lineItems[index].quantity += quantity
1205
+ // checkoutLoaded.lineItems[index].pricePaid = isGift ? 0 : lineItem.pricePaid
1206
+ // checkoutLoaded.lineItems[index].price = lineItem.price
1207
+ // } else
1208
+ // checkoutLoaded.lineItems = items.concat(
1209
+ // checkoutLoaded.lineItems ? checkoutLoaded.lineItems.concat([lineItem]) : [lineItem],
1210
+ // )
1211
+ // return this.checkoutService
1212
+ // .updateCheckoutLineItems(checkoutLoaded)
1213
+ // .pipe(map((updatedCheckout) => this.generateCartObject(updatedCheckout.lineItems)))
1214
+ // }),
1215
+ // )
1448
1216
  this.generateCartObject = (items) => items?.reduce((cart, item) => ({
1449
1217
  ...cart,
1450
1218
  [item.id]: LineItem.toInstance({
@@ -1452,69 +1220,21 @@ class CartService {
1452
1220
  quantity: (cart[item.id]?.quantity || 0) + (item.quantity ? item.quantity : 1),
1453
1221
  }),
1454
1222
  }), {}) || {};
1455
- this.buildLineItem = async ({ checkout, item, quantity, }) => {
1456
- const product = await this.getProductData(item.id);
1457
- item.quantity = item?.quantity || checkout?.lineItems?.find((lineItem) => lineItem.id === item.id)?.quantity || 0;
1458
- if (this.checkMaxStock(product.stock.quantity, item.quantity || 0, quantity || 0))
1459
- throw new Error('Desculpe! Temos apenas ' + product.stock?.quantity + ' em estoque.');
1460
- const image = item.image || item.images?.shift();
1461
- const { id, name, EAN, slug, weight, sku, type } = item;
1462
- const isGift = item?.isGift || null;
1463
- const pricePaid = isGift
1464
- ? 0
1465
- : this.getProductPrice({
1466
- product: LineItem.toInstance(product),
1467
- shop: checkout.shop || this.defaultShop,
1468
- isSubscriber: checkout.user?.isSubscriber,
1469
- });
1470
- RoundProductPricesHelper.roundProductPrices(item);
1471
- RoundProductPricesHelper.roundProductPrices(product);
1472
- return {
1473
- checkout,
1474
- lineItem: LineItem.toInstance({
1475
- id,
1476
- name: name ?? product.name,
1477
- EAN: EAN ?? product.EAN,
1478
- brand: product.brand,
1479
- slug: slug ?? product.slug,
1480
- sku: sku ?? product.sku,
1481
- stock: product.stock,
1482
- price: this.roundPrice(product.price),
1483
- image,
1484
- weight: weight ?? product.weight,
1485
- quantity: (item.quantity || 0) + (quantity || 0),
1486
- pricePaid,
1487
- discount: 0,
1488
- categories: product.categories || product.category?.id ? [product.category?.id, ...product.categories] : [],
1489
- category: product.category,
1490
- isGift: isGift ?? null,
1491
- costPrice: isGift ? 0 : product.costPrice ?? 0,
1492
- type,
1493
- label: product.label,
1494
- }),
1495
- };
1496
- };
1497
- this.getProductPrice = ({ product, isSubscriber, }) => {
1498
- const info = product.price;
1499
- if (product.isGift)
1500
- return 0;
1501
- return isSubscriber && info.subscriberPrice > 0
1502
- ? Number(info.subscriberPrice.toFixed(2))
1503
- : Number(info.price.toFixed(2));
1504
- };
1505
- this.checkMaxStock = (currentStock, currentItemQtd, quantityToAdd) => {
1506
- const maxStock = currentStock || 0;
1507
- const currentItemAmount = currentItemQtd || 0;
1508
- return currentItemAmount + quantityToAdd > maxStock;
1509
- };
1510
1223
  this.checkoutUrl = `https://southamerica-east1-${this.firebaseOptions.projectId}.cloudfunctions.net`;
1511
- }
1512
- async addItem(item, quantity = 1) {
1513
- return this.checkoutService.getCheckout().pipe(tap((checkout) => this.http.post(`${this.checkoutUrl}/checkoutAddItemToCart`, {
1514
- checkoutId: checkout.id,
1515
- productId: item.id,
1516
- quantity,
1517
- })), tap(() => this.checkoutService.getCheckout()), map((updatedCheckout) => this.generateCartObject(updatedCheckout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
1224
+ // this.checkoutUrl = `http://docker.for.localhost:5001/b4astage-cb80a/southamerica-east1`
1225
+ }
1226
+ addItem(item, quantity = 1) {
1227
+ return this.checkoutService.getCheckout().pipe(concatMap((checkout) => {
1228
+ console.log('getCheckout', checkout);
1229
+ return this.http.post(`${this.checkoutUrl}/checkoutAddItemToCart`, {
1230
+ checkoutId: checkout.id,
1231
+ productId: item.id,
1232
+ quantity,
1233
+ });
1234
+ }), concatMap(() => this.checkoutService.getCheckout()), map((updatedCheckout) => {
1235
+ console.log('updatedCheckout', updatedCheckout);
1236
+ return this.generateCartObject(updatedCheckout.lineItems);
1237
+ }), tap((cart) => this.cartSubject.next(cart)));
1518
1238
  // return this.generateCartObject(checkoutUpdated.lineItems as LineItem[])
1519
1239
  // return from(this.checkoutService.getCheckout()).pipe(
1520
1240
  // concatMap(async (checkout) => await this.buildLineItem({ checkout, item, quantity: quantity || 1 })),
@@ -1522,12 +1242,15 @@ class CartService {
1522
1242
  // tap((cart) => this.cartSubject.next(cart)),
1523
1243
  // )
1524
1244
  }
1525
- async decreaseItem(item) {
1526
- return this.checkoutService.getCheckout().pipe(tap((checkout) => this.http.post(`${this.checkoutUrl}/checkoutDecreaseProductFromCart`, {
1245
+ decreaseItem(item) {
1246
+ return this.checkoutService.getCheckout().pipe(concatMap((checkout) => this.http.post(`${this.checkoutUrl}/checkoutDecreaseProductFromCart`, {
1527
1247
  checkoutId: checkout.id,
1528
1248
  productId: item.id,
1529
1249
  quantity: 1,
1530
- })), tap(() => this.checkoutService.getCheckout()), map((updatedCheckout) => this.generateCartObject(updatedCheckout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
1250
+ })), concatMap(() => this.checkoutService.getCheckout()), map((updatedCheckout) => {
1251
+ console.log('updatedCheckout', updatedCheckout);
1252
+ return this.generateCartObject(updatedCheckout.lineItems);
1253
+ }), tap((cart) => this.cartSubject.next(cart)));
1531
1254
  // return this.checkoutService.getCheckout().pipe(
1532
1255
  // map((checkout) => {
1533
1256
  // const checkoutItem = checkout.lineItems?.find((lineItem) => lineItem.id === item.id)
@@ -1540,10 +1263,13 @@ class CartService {
1540
1263
  // )
1541
1264
  }
1542
1265
  removeItem(item) {
1543
- return this.checkoutService.getCheckout().pipe(tap((checkout) => this.http.post(`${this.checkoutUrl}/checkoutRemoveProductFromCart`, {
1266
+ return this.checkoutService.getCheckout().pipe(concatMap((checkout) => this.http.post(`${this.checkoutUrl}/checkoutRemoveProductFromCart`, {
1544
1267
  checkoutId: checkout.id,
1545
1268
  productId: item.id,
1546
- })), tap(() => this.checkoutService.getCheckout()), map((updatedCheckout) => this.generateCartObject(updatedCheckout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
1269
+ })), concatMap(() => this.checkoutService.getCheckout()), map((updatedCheckout) => {
1270
+ console.log('updatedCheckout', updatedCheckout);
1271
+ return this.generateCartObject(updatedCheckout.lineItems);
1272
+ }), tap((cart) => this.cartSubject.next(cart)));
1547
1273
  // return this.checkoutService.getCheckout().pipe(
1548
1274
  // map((checkout) => {
1549
1275
  // const index = checkout.lineItems.findIndex((lineItem) => lineItem.id === item.id)
@@ -1555,9 +1281,18 @@ class CartService {
1555
1281
  // tap((cart) => this.cartSubject.next(cart)),
1556
1282
  }
1557
1283
  updateUserCart(user) {
1558
- return this.checkoutService.getCheckout().pipe(concatMap((checkout) => this.checkoutService.updateCheckoutUser(Checkout.toInstance({ ...checkout.toPlain(), user }))), tap(() => (this.user = user)), tap((checkout) => this.http.post(`${this.checkoutUrl}/checkoutUpdateUserCart`, {
1559
- checkoutId: checkout.id,
1560
- })), tap(() => this.checkoutService.getCheckout()), map((updatedCheckout) => this.generateCartObject(updatedCheckout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
1284
+ return this.checkoutService.getCheckout().pipe(concatMap((checkout) => {
1285
+ console.log('getCheckout', checkout);
1286
+ return this.checkoutService.updateCheckoutUser(Checkout.toInstance({ ...checkout.toPlain(), user }));
1287
+ }), concatMap((checkout) => {
1288
+ console.log('getCheckout User', checkout);
1289
+ return this.http.post(`${this.checkoutUrl}/checkoutUpdateUserCart`, {
1290
+ checkoutId: checkout.id,
1291
+ });
1292
+ }), concatMap(() => this.checkoutService.getCheckout()), map((updatedCheckout) => {
1293
+ console.log('updatedCheckout', updatedCheckout);
1294
+ return this.generateCartObject(updatedCheckout.lineItems);
1295
+ }), tap((cart) => this.cartSubject.next(cart)));
1561
1296
  // return this.checkoutService.getCheckout().pipe(
1562
1297
  // concatMap((checkout) =>
1563
1298
  // this.checkoutService.updateCheckoutUser(Checkout.toInstance({ ...checkout.toPlain(), user })),
@@ -1586,12 +1321,21 @@ class CartService {
1586
1321
  this.buildCartFromCheckout(checkout).subscribe((cart) => this.cartSubject.next(cart));
1587
1322
  return this.cartSubject;
1588
1323
  }
1589
- /**
1590
- * @deprecated The method should not be used
1591
- */
1592
- getVariantPriceDiscount(item) {
1593
- return this.authService.getUser().pipe(concatMap((user) => iif(() => user.isSubscriber && !!item.price.subscriberPrice, of(item.price.subscriberPrice), of(item.price.price))), catchError(() => of(item.price.price)));
1594
- }
1324
+ // /**
1325
+ // * @deprecated The method should not be used
1326
+ // */
1327
+ // getVariantPriceDiscount(item: LineItem): Observable<number> {
1328
+ // return this.authService.getUser().pipe(
1329
+ // concatMap((user) =>
1330
+ // iif(
1331
+ // () => user.isSubscriber && !!item.price.subscriberPrice,
1332
+ // of(item.price.subscriberPrice),
1333
+ // of(item.price.price),
1334
+ // ),
1335
+ // ),
1336
+ // catchError(() => of(item.price.price)),
1337
+ // )
1338
+ // }
1595
1339
  clearCart() {
1596
1340
  return this.checkoutService.getCheckout().pipe(map((checkout) => {
1597
1341
  this.checkoutService.clearCheckoutFromSession();
@@ -1599,156 +1343,20 @@ class CartService {
1599
1343
  }), concatMap((oldCheckout) => this.buildCartFromCheckout(oldCheckout)), tap((cart) => this.cartSubject.next(cart)));
1600
1344
  }
1601
1345
  buildCartFromCheckout(checkoutData) {
1602
- return this.checkoutService.getCheckout(checkoutData).pipe(map((checkout) => checkout.lineItems), concatMap((lineItems) => of(this.generateCartObject(lineItems))));
1603
- }
1604
- roundPrice(productPrice) {
1605
- const { price, fullPrice, subscriberPrice } = productPrice;
1606
- return {
1607
- ...productPrice,
1608
- price: Number(price.toFixed(2)),
1609
- fullPrice: Number(fullPrice.toFixed(2)),
1610
- ...(subscriberPrice && { subscriberPrice: Number(subscriberPrice.toFixed(2)) }),
1611
- };
1612
- }
1613
- async getProductData(productId) {
1614
- let product;
1615
- let variant;
1616
- try {
1617
- product = await this.productRepository.get({ id: productId });
1618
- }
1619
- catch (error) {
1620
- if (!(error instanceof NotFoundError))
1621
- throw error;
1622
- const { data: variants } = await this.variantRepository.find({ filters: { id: productId } });
1623
- variant = variants.shift();
1624
- if (!variant)
1625
- throw error;
1626
- product = await this.productRepository.get({ id: variant.productId });
1627
- }
1628
- return {
1629
- ...product.toPlain(),
1630
- ...(variant && { ...variant.toPlain() }),
1631
- };
1632
- }
1633
- getGifts() {
1634
- return this.checkoutService.getCheckout().pipe(mergeMap(async (checkout) => {
1635
- const notGiftItems = checkout.lineItems ? checkout.lineItems.filter((item) => !item.isGift) : [];
1636
- if (!notGiftItems.length)
1637
- return { ...checkout, lineItems: [] };
1638
- const campaigns = await this.buy2WinRepository
1639
- .find({
1640
- filters: {
1641
- active: { operator: Where.EQUALS, value: true },
1642
- },
1643
- })
1644
- .then((data) => data.data.filter((campaign) => campaign.shop === Shops.ALL || campaign.shop === this.defaultShop));
1645
- if (!campaigns.length)
1646
- return { ...checkout, lineItems: notGiftItems };
1647
- const elegibleCampaigns = [];
1648
- for (const campaign of campaigns) {
1649
- const today = new Date().getTime();
1650
- if (!(campaign.startDate.getTime() <= today) && !(campaign.endDate.getTime() >= today))
1651
- continue;
1652
- if (campaign.activeCategory) {
1653
- const categoriesCampaing = campaign.categories.map((c) => c.id.toString());
1654
- const categoriesCampaingFullTree = [];
1655
- for (const id of categoriesCampaing) {
1656
- const children = await this.categoryRepository.getChildren(parseInt(id));
1657
- categoriesCampaingFullTree.push(id, ...children.map((c) => c.id.toString()));
1658
- }
1659
- const categoriesCampaingTree = [...new Set(categoriesCampaingFullTree)];
1660
- const filterProductsCategories = notGiftItems.filter((l) => {
1661
- if (!l.categories || !l.categories?.length)
1662
- return true;
1663
- return l.categories.some((c) => categoriesCampaingTree.some((cat) => cat == c));
1664
- });
1665
- if (filterProductsCategories.length) {
1666
- const cartValuelWithCategories = filterProductsCategories.reduce((a, b) => a + b.pricePaid * b.quantity, 0);
1667
- const cartItensQuantityWithCategories = filterProductsCategories.reduce((a, b) => a + b.quantity, 0);
1668
- const hasMinValue = campaign.cartValueMin && cartValuelWithCategories >= campaign.cartValueMin;
1669
- const hasMinQuantity = campaign.cartItensQuantityMin && cartItensQuantityWithCategories >= campaign.cartItensQuantityMin;
1670
- if (hasMinQuantity || hasMinValue)
1671
- elegibleCampaigns.push(campaign);
1672
- }
1673
- }
1674
- else {
1675
- const cartTotal = notGiftItems.reduce((a, b) => a + b.pricePaid * b.quantity, 0);
1676
- const cartItensQuantity = notGiftItems.reduce((a, b) => a + b.quantity, 0);
1677
- const hasMinValue = campaign.cartValue && campaign.cartValue > 0 && campaign.cartValue <= cartTotal;
1678
- const hasMinQuantity = campaign.cartItensQuantityMin && cartItensQuantity >= campaign.cartItensQuantityMin;
1679
- if (hasMinQuantity || hasMinValue)
1680
- elegibleCampaigns.push(campaign);
1681
- }
1682
- }
1683
- if (!elegibleCampaigns.length)
1684
- return { ...checkout, lineItems: notGiftItems };
1685
- const campaingnProducts = [];
1686
- for (const campaign of elegibleCampaigns) {
1687
- let elegibleProducts = [];
1688
- for (const product of campaign.products) {
1689
- const { data: productData } = await this.productRepository.find({ filters: { sku: product } });
1690
- if (!productData.length)
1691
- continue;
1692
- const gift = productData.shift();
1693
- if (gift.stock.quantity < 1)
1694
- continue;
1695
- elegibleProducts.push(gift);
1696
- }
1697
- campaingnProducts.push(elegibleProducts);
1698
- }
1699
- if (!campaingnProducts.length)
1700
- return { ...checkout, lineItems: notGiftItems };
1701
- const gifts = this.giftToLineItems([].concat(...campaingnProducts));
1702
- return { ...checkout, lineItems: notGiftItems.concat(gifts) };
1703
- }), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
1704
- }
1705
- giftToLineItems(items) {
1706
- return items.map((item) => {
1707
- const { brand, categories, category, id, name, price, sku, slug, stock, weight, EAN } = item;
1708
- const image = item?.miniatures?.length ? item.miniatures[0] : item.images[0];
1709
- return LineItem.toInstance({
1710
- brand,
1711
- categories,
1712
- category,
1713
- id: id.toString(),
1714
- name,
1715
- price,
1716
- sku,
1717
- slug,
1718
- stock,
1719
- weight,
1720
- EAN,
1721
- image,
1722
- pricePaid: 0,
1723
- quantity: 1,
1724
- isGift: true,
1725
- });
1726
- });
1346
+ return this.checkoutService.getCheckout(checkoutData).pipe(map((checkout) => checkout.lineItems), concatMap((lineItems) => of(this.generateCartObject(lineItems))));
1727
1347
  }
1728
1348
  }
1729
- CartService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService, deps: [{ token: AuthService }, { token: CheckoutService }, { token: DEFAULT_SHOP }, { token: FIREBASE_OPTIONS }, { token: 'ProductRepository' }, { token: 'CategoryRepository' }, { token: 'VariantRepository' }, { token: 'Buy2WinRepository' }, { token: i3.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
1349
+ CartService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService, deps: [{ token: AuthService }, { token: CheckoutService }, { token: DEFAULT_SHOP }, { token: FIREBASE_OPTIONS }, { token: i1$2.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
1730
1350
  CartService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService });
1731
1351
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService, decorators: [{
1732
1352
  type: Injectable
1733
- }], ctorParameters: function () { return [{ type: AuthService }, { type: CheckoutService }, { type: i1$2.Shops, decorators: [{
1353
+ }], ctorParameters: function () { return [{ type: AuthService }, { type: CheckoutService }, { type: i1$3.Shops, decorators: [{
1734
1354
  type: Inject,
1735
1355
  args: [DEFAULT_SHOP]
1736
1356
  }] }, { type: undefined, decorators: [{
1737
1357
  type: Inject,
1738
1358
  args: [FIREBASE_OPTIONS]
1739
- }] }, { type: undefined, decorators: [{
1740
- type: Inject,
1741
- args: ['ProductRepository']
1742
- }] }, { type: undefined, decorators: [{
1743
- type: Inject,
1744
- args: ['CategoryRepository']
1745
- }] }, { type: undefined, decorators: [{
1746
- type: Inject,
1747
- args: ['VariantRepository']
1748
- }] }, { type: i1$2.Buy2WinFirestoreRepository, decorators: [{
1749
- type: Inject,
1750
- args: ['Buy2WinRepository']
1751
- }] }, { type: i3.HttpClient }]; } });
1359
+ }] }, { type: i1$2.HttpClient }]; } });
1752
1360
 
1753
1361
  class NewCategoryStructureAdapter {
1754
1362
  constructor(categoryRepository) {
@@ -2092,7 +1700,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
2092
1700
  }] }, { type: undefined, decorators: [{
2093
1701
  type: Inject,
2094
1702
  args: [CATEGORY_STRUCTURE]
2095
- }] }, { type: i1$2.Shops, decorators: [{
1703
+ }] }, { type: i1$3.Shops, decorators: [{
2096
1704
  type: Inject,
2097
1705
  args: [DEFAULT_SHOP]
2098
1706
  }] }, { type: undefined, decorators: [{
@@ -2141,7 +1749,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
2141
1749
  }] }, { type: undefined, decorators: [{
2142
1750
  type: Inject,
2143
1751
  args: [CATEGORY_STRUCTURE]
2144
- }] }, { type: i1$2.Shops, decorators: [{
1752
+ }] }, { type: i1$3.Shops, decorators: [{
2145
1753
  type: Inject,
2146
1754
  args: [DEFAULT_SHOP]
2147
1755
  }] }]; } });
@@ -2368,7 +1976,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
2368
1976
  }], ctorParameters: function () { return [{ type: undefined, decorators: [{
2369
1977
  type: Inject,
2370
1978
  args: ['WishlistRepository']
2371
- }] }, { type: i1$2.Shops, decorators: [{
1979
+ }] }, { type: i1$3.Shops, decorators: [{
2372
1980
  type: Inject,
2373
1981
  args: [DEFAULT_SHOP]
2374
1982
  }] }, { type: undefined, decorators: [{
@@ -2391,6 +1999,271 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
2391
1999
  args: ['LogRepository']
2392
2000
  }] }]; } });
2393
2001
 
2002
+ class CouponService {
2003
+ constructor(couponRepository, defaultShop, orderRepository, categoryRepository) {
2004
+ this.couponRepository = couponRepository;
2005
+ this.defaultShop = defaultShop;
2006
+ this.orderRepository = orderRepository;
2007
+ this.categoryRepository = categoryRepository;
2008
+ this.emailIsFromCollaborator = (userEmail) => !!userEmail?.match(/@b4a.com.br/g);
2009
+ }
2010
+ checkCoupon(nickname, checkoutType, checkout, plan) {
2011
+ return from(this.couponRepository
2012
+ .find({
2013
+ filters: {
2014
+ nickname: { operator: Where.EQUALS, value: nickname },
2015
+ active: { operator: Where.EQUALS, value: true },
2016
+ },
2017
+ })
2018
+ .then((result) => result.data[0])).pipe(concatMap((coupon) => this.couponValidation(coupon, checkoutType)), concatMap((couponValid) => this.couponRulesValidation(couponValid, checkoutType, checkout, plan)), map((couponValidated) => couponValidated));
2019
+ }
2020
+ async couponValidation(coupon, checkoutType) {
2021
+ if (!coupon)
2022
+ throw 'Cupom inválido.';
2023
+ if (coupon?.beginAt && coupon?.beginAt.getTime() > new Date().getTime())
2024
+ throw 'Cupom inválido.';
2025
+ if (coupon?.expiresIn && coupon?.expiresIn.getTime() < new Date().getTime())
2026
+ throw 'Cupom expirado.';
2027
+ const isInShop = coupon.shopAvailability === Shops.ALL || coupon.shopAvailability === this.defaultShop;
2028
+ if (!isInShop)
2029
+ throw 'Cupom inválido para loja.';
2030
+ const isCheckoutType = coupon.checkoutType === CheckoutTypes.ALL || coupon.checkoutType === checkoutType;
2031
+ if (!isCheckoutType)
2032
+ throw 'Cupom inválido. Erro de checkout.';
2033
+ return coupon;
2034
+ }
2035
+ async couponRulesValidation(coupon, checkoutType, checkout, plan) {
2036
+ if (checkoutType == CheckoutTypes.SUBSCRIPTION) {
2037
+ if (coupon.plan && coupon.plan.toUpperCase() !== plan.toUpperCase())
2038
+ throw 'Cupom inválido para sua assinatura.';
2039
+ return coupon;
2040
+ }
2041
+ const validUser = this.coupomUserValidation(coupon, checkout?.user);
2042
+ if (!validUser)
2043
+ throw 'Usuário não elegível.';
2044
+ const couponUseLimits = this.getCouponUseLimits(coupon, checkoutType, checkout.user);
2045
+ if (couponUseLimits.firstOrder) {
2046
+ const ordersUser = await this.getOrdersFromUser(checkout.user.email.toLocaleLowerCase());
2047
+ if (couponUseLimits.firstOrder && ordersUser.length >= 1)
2048
+ throw 'Limite de uso atingido';
2049
+ }
2050
+ if (!couponUseLimits.unlimited || couponUseLimits.limitedPerUser) {
2051
+ const ordersCoupon = await this.getOrdersWithCoupon(coupon);
2052
+ if (!couponUseLimits.unlimited && couponUseLimits.total && ordersCoupon.length >= couponUseLimits.total)
2053
+ throw 'Limite de uso atingido.';
2054
+ if (couponUseLimits.limitedPerUser) {
2055
+ const ordersWithUser = this.countOrdersWithUser(ordersCoupon, checkout.user.email);
2056
+ if (ordersWithUser > 0)
2057
+ throw 'Limite de uso por usuário atingido.';
2058
+ }
2059
+ }
2060
+ const hasProductCategories = await this.hasProductCategories(coupon, checkout);
2061
+ if (!hasProductCategories)
2062
+ throw 'Seu carrinho não possui produtos elegíveis para desconto.';
2063
+ const hasMinSubTotal = await this.hasMinSubTotal(coupon, checkout);
2064
+ if (!hasMinSubTotal) {
2065
+ if (coupon.productsCategories?.length) {
2066
+ throw `Valor mínimo de ${Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' }).format(coupon.minSubTotalValue)} não atingido na(s) categoria(s) elegíveis para o desconto.`;
2067
+ }
2068
+ throw `Valor mínimo de ${Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' }).format(coupon.minSubTotalValue)} não atingido.`;
2069
+ }
2070
+ return coupon;
2071
+ }
2072
+ calcDiscountSubscription(coupon, checkout) {
2073
+ let discount = 0;
2074
+ if (coupon.discount.subscription.type == CouponTypes.ABSOLUTE)
2075
+ discount = coupon.discount.subscription.value;
2076
+ else
2077
+ discount = checkout.subscriptionPlan.recurrencePrice * (coupon.discount.subscription.value / 100);
2078
+ return of(discount);
2079
+ }
2080
+ // public async calcDiscountShopping(
2081
+ // coupon: Coupon,
2082
+ // checkout: Partial<Checkout>,
2083
+ // ): Promise<{ discount: number; lineItems: LineItem[] }> {
2084
+ // let discountInfo: { discount: number; lineItems: LineItem[] } = null
2085
+ // if (checkout.user.isSubscriber && coupon.discount.subscriber.value) {
2086
+ // discountInfo = await this.calcDiscountByType(
2087
+ // coupon.discount.subscriber.type,
2088
+ // coupon.discount.subscriber.value,
2089
+ // coupon.productsCategories,
2090
+ // checkout,
2091
+ // )
2092
+ // } else {
2093
+ // discountInfo = await this.calcDiscountByType(
2094
+ // coupon.discount.non_subscriber.type,
2095
+ // coupon.discount.non_subscriber.value,
2096
+ // coupon.productsCategories,
2097
+ // checkout,
2098
+ // )
2099
+ // }
2100
+ // return { discount: discountInfo.discount, lineItems: discountInfo.lineItems }
2101
+ // }
2102
+ // private async calcDiscountByType(
2103
+ // type: CouponTypes,
2104
+ // value: number,
2105
+ // categories: string[],
2106
+ // checkout: Partial<Checkout>,
2107
+ // ): Promise<{ discount: number; lineItems: LineItem[] }> {
2108
+ // let discount = 0
2109
+ // if (type == CouponTypes.SHIPPING) {
2110
+ // const subTotal = checkout.shipping.ShippingPrice
2111
+ // const discount = +(subTotal * ((value > 100 ? 100 : value) / 100)).toFixed(2)
2112
+ // return { discount, lineItems: checkout.lineItems }
2113
+ // }
2114
+ // const lineItensElegibleForDiscount = await this.getLineItensEligebleForDiscount(categories, checkout)
2115
+ // const subTotal = this.calcCheckoutSubtotal(lineItensElegibleForDiscount, checkout.user)
2116
+ // if (type == CouponTypes.ABSOLUTE) {
2117
+ // discount = value > subTotal ? subTotal : value
2118
+ // } else {
2119
+ // discount = +(subTotal * ((value > 100 ? 100 : value) / 100)).toFixed(2)
2120
+ // }
2121
+ // const lineItems = this.calcLineItenDiscount(type, lineItensElegibleForDiscount, value, subTotal)
2122
+ // return { discount, lineItems }
2123
+ // }
2124
+ async hasMinSubTotal(coupon, checkout) {
2125
+ if (!coupon.minSubTotalValue)
2126
+ return true;
2127
+ const lineItensDiscount = await this.getLineItensEligebleForDiscount(coupon.productsCategories, checkout);
2128
+ const subTotal = this.calcCheckoutSubtotal(lineItensDiscount, checkout.user);
2129
+ if (coupon.minSubTotalValue <= subTotal)
2130
+ return true;
2131
+ return false;
2132
+ }
2133
+ async hasProductCategories(coupon, checkout) {
2134
+ if (!coupon.productsCategories || !coupon.productsCategories?.length) {
2135
+ return true;
2136
+ }
2137
+ const couponCategories = await this.getCouponCategoriesId(coupon.productsCategories);
2138
+ const hasCategories = checkout.lineItems?.filter((item) => {
2139
+ if (item.isGift)
2140
+ return false;
2141
+ if (!item.categories || !item.categories?.length)
2142
+ return true;
2143
+ return item.categories.some((c) => couponCategories.some((cat) => cat == c));
2144
+ });
2145
+ return hasCategories.length ? true : false;
2146
+ }
2147
+ coupomUserValidation(coupon, user) {
2148
+ if (!user || coupon.exclusivityType.includes(Exclusivities.ALL_USERS))
2149
+ return true;
2150
+ let userTypes = [];
2151
+ if (coupon.exclusivityType.includes(Exclusivities.COLLABORATORS) &&
2152
+ this.emailIsFromCollaborator(user.email.toLocaleLowerCase()))
2153
+ userTypes.push(Exclusivities.COLLABORATORS);
2154
+ if (coupon.exclusivityType.includes(Exclusivities.SPECIFIC_USER) &&
2155
+ coupon.userExclusiveEmail.includes(user.email.toLocaleLowerCase()))
2156
+ userTypes.push(Exclusivities.SPECIFIC_USER);
2157
+ if (coupon.exclusivityType.includes(Exclusivities.ACTIVE_SUBSCRIBER) &&
2158
+ user.isSubscriber &&
2159
+ user.subscriptionPlan != '')
2160
+ userTypes.push(Exclusivities.ACTIVE_SUBSCRIBER);
2161
+ if (user.isSubscriber &&
2162
+ user.subscriptionPlan == '' &&
2163
+ coupon.exclusivityType.includes(Exclusivities.INACTIVE_SUBSCRIBER))
2164
+ userTypes.push(Exclusivities.INACTIVE_SUBSCRIBER);
2165
+ if (coupon.exclusivityType.includes(Exclusivities.NON_SUBSCRIBER) && !user.isSubscriber)
2166
+ userTypes.push(Exclusivities.NON_SUBSCRIBER);
2167
+ return coupon.exclusivityType.some((r) => userTypes.includes(r));
2168
+ }
2169
+ async getCouponCategoriesId(productsCategories) {
2170
+ const couponCategories = [];
2171
+ for (let index = 0; index < productsCategories.length; index++) {
2172
+ const category = await this.categoryRepository.get({
2173
+ id: productsCategories[index],
2174
+ });
2175
+ if (category) {
2176
+ const children = await this.categoryRepository.getChildren(parseInt(productsCategories[index]));
2177
+ couponCategories.push(category.id, ...children.map((c) => c.id.toString()));
2178
+ }
2179
+ }
2180
+ return [...new Set(couponCategories)];
2181
+ }
2182
+ async getLineItensEligebleForDiscount(productsCategories, checkout) {
2183
+ let lineItensDiscount = [];
2184
+ const couponCategories = await this.getCouponCategoriesId(productsCategories);
2185
+ if (productsCategories && productsCategories.length) {
2186
+ lineItensDiscount = checkout.lineItems?.filter((item) => {
2187
+ if (item.isGift)
2188
+ return false;
2189
+ if (item.categories?.length) {
2190
+ return item.categories.some((c) => couponCategories.some((cat) => cat == c));
2191
+ }
2192
+ return true;
2193
+ });
2194
+ }
2195
+ else {
2196
+ lineItensDiscount = checkout.lineItems.filter((item) => !item.isGift);
2197
+ }
2198
+ return lineItensDiscount;
2199
+ }
2200
+ calcCheckoutSubtotal(lineItens, user) {
2201
+ return (lineItens
2202
+ ?.filter((item) => !item.isGift)
2203
+ .reduce((acc, curr) => user?.isSubscriber && curr.price.subscriberPrice
2204
+ ? acc + curr.price?.subscriberPrice * curr.quantity
2205
+ : acc + curr.pricePaid * curr.quantity, 0) || 0);
2206
+ }
2207
+ async getOrdersWithCoupon(coupon) {
2208
+ return await this.orderRepository
2209
+ .find({
2210
+ filters: {
2211
+ coupon: { id: coupon.id },
2212
+ status: { operator: Where.NOTEQUALS, value: OrderStatus.CANCELADO },
2213
+ },
2214
+ })
2215
+ .then((result) => result.data);
2216
+ }
2217
+ async getOrdersFromUser(email) {
2218
+ return await this.orderRepository
2219
+ .find({
2220
+ filters: {
2221
+ user: { email: { operator: Where.EQUALS, value: email } },
2222
+ status: { operator: Where.NOTEQUALS, value: OrderStatus.CANCELADO },
2223
+ },
2224
+ })
2225
+ .then((result) => result.data);
2226
+ }
2227
+ countOrdersWithUser(orders, email) {
2228
+ return orders.filter((o) => o.user.email == email).length;
2229
+ }
2230
+ getCouponUseLimits(coupon, checkoutType, user) {
2231
+ let couponUseLimits;
2232
+ if (checkoutType == CheckoutTypes.ECOMMERCE || checkoutType == CheckoutTypes.ALL) {
2233
+ if (coupon.exclusivityType.length === 1 &&
2234
+ (coupon.exclusivityType.at(0) === Exclusivities.SPECIFIC_USER ||
2235
+ coupon.exclusivityType.at(0) === Exclusivities.COLLABORATORS))
2236
+ couponUseLimits = coupon.useLimits.non_subscriber;
2237
+ else
2238
+ couponUseLimits = user && user.isSubscriber ? coupon.useLimits.subscriber : coupon.useLimits.non_subscriber;
2239
+ }
2240
+ else {
2241
+ couponUseLimits = coupon.useLimits.subscription;
2242
+ }
2243
+ return couponUseLimits;
2244
+ }
2245
+ }
2246
+ CouponService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CouponService, deps: [{ token: 'CouponRepository' }, { token: DEFAULT_SHOP }, { token: 'OrderRepository' }, { token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
2247
+ CouponService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CouponService, providedIn: 'root' });
2248
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CouponService, decorators: [{
2249
+ type: Injectable,
2250
+ args: [{
2251
+ providedIn: 'root',
2252
+ }]
2253
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
2254
+ type: Inject,
2255
+ args: ['CouponRepository']
2256
+ }] }, { type: i1$3.Shops, decorators: [{
2257
+ type: Inject,
2258
+ args: [DEFAULT_SHOP]
2259
+ }] }, { type: undefined, decorators: [{
2260
+ type: Inject,
2261
+ args: ['OrderRepository']
2262
+ }] }, { type: undefined, decorators: [{
2263
+ type: Inject,
2264
+ args: ['CategoryRepository']
2265
+ }] }]; } });
2266
+
2394
2267
  class CheckoutSubscriptionService {
2395
2268
  constructor(checkoutSubscriptionRepository, dataPersistence, couponService) {
2396
2269
  this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
@@ -2565,7 +2438,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
2565
2438
  }] }, { type: undefined, decorators: [{
2566
2439
  type: Inject,
2567
2440
  args: ['ProductRepository']
2568
- }] }, { type: i1$2.Shops, decorators: [{
2441
+ }] }, { type: i1$3.Shops, decorators: [{
2569
2442
  type: Inject,
2570
2443
  args: [DEFAULT_SHOP]
2571
2444
  }] }]; } });
@@ -2587,97 +2460,11 @@ OrderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "1
2587
2460
  OrderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OrderService });
2588
2461
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OrderService, decorators: [{
2589
2462
  type: Injectable
2590
- }], ctorParameters: function () { return [{ type: i1$1.Firestore }, { type: i1$2.OrderFirestoreRepository, decorators: [{
2463
+ }], ctorParameters: function () { return [{ type: i1$1.Firestore }, { type: i1$3.OrderFirestoreRepository, decorators: [{
2591
2464
  type: Inject,
2592
2465
  args: ['OrderRepository']
2593
2466
  }] }]; } });
2594
2467
 
2595
- class ShippingService {
2596
- constructor(http, apiUrl, homeService) {
2597
- this.http = http;
2598
- this.apiUrl = apiUrl;
2599
- this.homeService = homeService;
2600
- }
2601
- getShippingMethods(shop, zip, weightGrams, totalPrice, personId, subscriptionPlan) {
2602
- return combineLatest([
2603
- this.homeService.getHomeData(),
2604
- this.http.get(`${this.apiUrl}open/checkshippingcompany?personId=${personId}&postalCode=${zip}&weightGrams=${weightGrams}`),
2605
- ]).pipe(map(([datas, shippingMethodsResponse]) => {
2606
- let shippingMethods = shippingMethodsResponse.result;
2607
- if (!shippingMethods.length)
2608
- return [];
2609
- shippingMethods = shippingMethods.map((shippingMethod) => {
2610
- if (shippingMethod.ShippingCompanyName == 'Same Day EG')
2611
- shippingMethod.ShippingCompanyName = 'Same Day';
2612
- return shippingMethod;
2613
- });
2614
- const datasSameDayNotAvaliable = datas.sameDayNotAvaliable;
2615
- if (this.isHolidays(datasSameDayNotAvaliable)) {
2616
- shippingMethods = shippingMethods.filter((method) => method.serviceName !== 'Same Day');
2617
- }
2618
- if (totalPrice >= 200) {
2619
- shippingMethods = shippingMethods.map((s) => {
2620
- if (s.serviceName !== 'Same Day')
2621
- return { ...s, totalPrice: 0 };
2622
- else
2623
- return s;
2624
- });
2625
- }
2626
- if (shop == Shops.GLAMSHOP)
2627
- return shippingMethods;
2628
- if (this.isFreeShippingBySubscription(shop, subscriptionPlan)) {
2629
- shippingMethods = shippingMethods.map((s) => {
2630
- if (s.serviceName == 'Same Day')
2631
- return { ...s, totalPrice: s.totalPrice / 2 };
2632
- else
2633
- return { ...s, totalPrice: 0 };
2634
- });
2635
- }
2636
- if (this.isHalfShippingBySubscription(shop, subscriptionPlan)) {
2637
- shippingMethods = shippingMethods.map((s) => {
2638
- return { ...s, totalPrice: s.totalPrice / 2 };
2639
- });
2640
- }
2641
- return shippingMethods;
2642
- }));
2643
- }
2644
- isFreeShippingBySubscription(shop, subscriptionPlan) {
2645
- if (!subscriptionPlan)
2646
- return false;
2647
- if (shop == Shops.MENSMARKET && subscriptionPlan == 'SELECT')
2648
- return true;
2649
- return false;
2650
- }
2651
- isHalfShippingBySubscription(shop, subscriptionPlan) {
2652
- if (!subscriptionPlan)
2653
- return false;
2654
- if (shop == Shops.MENSMARKET && subscriptionPlan == 'PRIME') {
2655
- return true;
2656
- }
2657
- return false;
2658
- }
2659
- isHolidays(datas) {
2660
- const today = new Date();
2661
- for (const key in datas) {
2662
- let start = new Date(`${today.getFullYear()}-${datas[key].beginDate}`);
2663
- let end = new Date(`${today.getFullYear()}-${datas[key].endDate}`);
2664
- if (start > end)
2665
- end = new Date(`${today.getFullYear() + 1}-${datas[key].endDate}`);
2666
- if (today >= start && today <= end)
2667
- return true;
2668
- }
2669
- return false;
2670
- }
2671
- }
2672
- ShippingService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ShippingService, deps: [{ token: i3.HttpClient }, { token: BACKEND_URL }, { token: HomeShopService }], target: i0.ɵɵFactoryTarget.Injectable });
2673
- ShippingService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ShippingService });
2674
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ShippingService, decorators: [{
2675
- type: Injectable
2676
- }], ctorParameters: function () { return [{ type: i3.HttpClient }, { type: undefined, decorators: [{
2677
- type: Inject,
2678
- args: [BACKEND_URL]
2679
- }] }, { type: HomeShopService }]; } });
2680
-
2681
2468
  class AngularConnectModule {
2682
2469
  static initializeApp(defaultShop, options, nameOrConfig) {
2683
2470
  return {
@@ -2703,7 +2490,7 @@ class AngularConnectModule {
2703
2490
  }
2704
2491
  }
2705
2492
  AngularConnectModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2706
- AngularConnectModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, imports: [i1$3.FirebaseAppModule, i2.StorageModule, AngularElasticSeachModule,
2493
+ AngularConnectModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, imports: [i1$4.FirebaseAppModule, i2.StorageModule, AngularElasticSeachModule,
2707
2494
  AngularVertexSeachModule,
2708
2495
  AngularFirebaseAuthModule,
2709
2496
  AngularFirestoreModule,
@@ -2718,7 +2505,6 @@ AngularConnectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", ve
2718
2505
  CouponService,
2719
2506
  HomeShopService,
2720
2507
  OrderService,
2721
- ShippingService,
2722
2508
  WishlistService,
2723
2509
  {
2724
2510
  provide: UpdateUserImage,
@@ -2783,7 +2569,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
2783
2569
  CouponService,
2784
2570
  HomeShopService,
2785
2571
  OrderService,
2786
- ShippingService,
2787
2572
  WishlistService,
2788
2573
  {
2789
2574
  provide: UpdateUserImage,
@@ -2811,5 +2596,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
2811
2596
  * Generated bundle index. Do not edit.
2812
2597
  */
2813
2598
 
2814
- export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule, AuthService, CartService, CatalogService, CategoryService, CategoryWithTree, CheckoutService, CheckoutSubscriptionService, CookieDataPersistence, CouponService, HomeShopService, NewCategoryStructureAdapter, OldCategoryStructureAdapter, OrderService, ProductSorts, ShippingService, UtilHelper, WishlistService };
2599
+ export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule, AuthService, CartService, CatalogService, CategoryService, CategoryWithTree, CheckoutService, CheckoutSubscriptionService, CookieDataPersistence, CouponService, HomeShopService, NewCategoryStructureAdapter, OldCategoryStructureAdapter, OrderService, ProductSorts, UtilHelper, WishlistService };
2815
2600
  //# sourceMappingURL=infrab4a-connect-angular.mjs.map