Files
web/utils/contactConfig.ts
2025-01-14 10:40:41 +01:00

24 lines
511 B
TypeScript

import type {
ContactConfig,
ContactFieldGroups,
} from "@/server/routers/contentstack/base/output"
export function getValueFromContactConfig(
data: ContactConfig,
keyString?: string | null
): string | undefined {
if (!keyString) {
return undefined
}
const [groupName, key] = keyString.split(".") as [
ContactFieldGroups,
keyof ContactConfig[ContactFieldGroups],
]
if (data[groupName]) {
const fieldGroup = data[groupName]
return fieldGroup[key]
}
return undefined
}