@infrab4a/connect-angular 4.17.3-beta.1 → 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,70 +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
- // this.checkoutUrl = `https://southamerica-east1-${this.firebaseOptions.projectId}.cloudfunctions.net`
1511
- this.checkoutUrl = `http://docker.for.localhost:5001/b4astage-cb80a/southamerica-east1`;
1223
+ this.checkoutUrl = `https://southamerica-east1-${this.firebaseOptions.projectId}.cloudfunctions.net`;
1224
+ // this.checkoutUrl = `http://docker.for.localhost:5001/b4astage-cb80a/southamerica-east1`
1512
1225
  }
1513
1226
  addItem(item, quantity = 1) {
1514
- return this.checkoutService.getCheckout().pipe(tap((checkout) => this.http.post(`${this.checkoutUrl}/checkoutAddItemToCart`, {
1515
- checkoutId: checkout.id,
1516
- productId: item.id,
1517
- quantity,
1518
- })), tap(() => this.checkoutService.getCheckout()), map((updatedCheckout) => this.generateCartObject(updatedCheckout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
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)));
1519
1238
  // return this.generateCartObject(checkoutUpdated.lineItems as LineItem[])
1520
1239
  // return from(this.checkoutService.getCheckout()).pipe(
1521
1240
  // concatMap(async (checkout) => await this.buildLineItem({ checkout, item, quantity: quantity || 1 })),
@@ -1524,11 +1243,14 @@ class CartService {
1524
1243
  // )
1525
1244
  }
1526
1245
  decreaseItem(item) {
1527
- return this.checkoutService.getCheckout().pipe(tap((checkout) => this.http.post(`${this.checkoutUrl}/checkoutDecreaseProductFromCart`, {
1246
+ return this.checkoutService.getCheckout().pipe(concatMap((checkout) => this.http.post(`${this.checkoutUrl}/checkoutDecreaseProductFromCart`, {
1528
1247
  checkoutId: checkout.id,
1529
1248
  productId: item.id,
1530
1249
  quantity: 1,
1531
- })), 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)));
1532
1254
  // return this.checkoutService.getCheckout().pipe(
1533
1255
  // map((checkout) => {
1534
1256
  // const checkoutItem = checkout.lineItems?.find((lineItem) => lineItem.id === item.id)
@@ -1541,10 +1263,13 @@ class CartService {
1541
1263
  // )
1542
1264
  }
1543
1265
  removeItem(item) {
1544
- 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`, {
1545
1267
  checkoutId: checkout.id,
1546
1268
  productId: item.id,
1547
- })), 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)));
1548
1273
  // return this.checkoutService.getCheckout().pipe(
1549
1274
  // map((checkout) => {
1550
1275
  // const index = checkout.lineItems.findIndex((lineItem) => lineItem.id === item.id)
@@ -1556,9 +1281,18 @@ class CartService {
1556
1281
  // tap((cart) => this.cartSubject.next(cart)),
1557
1282
  }
1558
1283
  updateUserCart(user) {
1559
- 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`, {
1560
- checkoutId: checkout.id,
1561
- })), 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)));
1562
1296
  // return this.checkoutService.getCheckout().pipe(
1563
1297
  // concatMap((checkout) =>
1564
1298
  // this.checkoutService.updateCheckoutUser(Checkout.toInstance({ ...checkout.toPlain(), user })),
@@ -1587,12 +1321,21 @@ class CartService {
1587
1321
  this.buildCartFromCheckout(checkout).subscribe((cart) => this.cartSubject.next(cart));
1588
1322
  return this.cartSubject;
1589
1323
  }
