From ccabe0177b12182e794d71be101b78657bd9f48a Mon Sep 17 00:00:00 2001 From: Munawwirul Jamal Date: Fri, 14 Nov 2025 16:39:21 +0700 Subject: [PATCH] dev: hotfix, added combobox objectsToItems --- app/components/pub/my-ui/combobox/index.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/components/pub/my-ui/combobox/index.ts b/app/components/pub/my-ui/combobox/index.ts index 82a3b3cd..e4864f7f 100644 --- a/app/components/pub/my-ui/combobox/index.ts +++ b/app/components/pub/my-ui/combobox/index.ts @@ -20,4 +20,17 @@ export function recStrToItem(input: Record): Item[] { return items } +export function objectsToItems(input: object[], key = 'id', label = 'name'): Item[] { + const items: Item[] = [] + for (const item of input) { + if (item.hasOwnProperty(key) && item.hasOwnProperty(label)) { + items.push({ + value: item[key as keyof typeof item], // the hasOwnProperty check should be enough + label: item[label as keyof typeof item], // the hasOwnProperty check should be enough + }) + } + } + return items +} + export { default as Combobox } from './combobox.vue'