This commit is contained in:
seb
2026-08-04 01:35:48 +02:00
parent dc956c4e60
commit 406684f4a2
2 changed files with 5 additions and 6 deletions

View File

@@ -53,7 +53,7 @@ export function resolveCategoryIdFromSlugPath(categories, rootCategoryId, slugPa
for (const slug of segments) { for (const slug of segments) {
const children = getCategoryChildren(categories, currentId); const children = getCategoryChildren(categories, currentId);
const match = children.find( const match = children.find(
(child) => categorySlug(child.name, child.id, rootCategoryId) === slug, (child) => categorySlug(child, rootCategoryId) === slug,
); );
if (!match) return null; if (!match) return null;
currentId = match.id; currentId = match.id;

View File

@@ -47,12 +47,11 @@ export function categoryDisplayName(name, categoryId, rootCategoryId) {
return name?.trim() || ''; return name?.trim() || '';
} }
export function categorySlug(name, categoryId, rootCategoryId) { export function categorySlug(node, rootCategoryId) {
if (rootCategoryId != null && String(categoryId) === String(rootCategoryId)) { if (rootCategoryId != null && String(node.id) === String(rootCategoryId)) {
return ROOT_CATEGORY_NAME; return ROOT_CATEGORY_NAME;
} }
const trimmed = name?.trim(); return node.slug || null;
return trimmed || null;
} }
export function normalizeCategoryMap(data, companyRootCategoryId) { export function normalizeCategoryMap(data, companyRootCategoryId) {
@@ -82,7 +81,7 @@ export function getCategoryBreadcrumbs(categories, currentCategoryId, rootCatego
crumbs.unshift({ crumbs.unshift({
id: node.id, id: node.id,
name: categoryDisplayName(node.name, node.id, rootCategoryId), name: categoryDisplayName(node.name, node.id, rootCategoryId),
slug: categorySlug(node.name, node.id, rootCategoryId), slug: categorySlug(node, rootCategoryId),
}); });
const parentId = node.parentId; const parentId = node.parentId;