1590
- /**
1591
- * @deprecated The method should not be used
1592
- */
1593
- getVariantPriceDiscount(item) {
1594
- 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)));
1595
- }
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
+ // }
1596
1339
  clearCart() {
1597
1340
  return this.checkoutService.getCheckout().pipe(map((checkout) => {
1598
1341
  this.checkoutService.clearCheckoutFromSession();
@@ -1600,156 +1343,20 @@ class CartService {
1600
1343
  }), concatMap((oldCheckout) => this.buildCartFromCheckout(oldCheckout)), tap((cart) => this.cartSubject.next(cart)));
1601
1344
  }
1602
1345
  buildCartFromCheckout(checkoutData) {
1603
- return this.checkoutService.getCheckout(checkoutData).pipe(map((checkout) => checkout.lineItems), concatMap((lineItems) => of(this.generateCartObject(lineItems))));
1604
- }
1605
- roundPrice(productPrice) {
1606
- const { price, fullPrice, subscriberPrice } = productPrice;
1607
- return {
1608
- ...productPrice,
1609
- price: Number(price.toFixed(2)),
1610
- fullPrice: Number(fullPrice.toFixed(2)),
1611
- ...(subscriberPrice && { subscriberPrice: Number(subscriberPrice.toFixed(2)) }),
1612
- };
1613
- }
1614
- async getProductData(productId) {
1615
- let product;
1616
- let variant;
1617
- try {
1618
- product = await this.productRepository.get({ id: productId });
1619
- }
1620
- catch (error) {
1621
- if (!(error instanceof NotFoundError))
1622
- throw error;
1623
- const { data: variants } = await this.variantRepository.find({ filters: { id: productId } });
1624
- variant = variants.shift();
1625
- if (!variant)
1626
- throw error;
1627
- product = await this.productRepository.get({ id: variant.productId });
1628
- }
1629
- return {
1630
- ...product.toPlain(),
1631
- ...(variant && { ...variant.toPlain() }),
1632
- };
1633
- }
1634
- getGifts() {
1635
- return this.checkoutService.getCheckout().pipe(mergeMap(async (checkout) => {
1636
- const notGiftItems = checkout.lineItems ? checkout.lineItems.filter((item) => !item.isGift) : [];
1637
- if (!notGiftItems.length)
1638
- return { ...checkout, lineItems: [] };
1639
- const campaigns = await this.buy2WinRepository
1640
- .find({
1641
- filters: {
1642
- active: { operator: Where.EQUALS, value: true },
1643
- },
1644
- })
1645
- .then((data) => data.data.filter((campaign) => campaign.shop === Shops.ALL || campaign.shop === this.defaultShop));
1646
- if (!campaigns.length)
1647
- return { ...checkout, lineItems: notGiftItems };
1648
- const elegibleCampaigns = [];
1649
- for (const campaign of campaigns) {
1650
- const today = new Date().getTime();
1651
- if (!(campaign.startDate.getTime() <= today) && !(campaign.endDate.getTime() >= today))
1652
- continue;
1653
- if (campaign.activeCategory) {
1654
- const categoriesCampaing = campaign.categories.map((c) => c.id.toString());
1655
- const categoriesCampaingFullTree = [];
1656
- for (const id of categoriesCampaing) {
1657
- const children = await this.categoryRepository.getChildren(parseInt(id));
1658
- categoriesCampaingFullTree.push(id, ...children.map((c) => c.id.toString()));
1659
- }
1660
- const categoriesCampaingTree = [...new Set(categoriesCampaingFullTree)];
1661
- const filterProductsCategories = notGiftItems.filter((l) => {
1662
- if (!l.categories || !l.categories?.length)
1663
- return true;
1664
- return l.categories.some((c) => categoriesCampaingTree.some((cat) => cat == c));
1665
- });
1666
- if (filterProductsCategories.length) {
1667
- const cartValuelWithCategories = filterProductsCategories.reduce((a, b) => a + b.pricePaid * b.quantity, 0);
1668
- const cartItensQuantityWithCategories = filterProductsCategories.reduce((a, b) => a + b.quantity, 0);
1669
- const hasMinValue = campaign.cartValueMin && cartValuelWithCategories >= campaign.cartValueMin;
1670
- const hasMinQuantity = campaign.cartItensQuantityMin && cartItensQuantityWithCategories >= campaign.cartItensQuantityMin;
1671
- if (hasMinQuantity || hasMinValue)
1672
- elegibleCampaigns.push(campaign);
1673
- }
1674
- }
1675
- else {
1676
- const cartTotal = notGiftItems.reduce((a, b) => a + b.pricePaid * b.quantity, 0);
1677
- const cartItensQuantity = notGiftItems.reduce((a, b) => a + b.quantity, 0);
1678
- const hasMinValue = campaign.cartValue && campaign.cartValue > 0 && campaign.cartValue <= cartTotal;
1679
- const hasMinQuantity = campaign.cartItensQuantityMin && cartItensQuantity >= campaign.cartItensQuantityMin;
1680
- if (hasMinQuantity || hasMinValue)
1681
- elegibleCampaigns.push(campaign);
1682
- }
1683
- }
1684
- if (!elegibleCampaigns.length)
1685
- return { ...checkout, lineItems: notGiftItems };
1686
- const campaingnProducts = [];
1687
- for (const campaign of elegibleCampaigns) {
1688
- let elegibleProducts = [];
1689
- for (const product of campaign.products) {
1690
- const { data: productData } = await this.productRepository.find({ filters: { sku: product } });
1691
- if (!productData.length)
1692
- continue;
1693
- const gift = productData.shift();
1694
- if (gift.stock.quantity < 1)
1695
- continue;
1696
- elegibleProducts.push(gift);
1697
- }
1698
- campaingnProducts.push(elegibleProducts);
1699
- }
1700
- if (!campaingnProducts.length)
1701
- return { ...checkout, lineItems: notGiftItems };
1702
- const gifts = this.giftToLineItems([].concat(...campaingnProducts));
1703
- return { ...checkout, lineItems: notGiftItems.concat(gifts) };
1704
- }), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
1705
- }
1706
- giftToLineItems(items) {
1707
- return items.map((item) => {
1708
- const { brand, categories, category, id, name, price, sku, slug, stock, weight, EAN } = item;
1709
- const image = item?.miniatures?.length ? item.miniatures[0] : item.images[0];
1710
- return LineItem.toInstance({
1711
- brand,
1712
- categories,
1713
- category,
1714
- id: id.toString(),
1715
- name,
1716
- price,
1717
- sku,
1718
- slug,
1719
- stock,
1720
- weight,
1721
- EAN,
1722
- image,
1723
- pricePaid: 0,
1724
- quantity: 1,
1725
- isGift: true,
1726
- });
1727
- });
1346
+ return this.checkoutService.getCheckout(checkoutData).pipe(map((checkout) => checkout.lineItems), concatMap((lineItems) => of(this.generateCartObject(lineItems))));
1728
1347
  }
1729
1348
  }
1730
- 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 });
1731
1350
  CartService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService });
