@resira/ui 0.4.8 → 0.4.9
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/index.cjs +31 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +31 -13
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1894,18 +1894,28 @@ function groupProductsByCategory(products, resources) {
|
|
|
1894
1894
|
);
|
|
1895
1895
|
const groups = /* @__PURE__ */ new Map();
|
|
1896
1896
|
products.forEach((product) => {
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1897
|
+
const productCategory = product.category?.trim();
|
|
1898
|
+
let groupId;
|
|
1899
|
+
let label;
|
|
1900
|
+
let catImage;
|
|
1901
|
+
if (productCategory) {
|
|
1902
|
+
groupId = productCategory.toLowerCase();
|
|
1903
|
+
label = product.categoryName?.trim() ? product.categoryName.trim() : formatCategoryLabel(productCategory);
|
|
1904
|
+
catImage = product.categoryImage ?? void 0;
|
|
1905
|
+
} else {
|
|
1906
|
+
let categoryResource;
|
|
1907
|
+
const categoryType = product.equipmentIds.map((equipmentId) => {
|
|
1908
|
+
const res = resourceById.get(equipmentId);
|
|
1909
|
+
if (res?.resourceType?.trim() && !categoryResource) {
|
|
1910
|
+
categoryResource = res;
|
|
1911
|
+
}
|
|
1912
|
+
return res?.resourceType?.trim();
|
|
1913
|
+
}).find((resourceType) => Boolean(resourceType));
|
|
1914
|
+
groupId = categoryType?.toLowerCase() ?? UNCATEGORIZED_CATEGORY_KEY;
|
|
1915
|
+
label = categoryType ? formatCategoryLabel(categoryType) : UNCATEGORIZED_CATEGORY_LABEL;
|
|
1916
|
+
catImage = categoryResource?.images?.[0]?.url ?? categoryResource?.imageUrl ?? void 0;
|
|
1917
|
+
}
|
|
1907
1918
|
if (!groups.has(groupId)) {
|
|
1908
|
-
const catImage = categoryResource?.images?.[0]?.url ?? categoryResource?.imageUrl ?? void 0;
|
|
1909
1919
|
groups.set(groupId, {
|
|
1910
1920
|
id: groupId,
|
|
1911
1921
|
label,
|
|
@@ -1915,8 +1925,16 @@ function groupProductsByCategory(products, resources) {
|
|
|
1915
1925
|
}
|
|
1916
1926
|
const group = groups.get(groupId);
|
|
1917
1927
|
group.products.push(product);
|
|
1918
|
-
if (!group.imageUrl
|
|
1919
|
-
|
|
1928
|
+
if (!group.imageUrl) {
|
|
1929
|
+
if (catImage) {
|
|
1930
|
+
group.imageUrl = catImage;
|
|
1931
|
+
} else {
|
|
1932
|
+
const coverImage = product.images?.[0];
|
|
1933
|
+
const firstImage = (coverImage?.showInCategoryHeader !== false ? coverImage?.url : void 0) ?? product.imageUrl;
|
|
1934
|
+
if (firstImage) {
|
|
1935
|
+
group.imageUrl = firstImage;
|
|
1936
|
+
}
|
|
1937
|
+
}
|
|
1920
1938
|
}
|
|
1921
1939
|
});
|
|
1922
1940
|
return Array.from(groups.values());
|