@propeller-commerce/propeller-v2-react-ui 0.4.28 → 0.4.29
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/CHANGELOG.md +13 -0
- package/dist/index.cjs +10 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +10 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2157,6 +2157,7 @@ function useProductSearch(options) {
|
|
|
2157
2157
|
);
|
|
2158
2158
|
const isLoading = !isControlled && internalLoading;
|
|
2159
2159
|
function filterByLanguage(products, lang) {
|
|
2160
|
+
if (!lang) return products;
|
|
2160
2161
|
return products.filter((p) => {
|
|
2161
2162
|
const names = p.names || p.names || [];
|
|
2162
2163
|
if (!names || names.length === 0) return true;
|
|
@@ -2418,9 +2419,12 @@ function useProductSearch(options) {
|
|
|
2418
2419
|
};
|
|
2419
2420
|
const response = await service.getCategory(variables);
|
|
2420
2421
|
const productsResponse = response?.products;
|
|
2421
|
-
const
|
|
2422
|
+
const rawItems = productsResponse?.items ?? [];
|
|
2423
|
+
const items = filterByLanguage(rawItems, language);
|
|
2424
|
+
const untranslated = rawItems.length - items.length;
|
|
2425
|
+
const apiTotal = productsResponse?.itemsFound ?? rawItems.length;
|
|
2422
2426
|
setSearchResults(items);
|
|
2423
|
-
setSearchItemsFound(
|
|
2427
|
+
setSearchItemsFound(Math.max(0, apiTotal - untranslated));
|
|
2424
2428
|
} catch {
|
|
2425
2429
|
setSearchResults([]);
|
|
2426
2430
|
setSearchItemsFound(0);
|
|
@@ -17207,7 +17211,7 @@ function RegisterForm(rawProps) {
|
|
|
17207
17211
|
] });
|
|
17208
17212
|
}
|
|
17209
17213
|
var RegisterForm_default = RegisterForm;
|
|
17210
|
-
function mapToSearchBarResult(item) {
|
|
17214
|
+
function mapToSearchBarResult(item, language) {
|
|
17211
17215
|
const isCluster = "clusterId" in item;
|
|
17212
17216
|
const displayItem = isCluster ? item.defaultProduct : item;
|
|
17213
17217
|
const id = isCluster ? item.clusterId : item.productId;
|
|
@@ -17215,9 +17219,10 @@ function mapToSearchBarResult(item) {
|
|
|
17215
17219
|
const url = isCluster ? "/cluster/" + id + "/" + slug : "/product/" + id + "/" + slug;
|
|
17216
17220
|
const priceNet = displayItem?.price?.net || 0;
|
|
17217
17221
|
const priceGross = displayItem?.price?.gross || 0;
|
|
17222
|
+
const localizedName = language && item.names?.find((n) => n.language === language)?.value || item.names?.[0]?.value || "Product";
|
|
17218
17223
|
return {
|
|
17219
17224
|
id,
|
|
17220
|
-
name:
|
|
17225
|
+
name: localizedName,
|
|
17221
17226
|
sku: item.sku || displayItem?.sku || "",
|
|
17222
17227
|
// `price` stays the gross value for back-compat; the row picks net/gross
|
|
17223
17228
|
// from the two explicit fields below per the toggle.
|
|
@@ -17244,7 +17249,7 @@ function SearchBar(rawProps) {
|
|
|
17244
17249
|
orderlistIds: props.orderlistIds,
|
|
17245
17250
|
applyOrderlists: props.applyOrderlists
|
|
17246
17251
|
});
|
|
17247
|
-
const results = searchResults.slice(0, maxResults).map((item) => mapToSearchBarResult(item));
|
|
17252
|
+
const results = searchResults.slice(0, maxResults).map((item) => mapToSearchBarResult(item, props.language));
|
|
17248
17253
|
const itemsFound = searchItemsFound;
|
|
17249
17254
|
function formatItemPrice(price) {
|
|
17250
17255
|
if (props.formatPrice) {
|