1732
1351
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService, decorators: [{
1733
1352
  type: Injectable
1734
- }], 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: [{
1735
1354
  type: Inject,
1736
1355
  args: [DEFAULT_SHOP]
1737
1356
  }] }, { type: undefined, decorators: [{
1738
1357
  type: Inject,
1739
1358
  args: [FIREBASE_OPTIONS]
1740
- }] }, { type: undefined, decorators: [{
1741
- type: Inject,
1742
- args: ['ProductRepository']
1743
- }] }, { type: undefined, decorators: [{
1744
- type: Inject,
1745
- args: ['CategoryRepository']
1746
- }] }, { type: undefined, decorators: [{
1747
- type: Inject,
1748
- args: ['VariantRepository']
1749
- }] }, { type: i1$2.Buy2WinFirestoreRepository, decorators: [{
1750
- type: Inject,
1751
- args: ['Buy2WinRepository']
1752
- }] }, { type: i3.HttpClient }]; } });
1359
+ }] }, { type: i1$2.HttpClient }]; } });
1753
1360
 
1754
1361
  class NewCategoryStructureAdapter {
1755
1362
  constructor(categoryRepository) {
@@ -2093,7 +1700,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
2093
1700
  }] }, { type: undefined, decorators: [{
2094
1701
  type: Inject,
2095
1702
  args: [CATEGORY_STRUCTURE]
2096
- }] }, { type: i1$2.Shops, decorators: [{
1703
+ }] }, { type: i1$3.Shops, decorators: [{
2097
1704
  type: Inject,
2098
1705
  args: [DEFAULT_SHOP]
2099
1706
  }] }, { type: undefined, decorators: [{
@@ -2142,7 +1749,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
2142
1749
  }] }, { type: undefined, decorators: [{
2143
1750
  type: Inject,
2144
1751
  args: [CATEGORY_STRUCTURE]
2145
- }] }, { type: i1$2.Shops, decorators: [{
1752
+ }] }, { type: i1$3.Shops, decorators: [{
2146
1753
  type: Inject,
2147
1754
  args: [DEFAULT_SHOP]
2148
1755
  }] }]; } });
