feat(SW-497): Changed to siteConfig which includes Global Alert

This commit is contained in:
Erik Tiekstra
2024-10-03 11:29:26 +02:00
parent 78569fcb21
commit 3f12246e12
6 changed files with 166 additions and 120 deletions

View File

@@ -1,11 +1,13 @@
import type {
FooterLinkItem,
FooterRefDataRaw,
} from "@/types/components/footer/footer"
import { getValueFromContactConfig } from "@/utils/contactConfig"
import { ContactConfig } from "./output"
import type { FooterRefDataRaw } from "@/types/components/footer/footer"
import { System } from "@/types/requests/system"
import { Edges } from "@/types/requests/utils/edges"
import { NodeRefs } from "@/types/requests/utils/refs"
import type { HeaderRefs } from "@/types/trpc/routers/contentstack/header"
import { SiteConfig } from "@/types/trpc/routers/contentstack/siteConfig"
export function getConnections({ header }: HeaderRefs) {
const connections: System["system"][] = [header.system]
@@ -68,3 +70,23 @@ export function getFooterConnections(refs: FooterRefDataRaw) {
return connections
}
export function getGlobalAlertPhoneContactData(
globalAlert: SiteConfig["globalAlert"],
contactConfig: ContactConfig
) {
if (globalAlert?.phone_contact) {
const { display_text, phone_number, footnote } = globalAlert.phone_contact
return {
display_text,
phone: phone_number
? getValueFromContactConfig(phone_number, contactConfig)
: null,
footnote: footnote
? getValueFromContactConfig(footnote, contactConfig)
: null,
}
}
return null
}