MCPcopy Create free account
hub / github.com/Packstack-Tech/packstack / getItemsByCategory

Function getItemsByCategory

frontend/src/lib/utils/categories.ts:12–21  ·  view source on GitHub ↗
(items: (PackItem | Item)[])

Source from the content-addressed store, hash-verified

10};
11
12export const getItemsByCategory = (items: (PackItem | Item)[]): CategoryItems[] => {
13 const categories = getCategories(items);
14 return categories.map(category => {
15 const catItems = items.filter(i => i.categoryId === category.id);
16 return {
17 ...category,
18 items: catItems
19 }
20 });
21};
22
23// handles the weirdness between categories with IDs and those without Ids
24export const categorySelectValue = (categories: Category[], value: number | string | undefined): Option | undefined => {

Callers 1

getWeightByCategoryFunction · 0.90

Calls 1

getCategoriesFunction · 0.85

Tested by

no test coverage detected