From aee238761f3ffbe84fc12749d89480c885e7a816 Mon Sep 17 00:00:00 2001 From: Fredrik Thorsson Date: Thu, 2 Jan 2025 13:07:02 +0100 Subject: [PATCH] feat(SW-543): clean up --- .../Sidebar/JoinLoyalty/Contact/ContactRow/index.tsx | 6 ++++-- server/routers/contentstack/base/utils.ts | 4 ++-- utils/contactConfig.ts | 7 ++----- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/components/Sidebar/JoinLoyalty/Contact/ContactRow/index.tsx b/components/Sidebar/JoinLoyalty/Contact/ContactRow/index.tsx index 936d75a01..58ffa8157 100644 --- a/components/Sidebar/JoinLoyalty/Contact/ContactRow/index.tsx +++ b/components/Sidebar/JoinLoyalty/Contact/ContactRow/index.tsx @@ -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 diff --git a/server/routers/contentstack/base/utils.ts b/server/routers/contentstack/base/utils.ts index 9afb71276..daf4575a0 100644 --- a/server/routers/contentstack/base/utils.ts +++ b/server/routers/contentstack/base/utils.ts @@ -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, } } diff --git a/utils/contactConfig.ts b/utils/contactConfig.ts index 2799c70bc..82930a03a 100644 --- a/utils/contactConfig.ts +++ b/utils/contactConfig.ts @@ -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],