feat(SW-543): update contact config function
This commit is contained in:
@@ -16,8 +16,8 @@ export default async function ContactRow({ contact }: ContactRowProps) {
|
||||
return null
|
||||
}
|
||||
|
||||
const val = getValueFromContactConfig(contact.contact_field, data)
|
||||
const footnote = getValueFromContactConfig(contact.selectTest, data)
|
||||
const val = getValueFromContactConfig(data, contact.contact_field)
|
||||
const footnote = getValueFromContactConfig(data, contact.phoneFootnote)
|
||||
|
||||
if (!val) {
|
||||
return null
|
||||
@@ -54,7 +54,9 @@ export default async function ContactRow({ contact }: ContactRowProps) {
|
||||
{val}
|
||||
</Link>
|
||||
</div>
|
||||
{footnote && <Footnote color="burgundy">{footnote}</Footnote>}
|
||||
{footnote && contact.contact_field.includes("phone") && (
|
||||
<Footnote color="burgundy">{footnote}</Footnote>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -13,8 +13,7 @@
|
||||
fragment ContactFields on ContactFields {
|
||||
display_text
|
||||
contact_field
|
||||
footnote
|
||||
select_test
|
||||
phone_footnote
|
||||
}
|
||||
|
||||
fragment JoinLoyaltyContactSidebar_ContentPage on ContentPageSidebarJoinLoyaltyContact {
|
||||
|
||||
@@ -77,8 +77,7 @@ export type ContactConfig = ContactConfigData["all_contact_config"]["items"][0]
|
||||
export type ContactFields = {
|
||||
display_text: string | null
|
||||
contact_field: string
|
||||
footnote: string | null
|
||||
selectTest: string
|
||||
phoneFootnote?: string | null
|
||||
}
|
||||
|
||||
export const validateCurrentHeaderConfigSchema = z
|
||||
|
||||
@@ -112,9 +112,9 @@ export function getAlertPhoneContactData(
|
||||
|
||||
return {
|
||||
displayText,
|
||||
phoneNumber: getValueFromContactConfig(phoneNumber, contactConfig),
|
||||
phoneNumber: getValueFromContactConfig(contactConfig, phoneNumber),
|
||||
footnote: footnote
|
||||
? getValueFromContactConfig(footnote, contactConfig)
|
||||
? getValueFromContactConfig(contactConfig, footnote)
|
||||
: null,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,8 +22,7 @@ export const contactSchema = z.object({
|
||||
contact: z.object({
|
||||
contact_field: z.string(),
|
||||
display_text: z.string().optional().nullable().default(null),
|
||||
footnote: z.string().optional().nullable().default(null),
|
||||
select_test: z.string(),
|
||||
phone_footnote: z.string().optional().nullable(),
|
||||
}),
|
||||
})
|
||||
.transform((data) => {
|
||||
@@ -32,8 +31,7 @@ export const contactSchema = z.object({
|
||||
typename: data.typename,
|
||||
contact_field: data.contact.contact_field,
|
||||
display_text: data.contact.display_text,
|
||||
footnote: data.contact.footnote,
|
||||
selectTest: data.contact.select_test,
|
||||
phoneFootnote: data.contact.phone_footnote,
|
||||
}
|
||||
})
|
||||
),
|
||||
|
||||
@@ -4,9 +4,12 @@ import type {
|
||||
} from "@/server/routers/contentstack/base/output"
|
||||
|
||||
export function getValueFromContactConfig(
|
||||
keyString: string,
|
||||
data: ContactConfig
|
||||
data: ContactConfig,
|
||||
keyString?: string | null
|
||||
): string | undefined {
|
||||
if (!keyString) {
|
||||
return undefined
|
||||
}
|
||||
const [groupName, key] = keyString.split(".") as [
|
||||
ContactFieldGroups,
|
||||
keyof ContactConfig[ContactFieldGroups],
|
||||
|
||||
Reference in New Issue
Block a user