Merged in feat/SW-3232-site-config-alerts (pull request #2671)
feat(SW-3232): update alert schema * feat(SW-3232): update alert schema Approved-by: Erik Tiekstra
This commit is contained in:
@@ -5,7 +5,7 @@ import { useIntl } from "react-intl"
|
|||||||
|
|
||||||
import { BackToTopButton } from "@scandic-hotels/design-system/BackToTopButton"
|
import { BackToTopButton } from "@scandic-hotels/design-system/BackToTopButton"
|
||||||
import { Typography } from "@scandic-hotels/design-system/Typography"
|
import { Typography } from "@scandic-hotels/design-system/Typography"
|
||||||
import { AlertTypeEnum } from "@scandic-hotels/trpc/types/alertType"
|
import { AlertTypeEnum } from "@scandic-hotels/trpc/types/alert"
|
||||||
|
|
||||||
import { useDestinationDataStore } from "@/stores/destination-data"
|
import { useDestinationDataStore } from "@/stores/destination-data"
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
import { useIntl } from "react-intl"
|
import { useIntl } from "react-intl"
|
||||||
import { useMediaQuery } from "usehooks-ts"
|
import { useMediaQuery } from "usehooks-ts"
|
||||||
|
|
||||||
import { AlertTypeEnum } from "@scandic-hotels/trpc/types/alertType"
|
import { AlertTypeEnum } from "@scandic-hotels/trpc/types/alert"
|
||||||
|
|
||||||
import Alert from "@/components/TempDesignSystem/Alert"
|
import Alert from "@/components/TempDesignSystem/Alert"
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
import { useIntl } from "react-intl"
|
import { useIntl } from "react-intl"
|
||||||
|
|
||||||
import Body from "@scandic-hotels/design-system/Body"
|
import Body from "@scandic-hotels/design-system/Body"
|
||||||
import { AlertTypeEnum } from "@scandic-hotels/trpc/types/alertType"
|
import { AlertTypeEnum } from "@scandic-hotels/trpc/types/alert"
|
||||||
|
|
||||||
import { useDestinationDataStore } from "@/stores/destination-data"
|
import { useDestinationDataStore } from "@/stores/destination-data"
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import { BackToTopButton } from "@scandic-hotels/design-system/BackToTopButton"
|
|||||||
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
||||||
import { OldDSButton as Button } from "@scandic-hotels/design-system/OldDSButton"
|
import { OldDSButton as Button } from "@scandic-hotels/design-system/OldDSButton"
|
||||||
import { Typography } from "@scandic-hotels/design-system/Typography"
|
import { Typography } from "@scandic-hotels/design-system/Typography"
|
||||||
import { AlertTypeEnum } from "@scandic-hotels/trpc/types/alertType"
|
import { AlertTypeEnum } from "@scandic-hotels/trpc/types/alert"
|
||||||
|
|
||||||
import { useDestinationDataStore } from "@/stores/destination-data"
|
import { useDestinationDataStore } from "@/stores/destination-data"
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import Footnote from "@scandic-hotels/design-system/Footnote"
|
|||||||
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
||||||
import { OldDSButton as Button } from "@scandic-hotels/design-system/OldDSButton"
|
import { OldDSButton as Button } from "@scandic-hotels/design-system/OldDSButton"
|
||||||
import Subtitle from "@scandic-hotels/design-system/Subtitle"
|
import Subtitle from "@scandic-hotels/design-system/Subtitle"
|
||||||
import { AlertTypeEnum } from "@scandic-hotels/trpc/types/alertType"
|
import { AlertTypeEnum } from "@scandic-hotels/trpc/types/alert"
|
||||||
|
|
||||||
import { useDestinationDataStore } from "@/stores/destination-data"
|
import { useDestinationDataStore } from "@/stores/destination-data"
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import { Divider } from "@scandic-hotels/design-system/Divider"
|
|||||||
import { IconButton } from "@scandic-hotels/design-system/IconButton"
|
import { IconButton } from "@scandic-hotels/design-system/IconButton"
|
||||||
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
||||||
import { Typography } from "@scandic-hotels/design-system/Typography"
|
import { Typography } from "@scandic-hotels/design-system/Typography"
|
||||||
import { AlertTypeEnum } from "@scandic-hotels/trpc/types/alertType"
|
import { AlertTypeEnum } from "@scandic-hotels/trpc/types/alert"
|
||||||
|
|
||||||
import { useHotelListingDataStore } from "@/stores/hotel-listing-data"
|
import { useHotelListingDataStore } from "@/stores/hotel-listing-data"
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { notFound } from "next/navigation"
|
|||||||
|
|
||||||
import { dt } from "@scandic-hotels/common/dt"
|
import { dt } from "@scandic-hotels/common/dt"
|
||||||
import { Divider } from "@scandic-hotels/design-system/Divider"
|
import { Divider } from "@scandic-hotels/design-system/Divider"
|
||||||
import { AlertTypeEnum } from "@scandic-hotels/trpc/types/alertType"
|
import { AlertTypeEnum } from "@scandic-hotels/trpc/types/alert"
|
||||||
|
|
||||||
import { getBookingConfirmation } from "@/lib/trpc/memoizedRequests"
|
import { getBookingConfirmation } from "@/lib/trpc/memoizedRequests"
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { useIntl } from "react-intl"
|
|||||||
import { selectRate } from "@scandic-hotels/common/constants/routes/hotelReservation"
|
import { selectRate } from "@scandic-hotels/common/constants/routes/hotelReservation"
|
||||||
import useStickyPosition from "@scandic-hotels/common/hooks/useStickyPosition"
|
import useStickyPosition from "@scandic-hotels/common/hooks/useStickyPosition"
|
||||||
import { BookingErrorCodeEnum } from "@scandic-hotels/trpc/enums/bookingErrorCode"
|
import { BookingErrorCodeEnum } from "@scandic-hotels/trpc/enums/bookingErrorCode"
|
||||||
import { AlertTypeEnum } from "@scandic-hotels/trpc/types/alertType"
|
import { AlertTypeEnum } from "@scandic-hotels/trpc/types/alert"
|
||||||
|
|
||||||
import { useEnterDetailsStore } from "@/stores/enter-details"
|
import { useEnterDetailsStore } from "@/stores/enter-details"
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { AlertTypeEnum } from "@scandic-hotels/trpc/types/alertType"
|
import { AlertTypeEnum } from "@scandic-hotels/trpc/types/alert"
|
||||||
|
|
||||||
import Alert from "@/components/TempDesignSystem/Alert"
|
import Alert from "@/components/TempDesignSystem/Alert"
|
||||||
import { getIntl } from "@/i18n"
|
import { getIntl } from "@/i18n"
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import Checkbox from "@scandic-hotels/design-system/Form/Checkbox"
|
|||||||
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
||||||
import Link from "@scandic-hotels/design-system/Link"
|
import Link from "@scandic-hotels/design-system/Link"
|
||||||
import { Typography } from "@scandic-hotels/design-system/Typography"
|
import { Typography } from "@scandic-hotels/design-system/Typography"
|
||||||
import { AlertTypeEnum } from "@scandic-hotels/trpc/types/alertType"
|
import { AlertTypeEnum } from "@scandic-hotels/trpc/types/alert"
|
||||||
|
|
||||||
import { bookingTermsAndConditions, privacyPolicy } from "@/constants/webHrefs"
|
import { bookingTermsAndConditions, privacyPolicy } from "@/constants/webHrefs"
|
||||||
import { useAddAncillaryStore } from "@/stores/my-stay/add-ancillary-flow"
|
import { useAddAncillaryStore } from "@/stores/my-stay/add-ancillary-flow"
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import Body from "@scandic-hotels/design-system/Body"
|
|||||||
import { ErrorMessage } from "@scandic-hotels/design-system/Form/ErrorMessage"
|
import { ErrorMessage } from "@scandic-hotels/design-system/Form/ErrorMessage"
|
||||||
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
||||||
import { Typography } from "@scandic-hotels/design-system/Typography"
|
import { Typography } from "@scandic-hotels/design-system/Typography"
|
||||||
import { AlertTypeEnum } from "@scandic-hotels/trpc/types/alertType"
|
import { AlertTypeEnum } from "@scandic-hotels/trpc/types/alert"
|
||||||
|
|
||||||
import { useAddAncillaryStore } from "@/stores/my-stay/add-ancillary-flow"
|
import { useAddAncillaryStore } from "@/stores/my-stay/add-ancillary-flow"
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
"use client"
|
"use client"
|
||||||
import { useIntl } from "react-intl"
|
import { useIntl } from "react-intl"
|
||||||
|
|
||||||
import { AlertTypeEnum } from "@scandic-hotels/trpc/types/alertType"
|
import { AlertTypeEnum } from "@scandic-hotels/trpc/types/alert"
|
||||||
|
|
||||||
import { useMyStayStore } from "@/stores/my-stay"
|
import { useMyStayStore } from "@/stores/my-stay"
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
"use client"
|
"use client"
|
||||||
import { useIntl } from "react-intl"
|
import { useIntl } from "react-intl"
|
||||||
|
|
||||||
import { AlertTypeEnum } from "@scandic-hotels/trpc/types/alertType"
|
import { AlertTypeEnum } from "@scandic-hotels/trpc/types/alert"
|
||||||
|
|
||||||
import Modal from "@/components/HotelReservation/MyStay/Modal"
|
import Modal from "@/components/HotelReservation/MyStay/Modal"
|
||||||
import Alert from "@/components/TempDesignSystem/Alert"
|
import Alert from "@/components/TempDesignSystem/Alert"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
"use client"
|
"use client"
|
||||||
import { useIntl } from "react-intl"
|
import { useIntl } from "react-intl"
|
||||||
|
|
||||||
import { AlertTypeEnum } from "@scandic-hotels/trpc/types/alertType"
|
import { AlertTypeEnum } from "@scandic-hotels/trpc/types/alert"
|
||||||
|
|
||||||
import Modal from "@/components/HotelReservation/MyStay/Modal"
|
import Modal from "@/components/HotelReservation/MyStay/Modal"
|
||||||
import Alert from "@/components/TempDesignSystem/Alert"
|
import Alert from "@/components/TempDesignSystem/Alert"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
"use client"
|
"use client"
|
||||||
import { useIntl } from "react-intl"
|
import { useIntl } from "react-intl"
|
||||||
|
|
||||||
import { AlertTypeEnum } from "@scandic-hotels/trpc/types/alertType"
|
import { AlertTypeEnum } from "@scandic-hotels/trpc/types/alert"
|
||||||
|
|
||||||
import Modal from "@/components/HotelReservation/MyStay/Modal"
|
import Modal from "@/components/HotelReservation/MyStay/Modal"
|
||||||
import Alert from "@/components/TempDesignSystem/Alert"
|
import Alert from "@/components/TempDesignSystem/Alert"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
"use client"
|
"use client"
|
||||||
import { useIntl } from "react-intl"
|
import { useIntl } from "react-intl"
|
||||||
|
|
||||||
import { AlertTypeEnum } from "@scandic-hotels/trpc/types/alertType"
|
import { AlertTypeEnum } from "@scandic-hotels/trpc/types/alert"
|
||||||
|
|
||||||
import Alert from "@/components/TempDesignSystem/Alert"
|
import Alert from "@/components/TempDesignSystem/Alert"
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { alternativeHotels } from "@scandic-hotels/common/constants/routes/hotelReservation"
|
import { alternativeHotels } from "@scandic-hotels/common/constants/routes/hotelReservation"
|
||||||
import { AlertTypeEnum } from "@scandic-hotels/trpc/types/alertType"
|
import { AlertTypeEnum } from "@scandic-hotels/trpc/types/alert"
|
||||||
|
|
||||||
import Alert from "@/components/TempDesignSystem/Alert"
|
import Alert from "@/components/TempDesignSystem/Alert"
|
||||||
import { getIntl } from "@/i18n"
|
import { getIntl } from "@/i18n"
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { useIntl } from "react-intl"
|
|||||||
|
|
||||||
import { alternativeHotels } from "@scandic-hotels/common/constants/routes/hotelReservation"
|
import { alternativeHotels } from "@scandic-hotels/common/constants/routes/hotelReservation"
|
||||||
import { AvailabilityEnum } from "@scandic-hotels/trpc/enums/selectHotel"
|
import { AvailabilityEnum } from "@scandic-hotels/trpc/enums/selectHotel"
|
||||||
import { AlertTypeEnum } from "@scandic-hotels/trpc/types/alertType"
|
import { AlertTypeEnum } from "@scandic-hotels/trpc/types/alert"
|
||||||
|
|
||||||
import Alert from "@/components/TempDesignSystem/Alert"
|
import Alert from "@/components/TempDesignSystem/Alert"
|
||||||
import { useSelectRateContext } from "@/contexts/SelectRate/SelectRateContext"
|
import { useSelectRateContext } from "@/contexts/SelectRate/SelectRateContext"
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
import { TRPCClientError } from "@trpc/client"
|
import { TRPCClientError } from "@trpc/client"
|
||||||
import { useIntl } from "react-intl"
|
import { useIntl } from "react-intl"
|
||||||
|
|
||||||
import { AlertTypeEnum } from "@scandic-hotels/trpc/types/alertType"
|
import { AlertTypeEnum } from "@scandic-hotels/trpc/types/alert"
|
||||||
|
|
||||||
import Alert from "@/components/TempDesignSystem/Alert"
|
import Alert from "@/components/TempDesignSystem/Alert"
|
||||||
import { useSelectRateContext } from "@/contexts/SelectRate/SelectRateContext"
|
import { useSelectRateContext } from "@/contexts/SelectRate/SelectRateContext"
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
import { useRouter, useSearchParams } from "next/navigation"
|
import { useRouter, useSearchParams } from "next/navigation"
|
||||||
import { useIntl } from "react-intl"
|
import { useIntl } from "react-intl"
|
||||||
|
|
||||||
import { AlertTypeEnum } from "@scandic-hotels/trpc/types/alertType"
|
import { AlertTypeEnum } from "@scandic-hotels/trpc/types/alert"
|
||||||
|
|
||||||
import { DTMC_SUCCESS_BANNER_KEY } from "@/constants/dtmc"
|
import { DTMC_SUCCESS_BANNER_KEY } from "@/constants/dtmc"
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import useStickyPosition from "@scandic-hotels/common/hooks/useStickyPosition"
|
|||||||
import { StickyElementNameEnum } from "@scandic-hotels/common/stores/sticky-position"
|
import { StickyElementNameEnum } from "@scandic-hotels/common/stores/sticky-position"
|
||||||
import { debounce } from "@scandic-hotels/common/utils/debounce"
|
import { debounce } from "@scandic-hotels/common/utils/debounce"
|
||||||
import { trpc } from "@scandic-hotels/trpc/client"
|
import { trpc } from "@scandic-hotels/trpc/client"
|
||||||
import { AlertTypeEnum } from "@scandic-hotels/trpc/types/alertType"
|
import { AlertTypeEnum } from "@scandic-hotels/trpc/types/alert"
|
||||||
|
|
||||||
import Alert from "@/components/TempDesignSystem/Alert"
|
import Alert from "@/components/TempDesignSystem/Alert"
|
||||||
import useLang from "@/hooks/useLang"
|
import useLang from "@/hooks/useLang"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import type { AlertTypeEnum } from "@scandic-hotels/trpc/types/alertType"
|
import type { AlertTypeEnum } from "@scandic-hotels/trpc/types/alert"
|
||||||
import type { SidepeekContent } from "@scandic-hotels/trpc/types/siteConfig"
|
import type { SidepeekContent } from "@scandic-hotels/trpc/types/siteConfig"
|
||||||
import type { VariantProps } from "class-variance-authority"
|
import type { VariantProps } from "class-variance-authority"
|
||||||
import type { AriaRole } from "react"
|
import type { AriaRole } from "react"
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import {
|
|||||||
MaterialIcon,
|
MaterialIcon,
|
||||||
type MaterialIconSetIconProps,
|
type MaterialIconSetIconProps,
|
||||||
} from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
} from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
||||||
import { AlertTypeEnum } from "@scandic-hotels/trpc/types/alertType"
|
import { AlertTypeEnum } from "@scandic-hotels/trpc/types/alert"
|
||||||
|
|
||||||
import type { JSX } from "react"
|
import type { JSX } from "react"
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { cva } from "class-variance-authority"
|
import { cva } from "class-variance-authority"
|
||||||
|
|
||||||
import { AlertTypeEnum } from "@scandic-hotels/trpc/types/alertType"
|
import { AlertTypeEnum } from "@scandic-hotels/trpc/types/alert"
|
||||||
|
|
||||||
import styles from "./alert.module.css"
|
import styles from "./alert.module.css"
|
||||||
|
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ fragment Alert on Alert {
|
|||||||
json
|
json
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
visible_on
|
||||||
}
|
}
|
||||||
|
|
||||||
fragment AlertRef on Alert {
|
fragment AlertRef on Alert {
|
||||||
@@ -130,4 +131,5 @@ fragment AlertRef on Alert {
|
|||||||
system {
|
system {
|
||||||
...System
|
...System
|
||||||
}
|
}
|
||||||
|
visible_on
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ query GetSiteConfig($locale: String!) {
|
|||||||
all_site_config(limit: 1, locale: $locale) {
|
all_site_config(limit: 1, locale: $locale) {
|
||||||
items {
|
items {
|
||||||
sitewide_alert {
|
sitewide_alert {
|
||||||
|
alerts {
|
||||||
booking_widget_disabled
|
booking_widget_disabled
|
||||||
alertConnection {
|
alertConnection {
|
||||||
edges {
|
edges {
|
||||||
@@ -18,11 +19,13 @@ query GetSiteConfig($locale: String!) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
query GetSiteConfigRef($locale: String!) {
|
query GetSiteConfigRef($locale: String!) {
|
||||||
all_site_config(limit: 1, locale: $locale) {
|
all_site_config(limit: 1, locale: $locale) {
|
||||||
items {
|
items {
|
||||||
sitewide_alert {
|
sitewide_alert {
|
||||||
|
alerts {
|
||||||
alertConnection {
|
alertConnection {
|
||||||
edges {
|
edges {
|
||||||
node {
|
node {
|
||||||
@@ -31,6 +34,7 @@ query GetSiteConfigRef($locale: String!) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
system {
|
system {
|
||||||
...System
|
...System
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { Lang } from "@scandic-hotels/common/constants/language"
|
|||||||
import { logger } from "@scandic-hotels/common/logger"
|
import { logger } from "@scandic-hotels/common/logger"
|
||||||
import { removeMultipleSlashes } from "@scandic-hotels/common/utils/url"
|
import { removeMultipleSlashes } from "@scandic-hotels/common/utils/url"
|
||||||
|
|
||||||
import { AlertTypeEnum } from "../../../types/alertType"
|
import { AlertTypeEnum, AlertVisibleOnEnum } from "../../../types/alert"
|
||||||
import { discriminatedUnion } from "../../../utils/discriminatedUnion"
|
import { discriminatedUnion } from "../../../utils/discriminatedUnion"
|
||||||
import {
|
import {
|
||||||
cardBlockRefsSchema,
|
cardBlockRefsSchema,
|
||||||
@@ -744,6 +744,7 @@ export const alertSchema = z
|
|||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
|
visible_on: z.array(z.string()).nullable().default([]),
|
||||||
})
|
})
|
||||||
.transform(
|
.transform(
|
||||||
({
|
({
|
||||||
@@ -756,12 +757,14 @@ export const alertSchema = z
|
|||||||
has_sidepeek_button,
|
has_sidepeek_button,
|
||||||
sidepeek_button,
|
sidepeek_button,
|
||||||
sidepeek_content,
|
sidepeek_content,
|
||||||
|
visible_on,
|
||||||
}) => {
|
}) => {
|
||||||
const hasLink = has_link && link.link
|
const hasLink = has_link && link.link
|
||||||
return {
|
return {
|
||||||
type,
|
type,
|
||||||
text,
|
text,
|
||||||
heading,
|
heading,
|
||||||
|
visible_on,
|
||||||
phoneContact:
|
phoneContact:
|
||||||
phone_contact.display_text && phone_contact.phone_number
|
phone_contact.display_text && phone_contact.phone_number
|
||||||
? {
|
? {
|
||||||
@@ -792,16 +795,20 @@ export const siteConfigSchema = z
|
|||||||
.array(
|
.array(
|
||||||
z.object({
|
z.object({
|
||||||
sitewide_alert: z.object({
|
sitewide_alert: z.object({
|
||||||
|
alerts: z
|
||||||
|
.array(
|
||||||
|
z.object({
|
||||||
booking_widget_disabled: z.boolean(),
|
booking_widget_disabled: z.boolean(),
|
||||||
alertConnection: z.object({
|
alertConnection: z.object({
|
||||||
edges: z
|
edges: z.array(
|
||||||
.array(
|
|
||||||
z.object({
|
z.object({
|
||||||
node: alertSchema,
|
node: alertSchema,
|
||||||
})
|
})
|
||||||
)
|
),
|
||||||
.max(1),
|
|
||||||
}),
|
}),
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.nullable(),
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
@@ -818,9 +825,15 @@ export const siteConfigSchema = z
|
|||||||
|
|
||||||
const { sitewide_alert } = data.all_site_config.items[0]
|
const { sitewide_alert } = data.all_site_config.items[0]
|
||||||
|
|
||||||
|
const sitewideAlertWeb = sitewide_alert.alerts?.find((alert) =>
|
||||||
|
alert.alertConnection.edges[0]?.node.visible_on?.includes(
|
||||||
|
AlertVisibleOnEnum.WEB
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
sitewideAlert: sitewide_alert.alertConnection.edges[0]?.node || null,
|
sitewideAlert: sitewideAlertWeb?.alertConnection.edges[0]?.node || null,
|
||||||
bookingWidgetDisabled: sitewide_alert.booking_widget_disabled,
|
bookingWidgetDisabled: sitewideAlertWeb?.booking_widget_disabled,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -846,14 +859,28 @@ const alertConnectionRefSchema = z.object({
|
|||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
),
|
),
|
||||||
|
visible_on: z.array(z.string()).nullable().default([]),
|
||||||
})
|
})
|
||||||
|
|
||||||
export const siteConfigRefSchema = z.object({
|
export const siteConfigRefSchema = z.object({
|
||||||
all_site_config: z.object({
|
all_site_config: z.object({
|
||||||
items: z.array(
|
items: z.array(
|
||||||
z.object({
|
z.object({
|
||||||
sitewide_alert: z.object({
|
sitewide_alert: z
|
||||||
|
.object({
|
||||||
|
alerts: z
|
||||||
|
.array(
|
||||||
|
z.object({
|
||||||
alertConnection: alertConnectionRefSchema,
|
alertConnection: alertConnectionRefSchema,
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.nullable(),
|
||||||
|
})
|
||||||
|
.transform((data) => {
|
||||||
|
const sitewideAlertWeb = data.alerts?.find((alert) =>
|
||||||
|
alert.alertConnection.visible_on?.includes(AlertVisibleOnEnum.WEB)
|
||||||
|
)
|
||||||
|
return { alert: sitewideAlertWeb || null }
|
||||||
}),
|
}),
|
||||||
system: systemSchema,
|
system: systemSchema,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -82,9 +82,9 @@ export function getSiteConfigConnections(refs: GetSiteConfigRefData) {
|
|||||||
const siteConfigData = refs.all_site_config.items[0]
|
const siteConfigData = refs.all_site_config.items[0]
|
||||||
const connections: System["system"][] = []
|
const connections: System["system"][] = []
|
||||||
|
|
||||||
if (!siteConfigData) return connections
|
if (!siteConfigData.sitewide_alert.alert) return connections
|
||||||
|
|
||||||
const alertConnection = siteConfigData.sitewide_alert.alertConnection
|
const alertConnection = siteConfigData.sitewide_alert.alert.alertConnection
|
||||||
|
|
||||||
alertConnection.edges.forEach(({ node }) => {
|
alertConnection.edges.forEach(({ node }) => {
|
||||||
connections.push(node.system)
|
connections.push(node.system)
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { z } from "zod"
|
|||||||
import { dt } from "@scandic-hotels/common/dt"
|
import { dt } from "@scandic-hotels/common/dt"
|
||||||
import { nullableStringValidator } from "@scandic-hotels/common/utils/zod/stringValidator"
|
import { nullableStringValidator } from "@scandic-hotels/common/utils/zod/stringValidator"
|
||||||
|
|
||||||
import { AlertTypeEnum } from "../../../../types/alertType"
|
import { AlertTypeEnum } from "../../../../types/alert"
|
||||||
|
|
||||||
const specialAlertSchema = z.object({
|
const specialAlertSchema = z.object({
|
||||||
description: nullableStringValidator,
|
description: nullableStringValidator,
|
||||||
|
|||||||
@@ -4,3 +4,8 @@ export enum AlertTypeEnum {
|
|||||||
Alarm = "alarm",
|
Alarm = "alarm",
|
||||||
Success = "success",
|
Success = "success",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const AlertVisibleOnEnum = {
|
||||||
|
WEB: "WEB",
|
||||||
|
APP: "APP",
|
||||||
|
} as const
|
||||||
Reference in New Issue
Block a user