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
+8 -8
View File
@@ -15,7 +15,7 @@ import { removeMultipleSlashes } from "@/utils/url"
import { systemSchema } from "../schemas/system"
import { Image } from "@/types/image"
import { GlobalAlertType } from "@/types/trpc/routers/contentstack/siteConfiguration"
import { GlobalAlertType } from "@/types/trpc/routers/contentstack/siteConfig"
// Help me write this zod schema based on the type ContactConfig
export const validateContactConfigSchema = z.object({
@@ -669,15 +669,15 @@ export const globalAlertSchema = z.object({
text: z.string(),
heading: z.string(),
phone_contact: z.object({
display_text: z.string(),
phone_number: z.string(),
footnote: z.string(),
display_text: z.string().nullable(),
phone_number: z.string().nullable(),
footnote: z.string().nullable(),
}),
})
export const siteConfigurationSchema = z
export const siteConfigSchema = z
.object({
all_site_configuration: z.object({
all_site_config: z.object({
items: z
.array(
z.object({
@@ -699,14 +699,14 @@ export const siteConfigurationSchema = z
}),
})
.transform((data) => {
if (!data.all_site_configuration.items.length) {
if (!data.all_site_config.items.length) {
return {
globalAlert: null,
bookingWidgetDisabled: false,
}
}
const { sitewide_alert } = data.all_site_configuration.items[0]
const { sitewide_alert } = data.all_site_config.items[0]
return {
globalAlert: sitewide_alert.alertConnection.edges[0]?.node || null,