diff --git a/arches_vue_utils/src/arches_vue_utils/types.ts b/arches_vue_utils/src/arches_vue_utils/types.ts index 77fbde1..9a49008 100644 --- a/arches_vue_utils/src/arches_vue_utils/types.ts +++ b/arches_vue_utils/src/arches_vue_utils/types.ts @@ -22,3 +22,10 @@ export interface WithValues { } export type Labellable = WithLabels | WithValues; + +export interface Descriptors { + [key: string]: { + name: string; + description: string; + }; +} diff --git a/arches_vue_utils/src/arches_vue_utils/utils.ts b/arches_vue_utils/src/arches_vue_utils/utils.ts index f063c27..02ad322 100644 --- a/arches_vue_utils/src/arches_vue_utils/utils.ts +++ b/arches_vue_utils/src/arches_vue_utils/utils.ts @@ -1,6 +1,7 @@ import { ALT_LABEL, PREF_LABEL } from "@/arches_vue_utils/constants.ts"; import type { + Descriptors, Label, Labellable, WithLabels, @@ -66,3 +67,14 @@ export const getItemLabel = ( rankLabel(a, preferredLanguageCode, systemLanguageCode), )[0]; }; + +export const getDescriptors = ( + data: Descriptors, + systemLanguageCode: string, + ): [string, string] => { + if (!data) { + return ["None", "None"]; + } + const descriptors = data[systemLanguageCode]; + return [descriptors.name, descriptors.description]; +};