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