feat(SW-543): clean up
This commit is contained in:
@@ -16,8 +16,10 @@ export default async function ContactRow({ contact }: ContactRowProps) {
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
const val = getValueFromContactConfig(data, contact.contact_field)
|
const val = getValueFromContactConfig(contact.contact_field, data)
|
||||||
const footnote = getValueFromContactConfig(data, contact.phoneFootnote)
|
const footnote = contact.phoneFootnote
|
||||||
|
? getValueFromContactConfig(contact.phoneFootnote, data)
|
||||||
|
: null
|
||||||
|
|
||||||
if (!val) {
|
if (!val) {
|
||||||
return null
|
return null
|
||||||
|
|||||||
@@ -112,9 +112,9 @@ export function getAlertPhoneContactData(
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
displayText,
|
displayText,
|
||||||
phoneNumber: getValueFromContactConfig(contactConfig, phoneNumber),
|
phoneNumber: getValueFromContactConfig(phoneNumber, contactConfig),
|
||||||
footnote: footnote
|
footnote: footnote
|
||||||
? getValueFromContactConfig(contactConfig, footnote)
|
? getValueFromContactConfig(footnote, contactConfig)
|
||||||
: null,
|
: null,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,12 +4,9 @@ import type {
|
|||||||
} from "@/server/routers/contentstack/base/output"
|
} from "@/server/routers/contentstack/base/output"
|
||||||
|
|
||||||
export function getValueFromContactConfig(
|
export function getValueFromContactConfig(
|
||||||
data: ContactConfig,
|
keyString: string,
|
||||||
keyString?: string | null
|
data: ContactConfig
|
||||||
): string | undefined {
|
): string | undefined {
|
||||||
if (!keyString) {
|
|
||||||
return undefined
|
|
||||||
}
|
|
||||||
const [groupName, key] = keyString.split(".") as [
|
const [groupName, key] = keyString.split(".") as [
|
||||||
ContactFieldGroups,
|
ContactFieldGroups,
|
||||||
keyof ContactConfig[ContactFieldGroups],
|
keyof ContactConfig[ContactFieldGroups],
|
||||||
|
|||||||
Reference in New Issue
Block a user