feat(SW-497): Changes to global alert schema

This commit is contained in:
Erik Tiekstra
2024-10-16 12:30:59 +02:00
parent 3f12246e12
commit c8d4f6c47c
8 changed files with 131 additions and 49 deletions

View File

@@ -7,7 +7,7 @@ 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"
import { Alert } from "@/types/trpc/routers/contentstack/siteConfig"
export function getConnections({ header }: HeaderRefs) {
const connections: System["system"][] = [header.system]
@@ -71,18 +71,16 @@ export function getFooterConnections(refs: FooterRefDataRaw) {
return connections
}
export function getGlobalAlertPhoneContactData(
globalAlert: SiteConfig["globalAlert"],
export function getAlertPhoneContactData(
alert: Alert,
contactConfig: ContactConfig
) {
if (globalAlert?.phone_contact) {
const { display_text, phone_number, footnote } = globalAlert.phone_contact
if (alert.phoneContact) {
const { displayText, phoneNumber, footnote } = alert.phoneContact
return {
display_text,
phone: phone_number
? getValueFromContactConfig(phone_number, contactConfig)
: null,
displayText,
phoneNumber: getValueFromContactConfig(phoneNumber, contactConfig),
footnote: footnote
? getValueFromContactConfig(footnote, contactConfig)
: null,