@@ -2369,7 +1976,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
2369
1976
  }], ctorParameters: function () { return [{ type: undefined, decorators: [{
2370
1977
  type: Inject,
2371
1978
  args: ['WishlistRepository']
2372
- }] }, { type: i1$2.Shops, decorators: [{
1979
+ }] }, { type: i1$3.Shops, decorators: [{
2373
1980
  type: Inject,
2374
1981
  args: [DEFAULT_SHOP]
2375
1982
  }] }, { type: undefined, decorators: [{
@@ -2392,6 +1999,271 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
2392
1999
  args: ['LogRepository']
2393
2000
  }] }]; } });
2394
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
+
2395
2267
  class CheckoutSubscriptionService {
2396
2268
  constructor(checkoutSubscriptionRepository, dataPersistence, couponService) {
2397
2269
  this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
@@ -2566,7 +2438,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
2566
2438
  }] }, { type: undefined, decorators: [{
2567
2439
  type: Inject,
2568
2440
  args: ['ProductRepository']
2569
- }] }, { type: i1$2.Shops, decorators: [{
2441
+ }] }, { type: i1$3.Shops, decorators: [{
2570
2442
  type: Inject,
2571
2443
  args: [DEFAULT_SHOP]
2572
2444
  }] }]; } });
@@ -2588,97 +2460,11 @@ OrderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "1
2588
2460
  OrderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OrderService });
2589
2461
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OrderService, decorators: [{
2590
2462
  type: Injectable
2591
- }], 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: [{
2592
2464
  type: Inject,
2593
2465
  args: ['OrderRepository']
2594
2466
  }] }]; } });
2595
2467
 
