Skip to content

Commit 23a364b

Browse files
committed
fix: include mapping_key in category parsing and improve parent category handling
1 parent c4f47c9 commit 23a364b

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/services/category.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ export class CategoryService {
2929
id: category.id,
3030
parent_id: category?.parent_id?.id || null,
3131
display_name: category.display_name,
32-
slug: category.slug
32+
slug: category.slug,
33+
mapping_key: category.mapping_key
3334
};
3435
});
3536

@@ -47,13 +48,20 @@ export class CategoryService {
4748
if (!parentCategory.children) {
4849
parentCategory.children = [];
4950
}
50-
parentCategory.children.push(category);
51+
const copyCategory = { ...category };
52+
delete copyCategory.parent_id;
53+
parentCategory.children.push(copyCategory);
5154
}
55+
} else {
56+
delete category.parent_id;
5257
}
53-
delete category.parent_id;
5458
});
5559

56-
allCategories = parsedCategories.filter(category => !category.parent_id);
60+
const finalCategories = parsedCategories.filter(category => !category.parent_id);
61+
62+
console.log('Setting category cache with', finalCategories.length, 'categories');
63+
64+
allCategories = finalCategories;
5765
}
5866

5967
// eslint-disable-next-line @typescript-eslint/no-explicit-any

0 commit comments

Comments
 (0)