@sentecacommerce-theme/lib 0.13.5-alpha.7 → 0.13.7-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/analytics/Pixel/hooks/usePixelProductClick.js +1 -1
- package/dist/cjs/analytics/Pixel/hooks/usePixelProductDetails.js +1 -1
- package/dist/cjs/analytics/Pixel/hooks/usePixelProductsImpression.js +1 -1
- package/dist/cjs/analytics/Pixel/usePixel.js +1 -1
- package/dist/cjs/analytics/Releva/useReleva.js +1 -1
- package/dist/cjs/analytics/addToCart.js +0 -1
- package/dist/cjs/analytics/initiateCheckout.js +0 -1
- package/dist/cjs/analytics/viewContent.js +0 -1
- package/dist/cjs/api/myCartApi/index.js +2 -1
- package/dist/cjs/api.v2/core/checkout/payments/useSetMerchantPaymentMethod.js +1 -1
- package/dist/cjs/basket/api/index.js +37 -0
- package/dist/cjs/basket/api/mutations/index.js +37 -0
- package/dist/cjs/basket/api/mutations/useReplaceBasketMutation.js +58 -0
- package/dist/cjs/basket/hooks/index.js +52 -0
- package/dist/cjs/basket/hooks/useBasketCrossSaleItems.js +99 -0
- package/dist/cjs/basket/hooks/useReplaceBasket.js +10 -0
- package/dist/cjs/basket/index.js +37 -0
- package/dist/cjs/checkout/api/keys.js +8 -1
- package/dist/cjs/checkout/api/queries/index.js +15 -0
- package/dist/cjs/checkout/api/queries/useBnpCalculateForCartQuery.js +60 -0
- package/dist/cjs/checkout/hooks/index.js +15 -0
- package/dist/cjs/checkout/hooks/useBnpCalculateForCart.js +120 -0
- package/dist/cjs/components/Html/index.js +1 -1
- package/dist/cjs/components/Portal/index.js +1 -1
- package/dist/cjs/contexts/CheckoutForm/hooks/usePayment/index.js +7 -2
- package/dist/cjs/contexts/CheckoutForm/index.js +5 -3
- package/dist/cjs/hooks/ui-hooks/useIsDesktop/index.js +2 -2
- package/dist/cjs/hooks/useAllSelectedFilters/index.js +3 -3
- package/dist/cjs/hooks/useLineItem/index.js +7 -0
- package/dist/cjs/hooks/usePrice/index.js +1 -1
- package/dist/cjs/hooks/useProduct/index.js +26 -5
- package/dist/cjs/hooks/useProduct/utils/index.js +14 -1
- package/dist/cjs/hooks/useProgressBar/hooks/useGetSetState.js +1 -24
- package/dist/cjs/hooks/useSelectedFilters/index.js +3 -3
- package/dist/cjs/hooks/useVouchers/index.js +1 -2
- package/dist/cjs/index.js +24 -0
- package/dist/cjs/listing/api/queries/useAggregateQuery.js +47 -12
- package/dist/cjs/listing/api/queries/useInfiniteListing.js +4 -4
- package/dist/cjs/listing/api/queries/useListingQuery.js +37 -22
- package/dist/cjs/listing/api/queries/usePredicate.js +4 -4
- package/dist/cjs/listing/components/BasicListingSEO.js +1 -1
- package/dist/cjs/listing/hooks/useListingAlias.js +2 -4
- package/dist/cjs/listing/hooks/useListingBreadcrumbs.js +4 -4
- package/dist/cjs/listing/hooks/useListingCategories.js +7 -8
- package/dist/cjs/listing/hooks/useListingConfig.js +4 -5
- package/dist/cjs/listing/hooks/useListingFilters.js +19 -20
- package/dist/cjs/listing/hooks/useListingItems.js +2 -2
- package/dist/cjs/listing/hooks/useListingMeta.js +5 -4
- package/dist/cjs/listing/hooks/useListingPagination.js +4 -4
- package/dist/cjs/listing/hooks/useListingSlug.js +3 -1
- package/dist/cjs/listing/hooks/useSlideFilter.js +4 -3
- package/dist/cjs/listing/hooks/utils.js +2 -1
- package/dist/cjs/listing/ssr/prefetchListing.js +4 -4
- package/dist/cjs/listing/types.js +8 -1
- package/dist/cjs/listing/utils/buildCategoryQuery.js +16 -12
- package/dist/cjs/listing/utils/buildFilterQuery.js +5 -7
- package/dist/cjs/listing/utils/getListingAlias.js +5 -6
- package/dist/cjs/listing/utils/getListingPageType.js +4 -3
- package/dist/cjs/navigation/components/SearchBox/Components/Container/index.js +1 -1
- package/dist/cjs/navigation/components/SearchBox/Components/EmptyBox/index.js +19 -18
- package/dist/cjs/navigation/components/SearchBox/Components/PopularSearches/index.js +1 -1
- package/dist/cjs/navigation/components/SearchBox/Components/Products/Components/ProductCard/index.js +1 -1
- package/dist/cjs/navigation/components/SearchBox/Components/Products/index.js +2 -2
- package/dist/cjs/navigation/components/SearchBox/Components/RecentSearches/index.js +1 -1
- package/dist/cjs/navigation/components/SearchBox/index.js +11 -11
- package/dist/cjs/order/api/mutations/index.js +15 -0
- package/dist/cjs/order/api/mutations/useUpdateOrderCustomFieldMutation.js +15 -0
- package/dist/cjs/order/hooks/index.js +15 -0
- package/dist/cjs/order/hooks/useUpdateOrderCustomField.js +9 -0
- package/dist/cjs/product/api/keys.js +11 -0
- package/dist/cjs/product/api/queries/index.js +37 -0
- package/dist/cjs/product/api/queries/useBnpOffersQuery.js +64 -0
- package/dist/cjs/product/hooks/index.js +37 -0
- package/dist/cjs/product/hooks/useBnpOffers.js +89 -0
- package/dist/cjs/product/index.js +15 -0
- package/dist/cjs/seo/components/GlobalSEO/index.js +3 -3
- package/dist/cjs/user/api/queries/index.js +15 -0
- package/dist/cjs/user/api/queries/useGetMyLoyaltyCardQuery.js +21 -0
- package/dist/cjs/user/api/utils/getUserToken.js +16 -0
- package/dist/cjs/user/api/utils/index.js +12 -0
- package/dist/cjs/user/hooks/index.js +24 -0
- package/dist/cjs/user/hooks/useGetMyLoyaltyCard.js +9 -0
- package/dist/cjs/user/hooks/useGetUserToken.js +15 -0
- package/dist/esm/analytics/Pixel/hooks/usePixelProductClick.js +1 -1
- package/dist/esm/analytics/Pixel/hooks/usePixelProductDetails.js +1 -1
- package/dist/esm/analytics/Pixel/hooks/usePixelProductsImpression.js +1 -1
- package/dist/esm/analytics/Pixel/mainScript.js +0 -1
- package/dist/esm/analytics/Pixel/usePixel.js +1 -1
- package/dist/esm/analytics/Releva/useReleva.js +1 -1
- package/dist/esm/analytics/addToCart.js +0 -1
- package/dist/esm/analytics/initiateCheckout.js +0 -1
- package/dist/esm/analytics/pageView.js +1 -1
- package/dist/esm/analytics/viewContent.js +0 -1
- package/dist/esm/api/myCartApi/index.js +2 -1
- package/dist/esm/api.v2/core/checkout/payments/useSetMerchantPaymentMethod.js +1 -1
- package/dist/esm/basket/api/index.js +1 -0
- package/dist/esm/basket/api/mutations/index.js +1 -0
- package/dist/esm/basket/api/mutations/useReplaceBasketMutation.js +48 -0
- package/dist/esm/basket/hooks/index.js +2 -0
- package/dist/esm/basket/hooks/useBasketCrossSaleItems.js +67 -0
- package/dist/esm/basket/hooks/useReplaceBasket.js +2 -0
- package/dist/esm/basket/index.js +1 -0
- package/dist/esm/checkout/api/keys.js +6 -0
- package/dist/esm/checkout/api/queries/index.js +1 -0
- package/dist/esm/checkout/api/queries/useBnpCalculateForCartQuery.js +50 -0
- package/dist/esm/checkout/hooks/index.js +1 -0
- package/dist/esm/checkout/hooks/useBnpCalculateForCart.js +92 -0
- package/dist/esm/components/GoogleOneTap/index.js +1 -1
- package/dist/esm/components/Html/index.js +1 -1
- package/dist/esm/components/Portal/index.js +1 -1
- package/dist/esm/contexts/CheckoutForm/hooks/usePayment/index.js +7 -2
- package/dist/esm/contexts/CheckoutForm/index.js +5 -3
- package/dist/esm/hooks/ui-hooks/useIsDesktop/index.js +2 -2
- package/dist/esm/hooks/useAllSelectedFilters/index.js +4 -4
- package/dist/esm/hooks/useLineItem/index.js +2 -0
- package/dist/esm/hooks/usePrice/index.js +1 -1
- package/dist/esm/hooks/useProduct/index.js +27 -6
- package/dist/esm/hooks/useProduct/utils/index.js +13 -0
- package/dist/esm/hooks/useProgressBar/hooks/useGetSetState.js +1 -1
- package/dist/esm/hooks/useSelectedFilters/index.js +4 -4
- package/dist/esm/hooks/useVouchers/index.js +1 -2
- package/dist/esm/index.js +4 -0
- package/dist/esm/listing/api/queries/useAggregateQuery.js +47 -12
- package/dist/esm/listing/api/queries/useInfiniteListing.js +4 -4
- package/dist/esm/listing/api/queries/useListingQuery.js +37 -22
- package/dist/esm/listing/api/queries/usePredicate.js +4 -4
- package/dist/esm/listing/components/BasicListingSEO.js +1 -1
- package/dist/esm/listing/hooks/useListingAlias.js +2 -4
- package/dist/esm/listing/hooks/useListingBreadcrumbs.js +5 -5
- package/dist/esm/listing/hooks/useListingCategories.js +8 -9
- package/dist/esm/listing/hooks/useListingConfig.js +5 -6
- package/dist/esm/listing/hooks/useListingFilters.js +19 -20
- package/dist/esm/listing/hooks/useListingItems.js +2 -2
- package/dist/esm/listing/hooks/useListingMeta.js +6 -5
- package/dist/esm/listing/hooks/useListingPagination.js +4 -4
- package/dist/esm/listing/hooks/useListingSlug.js +3 -1
- package/dist/esm/listing/hooks/useSlideFilter.js +5 -4
- package/dist/esm/listing/hooks/utils.js +2 -1
- package/dist/esm/listing/ssr/prefetchListing.js +4 -4
- package/dist/esm/listing/types.js +7 -0
- package/dist/esm/listing/utils/buildCategoryQuery.js +16 -12
- package/dist/esm/listing/utils/buildFilterQuery.js +5 -7
- package/dist/esm/listing/utils/getListingAlias.js +5 -6
- package/dist/esm/listing/utils/getListingPageType.js +4 -3
- package/dist/esm/navigation/components/SearchBox/Components/Container/index.js +1 -1
- package/dist/esm/navigation/components/SearchBox/Components/EmptyBox/index.js +19 -18
- package/dist/esm/navigation/components/SearchBox/Components/PopularSearches/index.js +1 -1
- package/dist/esm/navigation/components/SearchBox/Components/Products/Components/ProductCard/index.js +1 -1
- package/dist/esm/navigation/components/SearchBox/Components/Products/index.js +2 -2
- package/dist/esm/navigation/components/SearchBox/Components/RecentSearches/index.js +1 -1
- package/dist/esm/navigation/components/SearchBox/index.js +11 -11
- package/dist/esm/order/api/mutations/index.js +1 -0
- package/dist/esm/order/api/mutations/useUpdateOrderCustomFieldMutation.js +10 -0
- package/dist/esm/order/hooks/index.js +1 -0
- package/dist/esm/order/hooks/useUpdateOrderCustomField.js +4 -0
- package/dist/esm/product/api/keys.js +6 -0
- package/dist/esm/product/api/queries/index.js +1 -0
- package/dist/esm/product/api/queries/useBnpOffersQuery.js +54 -0
- package/dist/esm/product/hooks/index.js +1 -0
- package/dist/esm/product/hooks/useBnpOffers.js +84 -0
- package/dist/esm/product/index.js +1 -0
- package/dist/esm/seo/components/GlobalSEO/index.js +3 -3
- package/dist/esm/user/api/queries/index.js +1 -0
- package/dist/esm/user/api/queries/useGetMyLoyaltyCardQuery.js +16 -0
- package/dist/esm/user/api/utils/getUserToken.js +6 -0
- package/dist/esm/user/api/utils/index.js +1 -0
- package/dist/esm/user/hooks/index.js +2 -0
- package/dist/esm/user/hooks/useGetMyLoyaltyCard.js +4 -0
- package/dist/esm/user/hooks/useGetUserToken.js +5 -0
- package/dist/types/api/myCartApi/index.d.ts +1 -0
- package/dist/types/basket/api/index.d.ts +1 -0
- package/dist/types/basket/api/mutations/index.d.ts +1 -0
- package/dist/types/basket/api/mutations/useReplaceBasketMutation.d.ts +2 -0
- package/dist/types/basket/hooks/index.d.ts +2 -0
- package/dist/types/basket/hooks/useBasketCrossSaleItems.d.ts +9 -0
- package/dist/types/basket/hooks/useReplaceBasket.d.ts +2 -0
- package/dist/types/basket/index.d.ts +1 -0
- package/dist/types/checkout/api/keys.d.ts +1 -0
- package/dist/types/checkout/api/queries/index.d.ts +1 -0
- package/dist/types/checkout/api/queries/useBnpCalculateForCartQuery.d.ts +4 -0
- package/dist/types/checkout/hooks/index.d.ts +1 -0
- package/dist/types/checkout/hooks/useBnpCalculateForCart.d.ts +39 -0
- package/dist/types/contexts/CheckoutForm/hooks/usePayment/index.d.ts +2 -0
- package/dist/types/contexts/CheckoutForm/index.d.ts +2 -1
- package/dist/types/hooks/order-hooks/useReferralOrders/index.d.ts +1 -0
- package/dist/types/hooks/useLineItem/index.d.ts +2 -2
- package/dist/types/hooks/useProduct/index.d.ts +1 -0
- package/dist/types/hooks/useProduct/utils/index.d.ts +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/listing/api/queries/useAggregateQuery.d.ts +6 -4
- package/dist/types/listing/api/queries/useListingQuery.d.ts +4 -2
- package/dist/types/listing/api/queries/usePredicate.d.ts +2 -1
- package/dist/types/listing/hooks/useListingAlias.d.ts +2 -1
- package/dist/types/listing/hooks/useListingFilters.d.ts +0 -1
- package/dist/types/listing/hooks/useListingItems.d.ts +3 -2
- package/dist/types/listing/hooks/useListingSEOCategories.d.ts +6 -4
- package/dist/types/listing/hooks/utils.d.ts +3 -2
- package/dist/types/listing/ssr/prefetchCategories.d.ts +2 -2
- package/dist/types/listing/ssr/prefetchListing.d.ts +4 -4
- package/dist/types/listing/ssr/prefetchPredicate.d.ts +2 -1
- package/dist/types/listing/types.d.ts +32 -16
- package/dist/types/listing/utils/buildCategoryQuery.d.ts +2 -1
- package/dist/types/listing/utils/buildFilterQuery.d.ts +2 -1
- package/dist/types/listing/utils/extendFilter.d.ts +3 -2
- package/dist/types/listing/utils/getListingAlias.d.ts +2 -1
- package/dist/types/listing/utils/getListingPageType.d.ts +2 -2
- package/dist/types/navigation/components/SearchBox/Components/Container/index.d.ts +10 -9
- package/dist/types/navigation/components/SearchBox/Components/EmptyBox/index.d.ts +22 -21
- package/dist/types/navigation/components/SearchBox/Components/Products/Components/ProductCard/index.d.ts +8 -7
- package/dist/types/navigation/components/SearchBox/Components/Products/index.d.ts +9 -8
- package/dist/types/navigation/components/SearchBox/index.d.ts +31 -30
- package/dist/types/order/api/mutations/index.d.ts +1 -0
- package/dist/types/order/api/mutations/useUpdateCustomLineItemMutation.d.ts +2 -5
- package/dist/types/order/api/mutations/useUpdateOrderCustomFieldMutation.d.ts +9 -0
- package/dist/types/order/hooks/index.d.ts +1 -0
- package/dist/types/order/hooks/useUpdateCustomLineItem.d.ts +2 -2
- package/dist/types/order/hooks/useUpdateOrderCustomField.d.ts +2 -0
- package/dist/types/product/api/keys.d.ts +1 -0
- package/dist/types/product/api/queries/index.d.ts +1 -0
- package/dist/types/product/api/queries/useBnpOffersQuery.d.ts +5 -0
- package/dist/types/product/hooks/index.d.ts +1 -0
- package/dist/types/product/hooks/useBnpOffers.d.ts +37 -0
- package/dist/types/product/index.d.ts +1 -0
- package/dist/types/types/index.d.ts +38 -40
- package/dist/types/user/api/queries/index.d.ts +1 -0
- package/dist/types/user/api/queries/useGetMyLoyaltyCardQuery.d.ts +5 -0
- package/dist/types/user/api/utils/getUserToken.d.ts +1 -0
- package/dist/types/user/api/utils/index.d.ts +1 -0
- package/dist/types/user/hooks/index.d.ts +2 -0
- package/dist/types/user/hooks/useGetMyLoyaltyCard.d.ts +2 -0
- package/dist/types/user/hooks/useGetUserToken.d.ts +1 -0
- package/dist/types/utils/getSelectedFilters.d.ts +2 -1
- package/package.json +19 -13
@@ -109,9 +109,10 @@ export function CheckoutFormContextProvider(param) {
|
|
109
109
|
'email',
|
110
110
|
'phoneNumber',
|
111
111
|
] : _requiredFieldsOnShippingStep, _requiredFieldsOnBillingAddressStep = param.requiredFieldsOnBillingAddressStep, requiredFieldsOnBillingAddressStep = _requiredFieldsOnBillingAddressStep === void 0 ? [
|
112
|
-
'
|
113
|
-
'
|
114
|
-
'
|
112
|
+
'vatId',
|
113
|
+
'companyId',
|
114
|
+
'companyPerson',
|
115
|
+
'companyName',
|
115
116
|
] : _requiredFieldsOnBillingAddressStep, _enableNoShippingMethodMode = param.enableNoShippingMethodMode, enableNoShippingMethodMode = _enableNoShippingMethodMode === void 0 ? false : _enableNoShippingMethodMode, _disablePaymentRedirects = param.disablePaymentRedirects, disablePaymentRedirects = _disablePaymentRedirects === void 0 ? false : _disablePaymentRedirects;
|
116
117
|
var orderQuery = myCartApi.useGet();
|
117
118
|
var ref4 = _slicedToArray(useState(null), 2), boricaData = ref4[0], setBoricaData = ref4[1];
|
@@ -253,6 +254,7 @@ export function CheckoutFormContextProvider(param) {
|
|
253
254
|
setIsBillingSubmitting: billingState.updateIsSubmitting,
|
254
255
|
isPaymentValid: paymentState.isValid,
|
255
256
|
setIsPaymentSubmitting: paymentState.updateIsSubmitting,
|
257
|
+
loanInfo: paymentState.loanInfo,
|
256
258
|
step: step,
|
257
259
|
updateStep: setStep,
|
258
260
|
saveOrder: handleCheckoutSubmit,
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { useConfigState } from '../../useConfig';
|
2
2
|
export var useIsDesktop = function() {
|
3
|
-
var ref;
|
3
|
+
var ref, ref1, ref2, ref3, ref4;
|
4
4
|
var config = useConfigState();
|
5
|
-
return typeof document !== 'undefined' && document.body.clientWidth > Number((ref = config.theme.breakpoints) === null ||
|
5
|
+
return typeof document !== 'undefined' && document.body.clientWidth > Number((ref = config) === null || ref === void 0 ? void 0 : (ref1 = ref.theme) === null || ref1 === void 0 ? void 0 : (ref2 = ref1.breakpoints) === null || ref2 === void 0 ? void 0 : (ref3 = ref2.lg) === null || ref3 === void 0 ? void 0 : (ref4 = ref3.min) === null || ref4 === void 0 ? void 0 : ref4.split('px')[0]);
|
6
6
|
};
|
@@ -1,14 +1,14 @@
|
|
1
1
|
import { useMemo } from 'react';
|
2
2
|
import { useRouter } from 'next/router';
|
3
3
|
import { getSelectedFilters } from '../../utils';
|
4
|
-
import { useListingAlias,
|
4
|
+
import { useListingAlias, useListingConfig } from '../../index';
|
5
5
|
export var useAllSelectedFilters = function(aggregations) {
|
6
6
|
var router = useRouter();
|
7
|
-
var
|
8
|
-
var slug = useListingAlias().slug;
|
7
|
+
var meta = useListingConfig().meta;
|
8
|
+
var slug = useListingAlias(meta).slug;
|
9
9
|
return useMemo(function() {
|
10
10
|
return (aggregations === null || aggregations === void 0 ? void 0 : aggregations.reduce(function(items, filter) {
|
11
|
-
return items.concat(getSelectedFilters(router, slug, filter,
|
11
|
+
return items.concat(getSelectedFilters(router, slug, filter, meta));
|
12
12
|
}, [])) || [];
|
13
13
|
}, [
|
14
14
|
aggregations,
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import React from 'react';
|
2
|
+
import { OfferDTOStatusEnum } from '@sentecacommerce/sdk';
|
2
3
|
import { getTranslatableField } from '../../utils';
|
3
4
|
import { usePrefetchProduct } from '../usePrefetchProduct';
|
4
5
|
function _defineProperty(obj, key, value) {
|
@@ -30,6 +31,7 @@ function _objectSpread(target) {
|
|
30
31
|
}
|
31
32
|
return target;
|
32
33
|
}
|
34
|
+
export { OfferDTOStatusEnum };
|
33
35
|
export var useLineItem = function(props) {
|
34
36
|
var ref16 = usePrefetchProduct(getTranslatableField(props === null || props === void 0 ? void 0 : props.slug)), onMouseEnter = ref16.onMouseEnter, onMouseLeave = ref16.onMouseLeave, onMouseDown = ref16.onMouseDown;
|
35
37
|
var data = React.useMemo(function() {
|
@@ -9,7 +9,7 @@ import { useConfigState } from '../useConfig';
|
|
9
9
|
*/ export var usePrice = function(param) {
|
10
10
|
var price = param.price, discountedPrice = param.discountedPrice;
|
11
11
|
var ref, ref1;
|
12
|
-
var configLocale = (ref = useConfigState()) === null || ref === void 0 ? void 0 : (ref1 = ref.price) === null || ref1 === void 0 ? void 0 : ref1.locale;
|
12
|
+
var configLocale = ((ref = useConfigState()) === null || ref === void 0 ? void 0 : (ref1 = ref.price) === null || ref1 === void 0 ? void 0 : ref1.locale) || '';
|
13
13
|
var precision = (price === null || price === void 0 ? void 0 : price.fractionDigits) || 2;
|
14
14
|
var currency = (price === null || price === void 0 ? void 0 : price.currencyCode) || 'BGN' // to be replaced with interface currencyCode
|
15
15
|
;
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import { AssetSourceDTO } from '@sentecacommerce/sdk';
|
3
3
|
import { getTranslatableField } from '../../';
|
4
|
-
import { assignCombinationsToAttributeRules, createCombinationsMap, createCustomFieldsMap, createProductContent, createAttributeRulesMap, createMappedAttributes, processAvailabilityPerStore, getProductVideos, createMappedOptions, createSelectedOption2, formatCategories, createLabelsMap } from './utils';
|
4
|
+
import { assignCombinationsToAttributeRules, createCombinationsMap, createCustomFieldsMap, createProductContent, createAttributeRulesMap, createMappedAttributes, processAvailabilityPerStore, getProductVideos, createMappedOptions, createSelectedOption2, formatCategories, createLabelsMap, createCollapseKeyImagesMap } from './utils';
|
5
5
|
import { productsApi } from '../../api/productsApi';
|
6
6
|
import { assetsFieldsToMap } from '../../utils/assetsToMap';
|
7
7
|
function _arrayWithHoles(arr) {
|
@@ -152,12 +152,31 @@ export function ProductProvider(param) {
|
|
152
152
|
};
|
153
153
|
var selectVariantByAttribute = function selectVariantByAttribute(key) {
|
154
154
|
var ref;
|
155
|
-
|
156
|
-
|
155
|
+
// Get by collapseKey for SD
|
156
|
+
var split = key.split(':');
|
157
|
+
if (split[0] === 'collapseKey') {
|
158
|
+
var id = Object.keys(variants).find(function(el) {
|
159
|
+
return variants[el].collapseKey === split[1];
|
160
|
+
});
|
161
|
+
return setSelectedVariant(variants[id]);
|
162
|
+
}
|
163
|
+
var id1 = (ref = combinations[key]) === null || ref === void 0 ? void 0 : ref.value;
|
164
|
+
setSelectedVariant(variants[id1]);
|
157
165
|
};
|
158
166
|
var selectVariantByCombination = function selectVariantByCombination(key, value) {
|
159
|
-
|
160
|
-
|
167
|
+
// Take collapseKey for SD
|
168
|
+
var split = value.split(':');
|
169
|
+
if (split[0] === 'collapseKey') {
|
170
|
+
var id = Object.keys(variants).find(function(el) {
|
171
|
+
var ref;
|
172
|
+
return variants[el].collapseKey === split[1] && ((ref = variants[el].attributes.find(function(attr) {
|
173
|
+
return attr.name === 'size';
|
174
|
+
})) === null || ref === void 0 ? void 0 : ref.value) === key;
|
175
|
+
});
|
176
|
+
return setSelectedVariant(variants[id]);
|
177
|
+
}
|
178
|
+
var id2 = combinations[key].params[value];
|
179
|
+
setSelectedVariant(variants[id2]);
|
161
180
|
};
|
162
181
|
var selectVariantOptions = function selectVariantOptions(definitionKey, optionKey) {
|
163
182
|
if (selectedVariant) {
|
@@ -296,12 +315,14 @@ export function ProductProvider(param) {
|
|
296
315
|
}, [
|
297
316
|
variants
|
298
317
|
]);
|
318
|
+
var collapsedImages = createCollapseKeyImagesMap(product);
|
299
319
|
var state = {
|
300
320
|
metaData: metaData,
|
301
321
|
seoData: seoData,
|
302
322
|
variants: variants,
|
303
323
|
selectedVariant: selectedVariant,
|
304
|
-
attributeRules: attributeRules
|
324
|
+
attributeRules: attributeRules,
|
325
|
+
collapsedImages: collapsedImages
|
305
326
|
};
|
306
327
|
var functions = {
|
307
328
|
getVariantById: getVariantById,
|
@@ -118,6 +118,19 @@ export var createProductContent = function(data) {
|
|
118
118
|
content: getTranslatableField(data.content)
|
119
119
|
};
|
120
120
|
};
|
121
|
+
// Add grouped images for SD color variants
|
122
|
+
export var createCollapseKeyImagesMap = function(product) {
|
123
|
+
var ref;
|
124
|
+
var mappedKeys = product === null || product === void 0 ? void 0 : (ref = product.variants) === null || ref === void 0 ? void 0 : ref.reduce(function(res, cur) {
|
125
|
+
if (!res[cur.collapseKey]) {
|
126
|
+
res[cur.collapseKey] = [];
|
127
|
+
}
|
128
|
+
res[cur.collapseKey].push(cur);
|
129
|
+
return res;
|
130
|
+
}, {
|
131
|
+
});
|
132
|
+
return mappedKeys;
|
133
|
+
};
|
121
134
|
export var createAttributeRulesMap = function(product) {
|
122
135
|
var ref, ref1;
|
123
136
|
var uniqueRules = product === null || product === void 0 ? void 0 : (ref = product.attributeRules) === null || ref === void 0 ? void 0 : ref.filter(function(x) {
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import { useRouter } from 'next/router';
|
2
2
|
import { getSelectedFilters } from '../../utils';
|
3
|
-
import { useListingAlias,
|
3
|
+
import { useListingAlias, useListingConfig } from '../../index';
|
4
4
|
export var useSelectedFilters = function(filters) {
|
5
5
|
var router = useRouter();
|
6
|
-
var
|
7
|
-
var slug = useListingAlias().slug;
|
8
|
-
return getSelectedFilters(router, slug, filters,
|
6
|
+
var meta = useListingConfig().meta;
|
7
|
+
var slug = useListingAlias(meta).slug;
|
8
|
+
return getSelectedFilters(router, slug, filters, meta);
|
9
9
|
};
|
@@ -10,8 +10,7 @@ function mapVoucherData(element) {
|
|
10
10
|
var limitValue = element.cartDiscounts[0].resource.maxDiscountValue.centAmount;
|
11
11
|
var limitCurrency = element.cartDiscounts[0].resource.maxDiscountValue.currencyCode;
|
12
12
|
var endDate = new Date(element.validTo).toLocaleDateString('bg-BG');
|
13
|
-
var isUsed =
|
14
|
-
element.totalApplications >= element.maxApplicationsPerCustomer;
|
13
|
+
var isUsed = element.totalApplications >= ((element === null || element === void 0 ? void 0 : element.maxApplicationsPerCustomer) || 1);
|
15
14
|
return {
|
16
15
|
voucherCode: voucherCode,
|
17
16
|
campaign: campaign,
|
package/dist/esm/index.js
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
import Cookie from 'js-cookie';
|
2
|
+
export { Cookie };
|
1
3
|
export * from './dto';
|
2
4
|
// API
|
3
5
|
// export * from './api/myCart'
|
@@ -120,6 +122,8 @@ export * from './navigation';
|
|
120
122
|
export * from './GDPR';
|
121
123
|
// User
|
122
124
|
export * from './user';
|
125
|
+
// Basket
|
126
|
+
export * from './basket';
|
123
127
|
// UI Components and hooks
|
124
128
|
export * from './ui';
|
125
129
|
export * from './wishlist';
|
@@ -7,7 +7,7 @@ import { useListingAlias } from '../../hooks';
|
|
7
7
|
import { ListingTypesEnum } from '../../types';
|
8
8
|
import { getListingPageType, buildCategoryQuery, buildFilterQuery } from '../../utils';
|
9
9
|
import { canUseDOM } from '../../../utils';
|
10
|
-
import {
|
10
|
+
import { useListingConfig } from '../..';
|
11
11
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
12
12
|
try {
|
13
13
|
var info = gen[key](arg);
|
@@ -37,6 +37,35 @@ function _asyncToGenerator(fn) {
|
|
37
37
|
});
|
38
38
|
};
|
39
39
|
}
|
40
|
+
function _defineProperty(obj, key, value) {
|
41
|
+
if (key in obj) {
|
42
|
+
Object.defineProperty(obj, key, {
|
43
|
+
value: value,
|
44
|
+
enumerable: true,
|
45
|
+
configurable: true,
|
46
|
+
writable: true
|
47
|
+
});
|
48
|
+
} else {
|
49
|
+
obj[key] = value;
|
50
|
+
}
|
51
|
+
return obj;
|
52
|
+
}
|
53
|
+
function _objectSpread(target) {
|
54
|
+
for(var i = 1; i < arguments.length; i++){
|
55
|
+
var source = arguments[i] != null ? arguments[i] : {
|
56
|
+
};
|
57
|
+
var ownKeys = Object.keys(source);
|
58
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
59
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
60
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
61
|
+
}));
|
62
|
+
}
|
63
|
+
ownKeys.forEach(function(key) {
|
64
|
+
_defineProperty(target, key, source[key]);
|
65
|
+
});
|
66
|
+
}
|
67
|
+
return target;
|
68
|
+
}
|
40
69
|
var AggregateRequestEnum1;
|
41
70
|
export { AggregateRequestEnum1 as AggregateRequestEnum, };
|
42
71
|
(function(AggregateRequestEnum) {
|
@@ -44,14 +73,14 @@ export { AggregateRequestEnum1 as AggregateRequestEnum, };
|
|
44
73
|
AggregateRequestEnum["Categories"] = 'categories';
|
45
74
|
})(AggregateRequestEnum1 || (AggregateRequestEnum1 = {
|
46
75
|
}));
|
47
|
-
export var useAggregateQuery = function(aggregates, request) {
|
76
|
+
export var useAggregateQuery = function(aggregates, request, sort) {
|
48
77
|
var router = useRouter();
|
49
78
|
var ref = usePredicate(), predicate = ref.data;
|
50
|
-
var
|
79
|
+
var meta = useListingConfig().meta;
|
51
80
|
var postFilter = getPostFilters(router);
|
52
81
|
var aggregateKeys = generateAggregateKey(aggregates);
|
53
82
|
var predicateId = predicate === null || predicate === void 0 ? void 0 : predicate._id;
|
54
|
-
var ref1 = useListingAlias(), aliasedSlug = ref1.slug;
|
83
|
+
var ref1 = useListingAlias(meta), aliasedSlug = ref1.slug;
|
55
84
|
var queryKeys = [
|
56
85
|
request.toString(),
|
57
86
|
aggregateKeys,
|
@@ -76,14 +105,20 @@ export var useAggregateQuery = function(aggregates, request) {
|
|
76
105
|
router: router,
|
77
106
|
postFilter: postFilter,
|
78
107
|
slug: aliasedSlug,
|
79
|
-
config:
|
108
|
+
config: meta
|
80
109
|
});
|
81
|
-
|
110
|
+
if (sort) {
|
111
|
+
query = _objectSpread({
|
112
|
+
}, query, {
|
113
|
+
attributeSortType: sort
|
114
|
+
});
|
115
|
+
}
|
116
|
+
_ctx.next = 6;
|
82
117
|
return CatalogAggregate(query);
|
83
|
-
case
|
118
|
+
case 6:
|
84
119
|
response = _ctx.sent;
|
85
120
|
return _ctx.abrupt("return", response);
|
86
|
-
case
|
121
|
+
case 8:
|
87
122
|
case "end":
|
88
123
|
return _ctx.stop();
|
89
124
|
}
|
@@ -91,13 +126,13 @@ export var useAggregateQuery = function(aggregates, request) {
|
|
91
126
|
})), {
|
92
127
|
refetchOnMount: false,
|
93
128
|
refetchOnWindowFocus: false,
|
94
|
-
enabled: isQueryEnabled(router, aliasedSlug, predicateId,
|
129
|
+
enabled: isQueryEnabled(router, aliasedSlug, predicateId, meta),
|
95
130
|
keepPreviousData: true,
|
96
131
|
staleTime: 30000
|
97
132
|
});
|
98
133
|
};
|
99
134
|
export function prepareAggregateQuery(param) {
|
100
|
-
var request = param.request, predicate = param.predicate, aggregates = param.aggregates, router = param.router, postFilter = param.postFilter, slug = param.slug, config = param.config;
|
135
|
+
var request = param.request, predicate = param.predicate, aggregates = param.aggregates, router = param.router, postFilter = param.postFilter, slug = param.slug, config = param.config, attributeSortType = param.attributeSortType;
|
101
136
|
var pageType = getListingPageType(router, slug, config);
|
102
137
|
switch(request){
|
103
138
|
case AggregateRequestEnum1.Categories:
|
@@ -133,8 +168,8 @@ function getPostFilters(router) {
|
|
133
168
|
var query = router.query;
|
134
169
|
return query && Array.isArray(query.filter) ? query === null || query === void 0 ? void 0 : (ref = query.filter) === null || ref === void 0 ? void 0 : ref.join('&') : query === null || query === void 0 ? void 0 : query.filter;
|
135
170
|
}
|
136
|
-
function isQueryEnabled(router, slug, predicate,
|
137
|
-
var pageType = getListingPageType(router, slug,
|
171
|
+
function isQueryEnabled(router, slug, predicate, meta) {
|
172
|
+
var pageType = getListingPageType(router, slug, meta);
|
138
173
|
if (pageType === ListingTypesEnum.Search) {
|
139
174
|
return canUseDOM();
|
140
175
|
}
|
@@ -71,8 +71,8 @@ export var useInfiniteListing = function() {
|
|
71
71
|
var config = useListingConfig();
|
72
72
|
var ref3 = usePredicate(), predicate = ref3.data;
|
73
73
|
var query = router.query;
|
74
|
-
var ref1 = useListingAlias(), aliasedSlug = ref1.slug;
|
75
|
-
var limit = config.
|
74
|
+
var ref1 = useListingAlias(config.meta), aliasedSlug = ref1.slug;
|
75
|
+
var limit = config.meta.limit || 24;
|
76
76
|
var postFilter = getPostFilters(router);
|
77
77
|
var ref2;
|
78
78
|
var queryKeys = getListingQueryKeys({
|
@@ -95,11 +95,11 @@ export var useInfiniteListing = function() {
|
|
95
95
|
data = processListingQuery({
|
96
96
|
predicate: predicate,
|
97
97
|
limit: limit,
|
98
|
-
sort: config === null || config === void 0 ? void 0 : config.defaultSortKey,
|
98
|
+
sort: (config === null || config === void 0 ? void 0 : config.defaultSortKey) || 'defaultSort',
|
99
99
|
router: router,
|
100
100
|
postFilter: postFilter,
|
101
101
|
offset: offset,
|
102
|
-
config: config,
|
102
|
+
config: config.meta,
|
103
103
|
slug: aliasedSlug
|
104
104
|
});
|
105
105
|
return _ctx.abrupt("return", data);
|
@@ -6,7 +6,6 @@ import { useListingConfig, useListingSlug, useListingAlias } from '../../hooks';
|
|
6
6
|
import { getListingQueryKeys, usePredicate } from '..';
|
7
7
|
import { ListingTypesEnum } from '../../types';
|
8
8
|
import { calculateOffset, getListingPageType, getPostFilters, extendFilter } from '../../utils';
|
9
|
-
import { useConfigState } from '../../..';
|
10
9
|
function _arrayWithHoles(arr) {
|
11
10
|
if (Array.isArray(arr)) return arr;
|
12
11
|
}
|
@@ -97,46 +96,47 @@ function _slicedToArray(arr, i) {
|
|
97
96
|
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
|
98
97
|
}
|
99
98
|
export var useListingQuery = function() {
|
100
|
-
var ref
|
99
|
+
var ref;
|
101
100
|
var router = useRouter();
|
102
101
|
var slug = useListingSlug();
|
103
102
|
var config = useListingConfig();
|
104
|
-
var
|
105
|
-
var
|
106
|
-
var ref4 = useListingAlias(), aliasedSlug = ref4.slug;
|
103
|
+
var ref1 = usePredicate(), predicate = ref1.data;
|
104
|
+
var ref2 = useListingAlias(config.meta), aliasedSlug = ref2.slug;
|
107
105
|
var query = router.query;
|
108
106
|
var postFilter = getPostFilters(router);
|
109
|
-
var
|
110
|
-
var
|
111
|
-
var _sort, ref7;
|
112
|
-
var sort = (ref7 = (_sort = query.sort) !== null && _sort !== void 0 ? _sort : globalConfig === null || globalConfig === void 0 ? void 0 : (ref2 = globalConfig.listing) === null || ref2 === void 0 ? void 0 : ref2.defaultSortKey) !== null && ref7 !== void 0 ? ref7 : 'defaultSort';
|
107
|
+
var limit = Number((query === null || query === void 0 ? void 0 : query.limit) || (config === null || config === void 0 ? void 0 : (ref = config.meta) === null || ref === void 0 ? void 0 : ref.limit) || 24);
|
108
|
+
var sort = query.sort || (config === null || config === void 0 ? void 0 : config.defaultSortKey) || 'defaultSort';
|
113
109
|
var offset = calculateOffset(query === null || query === void 0 ? void 0 : query.page, limit);
|
114
|
-
var _sort1, ref8;
|
115
110
|
var queryKeys = getListingQueryKeys({
|
116
111
|
type: config.type,
|
117
112
|
predicate: predicate,
|
118
|
-
sort:
|
113
|
+
sort: sort,
|
119
114
|
postFilter: postFilter,
|
120
115
|
slug: slug,
|
121
116
|
offset: offset
|
122
117
|
});
|
118
|
+
console.log('useListingQuery', isListingQueryEnabled(config.type, predicate));
|
123
119
|
return useQuery(queryKeys, _asyncToGenerator(regeneratorRuntime.mark(function _callee() {
|
124
120
|
var data;
|
125
121
|
return regeneratorRuntime.wrap(function _callee$(_ctx) {
|
126
122
|
while(1)switch(_ctx.prev = _ctx.next){
|
127
123
|
case 0:
|
128
|
-
|
124
|
+
_ctx.next = 2;
|
125
|
+
return processListingQuery({
|
129
126
|
predicate: predicate,
|
130
127
|
limit: limit,
|
131
128
|
sort: sort,
|
132
129
|
router: router,
|
133
130
|
postFilter: postFilter,
|
134
131
|
offset: offset,
|
135
|
-
config:
|
132
|
+
config: config.meta,
|
136
133
|
slug: aliasedSlug
|
137
134
|
});
|
138
|
-
return _ctx.abrupt("return", data);
|
139
135
|
case 2:
|
136
|
+
data = _ctx.sent;
|
137
|
+
console.log('listing is Processed');
|
138
|
+
return _ctx.abrupt("return", data);
|
139
|
+
case 5:
|
140
140
|
case "end":
|
141
141
|
return _ctx.stop();
|
142
142
|
}
|
@@ -155,31 +155,46 @@ export function processListingQuery(_) {
|
|
155
155
|
}
|
156
156
|
function _processListingQuery() {
|
157
157
|
_processListingQuery = _asyncToGenerator(regeneratorRuntime.mark(function _callee(param) {
|
158
|
-
var predicate, router, limit, sort, postFilter, offset, config, slug,
|
158
|
+
var predicate, router, limit, sort, postFilter, offset, config, slug, query, type, filter, _sort, _sort1;
|
159
159
|
return regeneratorRuntime.wrap(function _callee$(_ctx) {
|
160
160
|
while(1)switch(_ctx.prev = _ctx.next){
|
161
161
|
case 0:
|
162
162
|
predicate = param.predicate, router = param.router, limit = param.limit, sort = param.sort, postFilter = param.postFilter, offset = param.offset, config = param.config, slug = param.slug;
|
163
|
-
;
|
163
|
+
console.log('processListingQuery');
|
164
164
|
query = router.query;
|
165
165
|
type = getListingPageType(router, slug, config);
|
166
166
|
filter = generateFilter(type, query, slug, predicate);
|
167
167
|
;
|
168
|
-
|
168
|
+
console.log(_objectSpread({
|
169
169
|
limit: limit,
|
170
170
|
offset: offset || 0,
|
171
171
|
filter: extendFilter({
|
172
172
|
slug: filter,
|
173
|
-
filterExtension: config === null || config === void 0 ? void 0 :
|
173
|
+
filterExtension: config === null || config === void 0 ? void 0 : config.filterExtension,
|
174
174
|
noSplit: true
|
175
175
|
}),
|
176
176
|
sort: (_sort = query.sort) !== null && _sort !== void 0 ? _sort : sort
|
177
177
|
}, (query === null || query === void 0 ? void 0 : query.filter) && {
|
178
178
|
postFilter: postFilter
|
179
|
-
}, (config === null || config === void 0 ? void 0 : config.
|
180
|
-
collapseMode: config === null || config === void 0 ? void 0 : config.
|
179
|
+
}, (config === null || config === void 0 ? void 0 : config.collapseMode) && type !== ListingTypesEnum.Collection && {
|
180
|
+
collapseMode: config === null || config === void 0 ? void 0 : config.collapseMode
|
181
|
+
}));
|
182
|
+
;
|
183
|
+
return _ctx.abrupt("return", CatalogFilter(_objectSpread({
|
184
|
+
limit: limit,
|
185
|
+
offset: offset || 0,
|
186
|
+
filter: extendFilter({
|
187
|
+
slug: filter,
|
188
|
+
filterExtension: config === null || config === void 0 ? void 0 : config.filterExtension,
|
189
|
+
noSplit: true
|
190
|
+
}),
|
191
|
+
sort: (_sort1 = query.sort) !== null && _sort1 !== void 0 ? _sort1 : sort
|
192
|
+
}, (query === null || query === void 0 ? void 0 : query.filter) && {
|
193
|
+
postFilter: postFilter
|
194
|
+
}, (config === null || config === void 0 ? void 0 : config.collapseMode) && type !== ListingTypesEnum.Collection && {
|
195
|
+
collapseMode: config === null || config === void 0 ? void 0 : config.collapseMode
|
181
196
|
})));
|
182
|
-
case
|
197
|
+
case 9:
|
183
198
|
case "end":
|
184
199
|
return _ctx.stop();
|
185
200
|
}
|
@@ -212,6 +227,6 @@ export function isListingQueryEnabled(type, predicate) {
|
|
212
227
|
return false;
|
213
228
|
}
|
214
229
|
function parseAttribute(slug) {
|
215
|
-
var ref = _slicedToArray(slug.split('-'), 2), type = ref[0], val = ref[1];
|
230
|
+
var ref = _slicedToArray((slug === null || slug === void 0 ? void 0 : slug.split('-')) || [], 2), type = ref[0], val = ref[1];
|
216
231
|
return "attr.".concat(type, ";eq;\"").concat(val, "\"");
|
217
232
|
}
|
@@ -2,11 +2,11 @@ import regeneratorRuntime from "regenerator-runtime";
|
|
2
2
|
import { BrandsGetBySlug, CategoriesGetBySlug, ViewsGetBySlug, ProductsGetAttributeLabel, CollectionsGetBySlug } from '@sentecacommerce/sdk';
|
3
3
|
import { useQuery } from 'react-query';
|
4
4
|
import { useRouter } from 'next/router';
|
5
|
-
import { useConfigState } from '../../../index';
|
6
5
|
import { ListingTypesEnum } from '../../types';
|
7
6
|
import { ListingQueryKeysEnum } from '../';
|
8
7
|
import { getListingPageType } from '../../utils';
|
9
8
|
import { useListingSlug, useListingAlias } from '../../hooks';
|
9
|
+
import { useListingConfig } from '../..';
|
10
10
|
function _arrayWithHoles(arr) {
|
11
11
|
if (Array.isArray(arr)) return arr;
|
12
12
|
}
|
@@ -85,9 +85,9 @@ var getBySlugMap = (_obj = {
|
|
85
85
|
}, _defineProperty(_obj, ListingTypesEnum.Category, CategoriesGetBySlug), _defineProperty(_obj, ListingTypesEnum.View, ViewsGetBySlug), _defineProperty(_obj, ListingTypesEnum.Brand, BrandsGetBySlug), _defineProperty(_obj, ListingTypesEnum.Collection, CollectionsGetBySlug), _obj);
|
86
86
|
export var usePredicate = function() {
|
87
87
|
var slug = useListingSlug();
|
88
|
+
var meta = useListingConfig().meta;
|
88
89
|
var router = useRouter();
|
89
|
-
var
|
90
|
-
var ref = useListingAlias(), aliasedSlug = ref.slug;
|
90
|
+
var ref = useListingAlias(meta), aliasedSlug = ref.slug;
|
91
91
|
var attribute = router.query.cat && aliasedSlug;
|
92
92
|
return useQuery([
|
93
93
|
ListingQueryKeysEnum.usePredicate,
|
@@ -99,7 +99,7 @@ export var usePredicate = function() {
|
|
99
99
|
while(1)switch(_ctx.prev = _ctx.next){
|
100
100
|
case 0:
|
101
101
|
_ctx.next = 2;
|
102
|
-
return processPredicateRequest(slug, router, aliasedSlug,
|
102
|
+
return processPredicateRequest(slug, router, aliasedSlug, meta);
|
103
103
|
case 2:
|
104
104
|
data = _ctx.sent;
|
105
105
|
return _ctx.abrupt("return", data);
|
@@ -27,7 +27,7 @@ import { useListingMeta } from '../hooks';
|
|
27
27
|
}), /*#__PURE__*/ React.createElement(OpenGraph, {
|
28
28
|
title: formattedTitle,
|
29
29
|
type: "website",
|
30
|
-
image: image || topBanner || imagesConfig.fallbackImage,
|
30
|
+
image: image || topBanner || (imagesConfig === null || imagesConfig === void 0 ? void 0 : imagesConfig.fallbackImage) || '',
|
31
31
|
additionalProps: [
|
32
32
|
{
|
33
33
|
key: 'description',
|
@@ -1,12 +1,10 @@
|
|
1
1
|
import { getListingAlias } from '../utils';
|
2
|
-
import { useConfigState } from '../..';
|
3
2
|
import { useRouter } from 'next/router';
|
4
|
-
export var useListingAlias = function() {
|
3
|
+
export var useListingAlias = function(meta) {
|
5
4
|
var router = useRouter();
|
6
|
-
var config = useConfigState();
|
7
5
|
var slug = getListingAlias({
|
8
6
|
router: router,
|
9
|
-
config:
|
7
|
+
config: meta
|
10
8
|
});
|
11
9
|
return {
|
12
10
|
slug: slug
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
2
2
|
import { useRouter } from 'next/router';
|
3
3
|
import { usePredicate } from '../api';
|
4
4
|
import { useListingConfig } from './';
|
5
|
-
import {
|
5
|
+
import { useListingAlias } from '../../index';
|
6
6
|
import { typeToSuffix } from '../../utils/typeToSuffix';
|
7
7
|
import { getTranslatableField } from '../../utils/getTranslatableField';
|
8
8
|
import { ListingTypesEnum } from '..';
|
@@ -25,16 +25,16 @@ function _toConsumableArray(arr) {
|
|
25
25
|
}
|
26
26
|
var _instance;
|
27
27
|
export var useListingBreadcrumbs = function() {
|
28
|
-
var
|
28
|
+
var ref1 = usePredicate(), data = ref1.data, isLoading = ref1.isLoading;
|
29
29
|
var config = useListingConfig();
|
30
30
|
var router = useRouter();
|
31
|
-
var
|
32
|
-
var slug = useListingAlias().slug;
|
31
|
+
var slug = useListingAlias(config.meta).slug;
|
33
32
|
var result = React.useMemo(function() {
|
34
33
|
if (config.type === ListingTypesEnum.AttrPage) {
|
34
|
+
var ref;
|
35
35
|
return [
|
36
36
|
{
|
37
|
-
name:
|
37
|
+
name: (ref = config.meta) === null || ref === void 0 ? void 0 : ref.titleAliases[slug],
|
38
38
|
id: '',
|
39
39
|
link: "/".concat(router.query.slug, "/c")
|
40
40
|
},
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import { useRouter } from 'next/router';
|
3
3
|
import { useListingConfig } from './useListingConfig';
|
4
|
-
import { useListingAlias
|
4
|
+
import { useListingAlias } from '../../index';
|
5
5
|
import { getTranslatableField, typeToSuffix } from '../../utils';
|
6
6
|
import { useAggregateQuery, AggregateRequestEnum } from '../api';
|
7
7
|
import { processCategoriesResponse, getAggregateTypeAndTerm } from './utils';
|
@@ -28,19 +28,18 @@ var ListingCategoriesStateContext = /*#__PURE__*/ React.createContext(undefined)
|
|
28
28
|
export function ListingCategoriesProvider(param) {
|
29
29
|
var children = param.children;
|
30
30
|
var router = useRouter();
|
31
|
-
var
|
32
|
-
var slug = useListingAlias().slug;
|
33
|
-
var
|
34
|
-
var ref = useAggregateQuery([
|
31
|
+
var ref = useListingConfig(), categoryTreeConfig = ref.categoryTreeConfig, meta = ref.meta;
|
32
|
+
var slug = useListingAlias(meta).slug;
|
33
|
+
var ref1 = useAggregateQuery([
|
35
34
|
categoryTreeConfig
|
36
|
-
], AggregateRequestEnum.Categories), aggData =
|
37
|
-
var currentCategory = generateCurrentUrl(router, slug,
|
38
|
-
var
|
35
|
+
], AggregateRequestEnum.Categories), aggData = ref1.data, isLoading = ref1.isLoading;
|
36
|
+
var currentCategory = generateCurrentUrl(router, slug, meta);
|
37
|
+
var ref2 = getAggregateTypeAndTerm(categoryTreeConfig), type = ref2.type, term = ref2.term;
|
39
38
|
var data = React.useMemo(function() {
|
40
39
|
if (aggData) {
|
41
40
|
var response = processCategoriesResponse(aggData, type, term);
|
42
41
|
var nodes = response.map(function(current) {
|
43
|
-
return buildNodes(current, router, slug,
|
42
|
+
return buildNodes(current, router, slug, meta);
|
44
43
|
});
|
45
44
|
var categoryTree = buildCategories(nodes);
|
46
45
|
return categoryTree;
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
2
2
|
import { useRouter } from 'next/router';
|
3
3
|
import { ListingFiltersProvider } from './useListingFilters';
|
4
4
|
import { ListingCategoriesProvider } from './useListingCategories';
|
5
|
-
import { useListingAlias
|
5
|
+
import { useListingAlias } from '../../index';
|
6
6
|
import { getListingPageType } from '../utils';
|
7
7
|
function _defineProperty(obj, key, value) {
|
8
8
|
if (key in obj) {
|
@@ -37,22 +37,21 @@ var ListingPageContext = /*#__PURE__*/ React.createContext(undefined);
|
|
37
37
|
export function ListingPageProvider(param) {
|
38
38
|
var config = param.config, children = param.children;
|
39
39
|
var router = useRouter();
|
40
|
-
var slug = useListingAlias().slug;
|
41
|
-
var mainConfig = useConfigState();
|
40
|
+
var slug = useListingAlias(config.meta).slug;
|
42
41
|
var data = React.useMemo(function() {
|
43
42
|
return _objectSpread({
|
44
43
|
}, config, {
|
45
|
-
type: getListingPageType(router, slug,
|
44
|
+
type: getListingPageType(router, slug, config.meta)
|
46
45
|
});
|
47
46
|
}, [
|
48
47
|
router.pathname,
|
49
48
|
config.aggregates,
|
50
49
|
config.categoryTreeConfig,
|
51
50
|
config.defaultSortKey,
|
52
|
-
config.productsPerPage,
|
53
51
|
config.seoAggregates,
|
54
52
|
config.sortOptions,
|
55
|
-
config.
|
53
|
+
config.meta,
|
54
|
+
config.attributeSortType,
|
56
55
|
]);
|
57
56
|
return(/*#__PURE__*/ React.createElement(ListingPageContext.Provider, {
|
58
57
|
value: data
|