refactor: infer types from zod validation
This commit is contained in:
@@ -1,18 +1,19 @@
|
||||
import {
|
||||
ContactConfig,
|
||||
ContactConfigField,
|
||||
ContactFieldGroups,
|
||||
} from "@/types/requests/contactConfig"
|
||||
|
||||
export function getValueFromContactConfig(
|
||||
keyStrings: ContactConfigField,
|
||||
keyString: string,
|
||||
data: ContactConfig
|
||||
): string | undefined {
|
||||
const [groupName, key] = keyStrings.split(".") as [
|
||||
const [groupName, key] = keyString.split(".") as [
|
||||
ContactFieldGroups,
|
||||
keyof ContactConfig[ContactFieldGroups],
|
||||
]
|
||||
const fieldGroup = data[groupName]
|
||||
if (data[groupName]) {
|
||||
const fieldGroup = data[groupName]
|
||||
|
||||
return fieldGroup[key]
|
||||
return fieldGroup[key]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user