feat(SW-543): clean up

This commit is contained in:
Fredrik Thorsson
2025-01-02 13:07:02 +01:00
parent eab1386ee7
commit aee238761f
3 changed files with 8 additions and 9 deletions

View File

@@ -16,8 +16,10 @@ export default async function ContactRow({ contact }: ContactRowProps) {
return null
}
const val = getValueFromContactConfig(data, contact.contact_field)
const footnote = getValueFromContactConfig(data, contact.phoneFootnote)
const val = getValueFromContactConfig(contact.contact_field, data)
const footnote = contact.phoneFootnote
? getValueFromContactConfig(contact.phoneFootnote, data)
: null
if (!val) {
return null

View File

@@ -112,9 +112,9 @@ export function getAlertPhoneContactData(
return {
displayText,
phoneNumber: getValueFromContactConfig(contactConfig, phoneNumber),
phoneNumber: getValueFromContactConfig(phoneNumber, contactConfig),
footnote: footnote
? getValueFromContactConfig(contactConfig, footnote)
? getValueFromContactConfig(footnote, contactConfig)
: null,
}
}

View File

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