Function
categorySelectValue
(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 |
| 24 | export 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 | }; |
Tested by
no test coverage detected