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

Function categorySelectValue

frontend/src/lib/utils/categories.ts:24–32  ·  view source on GitHub ↗
(categories: Category[], value: number | string | undefined)

Source from the content-addressed store, hash-verified

22
23// handles the weirdness between categories with IDs and those without Ids
24export const categorySelectValue = (categories: Category[], value: number | string | undefined): Option | undefined => {
25 if (!value) return;
26 const currentCategory = categories.find(cat => cat.id === value);
27
28 return {
29 value: currentCategory ? currentCategory.id : value,
30 label: currentCategory ? currentCategory.name : value.toString()
31 };
32};

Callers 2

ItemFormFunction · 0.90
ItemFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected