@infrab4a/connect-angular 5.0.0-beta.56 → 5.0.0-beta.58
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2022/angular-connect.module.mjs +1 -1
- package/esm2022/angular-elastic-search.module.mjs +1 -1
- package/esm2022/angular-firebase-auth.module.mjs +1 -1
- package/esm2022/angular-firestore.module.mjs +1 -1
- package/esm2022/angular-hasura-graphql.module.mjs +1 -1
- package/esm2022/consts/category-structure.mjs +1 -1
- package/esm2022/consts/default-shop.const.mjs +1 -1
- package/esm2022/consts/es-config.const.mjs +1 -1
- package/esm2022/consts/firebase-const.mjs +1 -1
- package/esm2022/consts/hasura-options.const.mjs +1 -1
- package/esm2022/consts/index.mjs +1 -1
- package/esm2022/consts/persistence.const.mjs +1 -1
- package/esm2022/consts/storage-base-url.const.mjs +1 -1
- package/esm2022/helpers/index.mjs +1 -1
- package/esm2022/helpers/mobile-operation-system-checker.helper.mjs +1 -1
- package/esm2022/index.mjs +1 -1
- package/esm2022/persistence/cookie-data-persistence.mjs +1 -1
- package/esm2022/persistence/data-persistence.mjs +1 -1
- package/esm2022/persistence/index.mjs +1 -1
- package/esm2022/services/auth.service.mjs +1 -1
- package/esm2022/services/cart.service.mjs +9 -7
- package/esm2022/services/catalog/adapters/category-structure.adapter.mjs +1 -1
- package/esm2022/services/catalog/adapters/index.mjs +1 -1
- package/esm2022/services/catalog/adapters/new-category-structure.adapter.mjs +1 -1
- package/esm2022/services/catalog/adapters/old-category-structure.adapter.mjs +1 -1
- package/esm2022/services/catalog/catalog.service.mjs +10 -5
- package/esm2022/services/catalog/category.service.mjs +1 -1
- package/esm2022/services/catalog/enums/index.mjs +1 -1
- package/esm2022/services/catalog/enums/product-sorts.enum.mjs +1 -1
- package/esm2022/services/catalog/index.mjs +1 -1
- package/esm2022/services/catalog/models/category-with-tree.model.mjs +1 -1
- package/esm2022/services/catalog/models/index.mjs +1 -1
- package/esm2022/services/catalog/types/index.mjs +1 -1
- package/esm2022/services/catalog/types/product-sort.type.mjs +1 -1
- package/esm2022/services/catalog/wishlist.service.mjs +1 -1
- package/esm2022/services/checkout-subscription.service.mjs +1 -1
- package/esm2022/services/checkout.service.mjs +1 -1
- package/esm2022/services/coupon.service.mjs +13 -8
- package/esm2022/services/helpers/index.mjs +1 -1
- package/esm2022/services/helpers/util.helper.mjs +1 -1
- package/esm2022/services/home-shop.service.mjs +1 -1
- package/esm2022/services/index.mjs +1 -1
- package/esm2022/services/order.service.mjs +1 -1
- package/esm2022/services/shipping.service.mjs +1 -1
- package/esm2022/services/types/index.mjs +1 -1
- package/esm2022/services/types/required-checkout-data.type.mjs +1 -1
- package/esm2022/services/types/required-checkout-subscription-data.type.mjs +1 -1
- package/esm2022/services/types/shipping-methods.type.mjs +1 -1
- package/esm2022/types/firebase-app-config.type.mjs +1 -1
- package/esm2022/types/index.mjs +1 -1
- package/fesm2022/infrab4a-connect-angular.mjs +26 -14
- package/fesm2022/infrab4a-connect-angular.mjs.map +1 -1
- package/package.json +2 -2
- package/services/catalog/catalog.service.d.ts +1 -1
|
@@ -5,7 +5,7 @@ import { FirebaseApp, provideFirebaseApp, getApp, initializeApp } from '@angular
|
|
|
5
5
|
import * as i2 from '@angular/fire/storage';
|
|
6
6
|
import { Storage, provideStorage, getStorage } from '@angular/fire/storage';
|
|
7
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, CategoryHasuraGraphQLRepository, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository, ProductReviewsHasuraGraphQLRepository, VariantHasuraGraphQLRepository, ProductStockNotificationHasuraGraphQLRepository, FilterOptionHasuraGraphQLRepository, FilterHasuraGraphQLRepository, CategoryCollectionChildrenHasuraGraphQLRepository, WishlistHasuraGraphQLRepository, Where, Shops, CheckoutTypes, CouponTypes, Exclusivities, isNil, NotFoundError, Checkout, pick, LineItem, RoundProductPricesHelper, set, InvalidArgumentError, Category, PersonTypes, Wishlist, CheckoutSubscription, Product, RequiredArgumentError, add, Order, UpdateUserImage, FirebaseFileUploaderService } 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, CategoryHasuraGraphQLRepository, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository, ProductReviewsHasuraGraphQLRepository, VariantHasuraGraphQLRepository, ProductStockNotificationHasuraGraphQLRepository, FilterOptionHasuraGraphQLRepository, FilterHasuraGraphQLRepository, CategoryCollectionChildrenHasuraGraphQLRepository, WishlistHasuraGraphQLRepository, Where, Shops, CheckoutTypes, CouponTypes, Exclusivities, OrderStatus, isNil, NotFoundError, Checkout, pick, LineItem, RoundProductPricesHelper, set, InvalidArgumentError, Category, PersonTypes, Wishlist, 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';
|
|
@@ -1048,11 +1048,11 @@ class CouponService {
|
|
|
1048
1048
|
throw 'Limite de uso atingido';
|
|
1049
1049
|
}
|
|
1050
1050
|
if (!couponUseLimits.unlimited || couponUseLimits.limitedPerUser) {
|
|
1051
|
-
const
|
|
1052
|
-
if (!couponUseLimits.unlimited && couponUseLimits.total &&
|
|
1051
|
+
const ordersCoupon = await this.getOrdersWithCoupon(coupon);
|
|
1052
|
+
if (!couponUseLimits.unlimited && couponUseLimits.total && ordersCoupon.length >= couponUseLimits.total)
|
|
1053
1053
|
throw 'Limite de uso atingido.';
|
|
1054
1054
|
if (couponUseLimits.limitedPerUser) {
|
|
1055
|
-
const ordersWithUser = this.countOrdersWithUser(
|
|
1055
|
+
const ordersWithUser = this.countOrdersWithUser(ordersCoupon, checkout.user.email);
|
|
1056
1056
|
if (ordersWithUser > 0)
|
|
1057
1057
|
throw 'Limite de uso por usuário atingido.';
|
|
1058
1058
|
}
|
|
@@ -1178,7 +1178,7 @@ class CouponService {
|
|
|
1178
1178
|
.find({
|
|
1179
1179
|
filters: {
|
|
1180
1180
|
coupon: { id: coupon.id },
|
|
1181
|
-
|
|
1181
|
+
status: { operator: Where.NOTEQUALS, value: OrderStatus.CANCELADO },
|
|
1182
1182
|
},
|
|
1183
1183
|
})
|
|
1184
1184
|
.then((result) => result.data);
|
|
@@ -1188,7 +1188,7 @@ class CouponService {
|
|
|
1188
1188
|
.find({
|
|
1189
1189
|
filters: {
|
|
1190
1190
|
user: { email: { operator: Where.EQUALS, value: email } },
|
|
1191
|
-
|
|
1191
|
+
status: { operator: Where.NOTEQUALS, value: OrderStatus.CANCELADO },
|
|
1192
1192
|
},
|
|
1193
1193
|
})
|
|
1194
1194
|
.then((result) => result.data);
|
|
@@ -1199,7 +1199,12 @@ class CouponService {
|
|
|
1199
1199
|
getCouponUseLimits(coupon, checkoutType, user) {
|
|
1200
1200
|
let couponUseLimits;
|
|
1201
1201
|
if (checkoutType == CheckoutTypes.ECOMMERCE || checkoutType == CheckoutTypes.ALL) {
|
|
1202
|
-
|
|
1202
|
+
if (coupon.exclusivityType.length === 1 &&
|
|
1203
|
+
(coupon.exclusivityType.at(0) === Exclusivities.SPECIFIC_USER ||
|
|
1204
|
+
coupon.exclusivityType.at(0) === Exclusivities.COLLABORATORS))
|
|
1205
|
+
couponUseLimits = coupon.useLimits.non_subscriber;
|
|
1206
|
+
else
|
|
1207
|
+
couponUseLimits = user && user.isSubscriber ? coupon.useLimits.subscriber : coupon.useLimits.non_subscriber;
|
|
1203
1208
|
}
|
|
1204
1209
|
else {
|
|
1205
1210
|
couponUseLimits = coupon.useLimits.subscription;
|
|
@@ -1327,6 +1332,7 @@ class CartService {
|
|
|
1327
1332
|
if (index > -1) {
|
|
1328
1333
|
checkoutLoaded.lineItems[index].quantity += quantity;
|
|
1329
1334
|
checkoutLoaded.lineItems[index].pricePaid = lineItem.pricePaid;
|
|
1335
|
+
checkoutLoaded.lineItems[index].price = lineItem.price;
|
|
1330
1336
|
}
|
|
1331
1337
|
else
|
|
1332
1338
|
checkoutLoaded.lineItems = items.concat(checkoutLoaded.lineItems ? checkoutLoaded.lineItems.concat([lineItem]) : [lineItem]);
|
|
@@ -1347,14 +1353,15 @@ class CartService {
|
|
|
1347
1353
|
if (this.checkMaxStock(product.stock.quantity, item.quantity || 0, quantity || 0))
|
|
1348
1354
|
throw new Error('Desculpe! Temos apenas ' + product.stock?.quantity + ' em estoque.');
|
|
1349
1355
|
const image = item.image || item.images?.shift();
|
|
1350
|
-
const { id, name, EAN, slug,
|
|
1356
|
+
const { id, name, EAN, slug, weight, sku, type } = item;
|
|
1351
1357
|
const isGift = item.isGift || null;
|
|
1352
1358
|
const pricePaid = this.getProductPrice({
|
|
1353
|
-
product:
|
|
1359
|
+
product: LineItem.toInstance(product),
|
|
1354
1360
|
shop: checkout.shop || this.defaultShop,
|
|
1355
1361
|
isSubscriber: checkout.user?.isSubscriber,
|
|
1356
1362
|
});
|
|
1357
1363
|
RoundProductPricesHelper.roundProductPrices(item);
|
|
1364
|
+
RoundProductPricesHelper.roundProductPrices(product);
|
|
1358
1365
|
return {
|
|
1359
1366
|
checkout,
|
|
1360
1367
|
lineItem: LineItem.toInstance({
|
|
@@ -1364,8 +1371,8 @@ class CartService {
|
|
|
1364
1371
|
brand: product.brand,
|
|
1365
1372
|
slug: slug ?? product.slug,
|
|
1366
1373
|
sku: sku ?? product.sku,
|
|
1367
|
-
stock,
|
|
1368
|
-
price: this.roundPrice(price),
|
|
1374
|
+
stock: product.stock,
|
|
1375
|
+
price: this.roundPrice(product.price),
|
|
1369
1376
|
image,
|
|
1370
1377
|
weight: weight ?? product.weight,
|
|
1371
1378
|
quantity: (item.quantity || 0) + (quantity || 0),
|
|
@@ -1780,15 +1787,20 @@ class CatalogService {
|
|
|
1780
1787
|
id: { operator: Where.IN, value: mostRelevantProductsIds },
|
|
1781
1788
|
...this.buildFilterQuery(options?.filters || {}),
|
|
1782
1789
|
},
|
|
1783
|
-
orderBy: this.buildSortQuery('
|
|
1790
|
+
orderBy: this.buildSortQuery('best-sellers'),
|
|
1784
1791
|
options: {
|
|
1785
1792
|
minimal: ['price'],
|
|
1786
1793
|
maximum: ['price'],
|
|
1787
1794
|
distinct: ['brand'],
|
|
1788
1795
|
},
|
|
1789
1796
|
}, options?.mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female');
|
|
1790
|
-
const
|
|
1791
|
-
const
|
|
1797
|
+
const mostRelevantWithouyStock = totalResult.data.filter((product) => mostRelevants.includes(product.id) && product.stock.quantity <= 0);
|
|
1798
|
+
const firstProducts = totalResult.data
|
|
1799
|
+
.filter((product) => mostRelevants.includes(product.id) && product.stock.quantity > 0)
|
|
1800
|
+
.sort((a, b) => mostRelevants.indexOf(a.id) - mostRelevants.indexOf(b.id));
|
|
1801
|
+
const lastProducts = totalResult.data
|
|
1802
|
+
.filter((product) => !mostRelevants.includes(product.id))
|
|
1803
|
+
.concat(mostRelevantWithouyStock);
|
|
1792
1804
|
const categoryMostRelevants = firstProducts.concat(lastProducts);
|
|
1793
1805
|
const resultFinal = categoryMostRelevants.slice(limits.offset, limits.offset + limits.limit);
|
|
1794
1806
|
return {
|