feat(SW-497): Changed to siteConfig which includes Global Alert
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user