2596
- class ShippingService {
2597
- constructor(http, apiUrl, homeService) {
2598
- this.http = http;
2599
- this.apiUrl = apiUrl;
2600
- this.homeService = homeService;
2601
- }
2602
- getShippingMethods(shop, zip, weightGrams, totalPrice, personId, subscriptionPlan) {
2603
- return combineLatest([
2604
- this.homeService.getHomeData(),
2605
- this.http.get(`${this.apiUrl}open/checkshippingcompany?personId=${personId}&postalCode=${zip}&weightGrams=${weightGrams}`),
2606
- ]).pipe(map(([datas, shippingMethodsResponse]) => {
2607
- let shippingMethods = shippingMethodsResponse.result;
2608
- if (!shippingMethods.length)
2609
- return [];
2610
- shippingMethods = shippingMethods.map((shippingMethod) => {
2611
- if (shippingMethod.ShippingCompanyName == 'Same Day EG')
2612
- shippingMethod.ShippingCompanyName = 'Same Day';
2613
- return shippingMethod;
2614
- });
2615
- const datasSameDayNotAvaliable = datas.sameDayNotAvaliable;
2616
- if (this.isHolidays(datasSameDayNotAvaliable)) {
2617
- shippingMethods = shippingMethods.filter((method) => method.serviceName !== 'Same Day');
2618
- }
2619
- if (totalPrice >= 200) {
2620
- shippingMethods = shippingMethods.map((s) => {
2621
- if (s.serviceName !== 'Same Day')
2622
- return { ...s, totalPrice: 0 };
2623
- else
2624
- return s;
2625
- });
2626
- }
2627
- if (shop == Shops.GLAMSHOP)
2628
- return shippingMethods;
2629
- if (this.isFreeShippingBySubscription(shop, subscriptionPlan)) {
2630
- shippingMethods = shippingMethods.map((s) => {
2631
- if (s.serviceName == 'Same Day')
2632
- return { ...s, totalPrice: s.totalPrice / 2 };
2633
- else
2634
- return { ...s, totalPrice: 0 };
2635
- });
2636
- }
2637
- if (this.isHalfShippingBySubscription(shop, subscriptionPlan)) {
2638
- shippingMethods = shippingMethods.map((s) => {
2639
- return { ...s, totalPrice: s.totalPrice / 2 };
2640
- });
2641
- }
2642
- return shippingMethods;
2643
- }));
2644
- }
2645
- isFreeShippingBySubscription(shop, subscriptionPlan) {
2646
- if (!subscriptionPlan)
2647
- return false;
2648
- if (shop == Shops.MENSMARKET && subscriptionPlan == 'SELECT')
2649
- return true;
2650
- return false;
2651
- }
2652
- isHalfShippingBySubscription(shop, subscriptionPlan) {
2653
- if (!subscriptionPlan)
2654
- return false;
2655
- if (shop == Shops.MENSMARKET && subscriptionPlan == 'PRIME') {
2656
- return true;
2657
- }
2658
- return false;
2659
- }
2660
- isHolidays(datas) {
2661
- const today = new Date();
2662
- for (const key in datas) {
2663
- let start = new Date(`${today.getFullYear()}-${datas[key].beginDate}`);
2664
- let end = new Date(`${today.getFullYear()}-${datas[key].endDate}`);
2665
- if (start > end)
2666
- end = new Date(`${today.getFullYear() + 1}-${datas[key].endDate}`);
2667
- if (today >= start && today <= end)
2668
- return true;
2669
- }
2670
- return false;
2671
- }
2672
- }
2673
- 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 });
2674
- ShippingService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ShippingService });
2675
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ShippingService, decorators: [{
2676
- type: Injectable
2677
- }], ctorParameters: function () { return [{ type: i3.HttpClient }, { type: undefined, decorators: [{
2678
- type: Inject,
2679
- args: [BACKEND_URL]
2680
- }] }, { type: HomeShopService }]; } });
2681
-
2682
2468
  class AngularConnectModule {
2683
2469
  static initializeApp(defaultShop, options, nameOrConfig) {
2684
2470
  return {
@@ -2704,7 +2490,7 @@ class AngularConnectModule {
2704
2490
  }
2705
2491
  }
2706
2492
  AngularConnectModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2707
- 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,
2708
2494
  AngularVertexSeachModule,
2709
2495
  AngularFirebaseAuthModule,
2710
2496
  AngularFirestoreModule,
@@ -2719,7 +2505,6 @@ AngularConnectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", ve
2719
2505
  CouponService,
2720
2506
  HomeShopService,
2721
2507
  OrderService,
2722
- ShippingService,
2723
2508
  WishlistService,
2724
2509
  {
2725
2510
  provide: UpdateUserImage,
@@ -2784,7 +2569,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
2784
2569
  CouponService,
2785
2570
  HomeShopService,
2786
2571
  OrderService,
2787
- ShippingService,
2788
2572
  WishlistService,
2789
2573
  {
2790
2574
  provide: UpdateUserImage,
@@ -2812,5 +2596,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
2812
2596
  * Generated bundle index. Do not edit.
2813
2597
  */
2814
2598
 
2815
- 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 };
2816
2600
  //# sourceMappingURL=infrab4a-connect-angular.mjs.map