From 7891ae3ae6610723caf2877d139d6873eea5c30c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matilda=20Landstr=C3=B6m?= Date: Wed, 20 Aug 2025 09:18:00 +0000 Subject: [PATCH] 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 --- .../DestinationPage/CityListing/index.tsx | 2 +- .../CityMap/HotelList/Content.tsx | 2 +- .../CountryMap/CityList/index.tsx | 2 +- .../DestinationPage/HotelListing/index.tsx | 2 +- .../DestinationFilterAndSort/index.tsx | 2 +- .../components/HotelFilterAndSort/index.tsx | 2 +- .../BookingConfirmation/index.tsx | 2 +- .../Payment/BookingAlert/index.tsx | 2 +- .../FnFNotAllowedAlert/FnFNotAllowedAlert.tsx | 2 +- .../Steps/ConfirmationStep/index.tsx | 2 +- .../Steps/SelectQuantityStep/index.tsx | 2 +- .../ManageStay/Actions/CancelStay/Alerts.tsx | 2 +- .../ChangeDates/Alerts/CannotChangeDate.tsx | 2 +- .../ChangeDates/Alerts/MultiRoomBooking.tsx | 2 +- .../ChangeDates/Alerts/NotMainRoom.tsx | 2 +- .../Steps/Form/Alerts/NoAvailability.tsx | 2 +- .../SelectHotel/NoAvailabilityAlert.tsx | 2 +- .../Rooms/NoAvailabilityAlert/index.tsx | 2 +- .../SelectRate/RoomsContainer/index.tsx | 2 +- .../DigitalTeamMemberCard/Alert/index.tsx | 2 +- .../components/SitewideAlert/index.tsx | 2 +- .../TempDesignSystem/Alert/alert.ts | 2 +- .../TempDesignSystem/Alert/utils.tsx | 2 +- .../TempDesignSystem/Alert/variants.ts | 2 +- .../trpc/lib/graphql/Fragments/Alert.graphql | 2 + .../trpc/lib/graphql/Query/SiteConfig.graphql | 22 ++++--- .../lib/routers/contentstack/base/output.ts | 59 ++++++++++++++----- .../lib/routers/contentstack/base/utils.ts | 4 +- .../hotels/schemas/hotel/specialAlerts.ts | 2 +- .../trpc/lib/types/{alertType.ts => alert.ts} | 5 ++ 30 files changed, 90 insertions(+), 52 deletions(-) rename packages/trpc/lib/types/{alertType.ts => alert.ts} (59%) diff --git a/apps/scandic-web/components/ContentType/DestinationPage/CityListing/index.tsx b/apps/scandic-web/components/ContentType/DestinationPage/CityListing/index.tsx index f8e9da87c..10cdf3ae0 100644 --- a/apps/scandic-web/components/ContentType/DestinationPage/CityListing/index.tsx +++ b/apps/scandic-web/components/ContentType/DestinationPage/CityListing/index.tsx @@ -5,7 +5,7 @@ import { useIntl } from "react-intl" import { BackToTopButton } from "@scandic-hotels/design-system/BackToTopButton" 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" diff --git a/apps/scandic-web/components/ContentType/DestinationPage/DestinationCityPage/CityMap/HotelList/Content.tsx b/apps/scandic-web/components/ContentType/DestinationPage/DestinationCityPage/CityMap/HotelList/Content.tsx index 6cab26005..7fac87c31 100644 --- a/apps/scandic-web/components/ContentType/DestinationPage/DestinationCityPage/CityMap/HotelList/Content.tsx +++ b/apps/scandic-web/components/ContentType/DestinationPage/DestinationCityPage/CityMap/HotelList/Content.tsx @@ -3,7 +3,7 @@ import { useIntl } from "react-intl" 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" diff --git a/apps/scandic-web/components/ContentType/DestinationPage/DestinationCountryPage/CountryMap/CityList/index.tsx b/apps/scandic-web/components/ContentType/DestinationPage/DestinationCountryPage/CountryMap/CityList/index.tsx index 39031c060..d4ea062d4 100644 --- a/apps/scandic-web/components/ContentType/DestinationPage/DestinationCountryPage/CountryMap/CityList/index.tsx +++ b/apps/scandic-web/components/ContentType/DestinationPage/DestinationCountryPage/CountryMap/CityList/index.tsx @@ -3,7 +3,7 @@ import { useIntl } from "react-intl" 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" diff --git a/apps/scandic-web/components/ContentType/DestinationPage/HotelListing/index.tsx b/apps/scandic-web/components/ContentType/DestinationPage/HotelListing/index.tsx index 9d5d5a2d1..2e5f1f9ea 100644 --- a/apps/scandic-web/components/ContentType/DestinationPage/HotelListing/index.tsx +++ b/apps/scandic-web/components/ContentType/DestinationPage/HotelListing/index.tsx @@ -9,7 +9,7 @@ import { BackToTopButton } from "@scandic-hotels/design-system/BackToTopButton" import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon" import { OldDSButton as Button } from "@scandic-hotels/design-system/OldDSButton" 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" diff --git a/apps/scandic-web/components/DestinationFilterAndSort/index.tsx b/apps/scandic-web/components/DestinationFilterAndSort/index.tsx index d45247283..93b2f5a3d 100644 --- a/apps/scandic-web/components/DestinationFilterAndSort/index.tsx +++ b/apps/scandic-web/components/DestinationFilterAndSort/index.tsx @@ -15,7 +15,7 @@ import Footnote from "@scandic-hotels/design-system/Footnote" import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon" import { OldDSButton as Button } from "@scandic-hotels/design-system/OldDSButton" 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" diff --git a/apps/scandic-web/components/HotelFilterAndSort/index.tsx b/apps/scandic-web/components/HotelFilterAndSort/index.tsx index 4e96660fa..33b054821 100644 --- a/apps/scandic-web/components/HotelFilterAndSort/index.tsx +++ b/apps/scandic-web/components/HotelFilterAndSort/index.tsx @@ -14,7 +14,7 @@ import { Divider } from "@scandic-hotels/design-system/Divider" import { IconButton } from "@scandic-hotels/design-system/IconButton" import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon" 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" diff --git a/apps/scandic-web/components/HotelReservation/BookingConfirmation/index.tsx b/apps/scandic-web/components/HotelReservation/BookingConfirmation/index.tsx index 85b198de2..512a0b1a5 100644 --- a/apps/scandic-web/components/HotelReservation/BookingConfirmation/index.tsx +++ b/apps/scandic-web/components/HotelReservation/BookingConfirmation/index.tsx @@ -2,7 +2,7 @@ import { notFound } from "next/navigation" import { dt } from "@scandic-hotels/common/dt" 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" diff --git a/apps/scandic-web/components/HotelReservation/EnterDetails/Payment/BookingAlert/index.tsx b/apps/scandic-web/components/HotelReservation/EnterDetails/Payment/BookingAlert/index.tsx index 15fadea19..cf3e7c0bf 100644 --- a/apps/scandic-web/components/HotelReservation/EnterDetails/Payment/BookingAlert/index.tsx +++ b/apps/scandic-web/components/HotelReservation/EnterDetails/Payment/BookingAlert/index.tsx @@ -7,7 +7,7 @@ import { useIntl } from "react-intl" import { selectRate } from "@scandic-hotels/common/constants/routes/hotelReservation" import useStickyPosition from "@scandic-hotels/common/hooks/useStickyPosition" 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" diff --git a/apps/scandic-web/components/HotelReservation/FnFNotAllowedAlert/FnFNotAllowedAlert.tsx b/apps/scandic-web/components/HotelReservation/FnFNotAllowedAlert/FnFNotAllowedAlert.tsx index f592381a1..e4b9ea67f 100644 --- a/apps/scandic-web/components/HotelReservation/FnFNotAllowedAlert/FnFNotAllowedAlert.tsx +++ b/apps/scandic-web/components/HotelReservation/FnFNotAllowedAlert/FnFNotAllowedAlert.tsx @@ -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 { getIntl } from "@/i18n" diff --git a/apps/scandic-web/components/HotelReservation/MyStay/Ancillaries/AddAncillaryFlow/AddAncillaryFlowModal/Steps/ConfirmationStep/index.tsx b/apps/scandic-web/components/HotelReservation/MyStay/Ancillaries/AddAncillaryFlow/AddAncillaryFlowModal/Steps/ConfirmationStep/index.tsx index 837a01b59..64a0535e8 100644 --- a/apps/scandic-web/components/HotelReservation/MyStay/Ancillaries/AddAncillaryFlow/AddAncillaryFlowModal/Steps/ConfirmationStep/index.tsx +++ b/apps/scandic-web/components/HotelReservation/MyStay/Ancillaries/AddAncillaryFlow/AddAncillaryFlowModal/Steps/ConfirmationStep/index.tsx @@ -7,7 +7,7 @@ import Checkbox from "@scandic-hotels/design-system/Form/Checkbox" import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon" import Link from "@scandic-hotels/design-system/Link" 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 { useAddAncillaryStore } from "@/stores/my-stay/add-ancillary-flow" diff --git a/apps/scandic-web/components/HotelReservation/MyStay/Ancillaries/AddAncillaryFlow/AddAncillaryFlowModal/Steps/SelectQuantityStep/index.tsx b/apps/scandic-web/components/HotelReservation/MyStay/Ancillaries/AddAncillaryFlow/AddAncillaryFlowModal/Steps/SelectQuantityStep/index.tsx index b018704e8..241fbf79a 100644 --- a/apps/scandic-web/components/HotelReservation/MyStay/Ancillaries/AddAncillaryFlow/AddAncillaryFlowModal/Steps/SelectQuantityStep/index.tsx +++ b/apps/scandic-web/components/HotelReservation/MyStay/Ancillaries/AddAncillaryFlow/AddAncillaryFlowModal/Steps/SelectQuantityStep/index.tsx @@ -5,7 +5,7 @@ import Body from "@scandic-hotels/design-system/Body" import { ErrorMessage } from "@scandic-hotels/design-system/Form/ErrorMessage" import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon" 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" diff --git a/apps/scandic-web/components/HotelReservation/MyStay/ReferenceCard/Actions/NotCancelled/ManageStay/Actions/CancelStay/Alerts.tsx b/apps/scandic-web/components/HotelReservation/MyStay/ReferenceCard/Actions/NotCancelled/ManageStay/Actions/CancelStay/Alerts.tsx index 70af51ccc..e2f9792c5 100644 --- a/apps/scandic-web/components/HotelReservation/MyStay/ReferenceCard/Actions/NotCancelled/ManageStay/Actions/CancelStay/Alerts.tsx +++ b/apps/scandic-web/components/HotelReservation/MyStay/ReferenceCard/Actions/NotCancelled/ManageStay/Actions/CancelStay/Alerts.tsx @@ -1,7 +1,7 @@ "use client" 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" diff --git a/apps/scandic-web/components/HotelReservation/MyStay/ReferenceCard/Actions/NotCancelled/ManageStay/Actions/ChangeDates/Alerts/CannotChangeDate.tsx b/apps/scandic-web/components/HotelReservation/MyStay/ReferenceCard/Actions/NotCancelled/ManageStay/Actions/ChangeDates/Alerts/CannotChangeDate.tsx index bf1445537..ba14dd3c4 100644 --- a/apps/scandic-web/components/HotelReservation/MyStay/ReferenceCard/Actions/NotCancelled/ManageStay/Actions/ChangeDates/Alerts/CannotChangeDate.tsx +++ b/apps/scandic-web/components/HotelReservation/MyStay/ReferenceCard/Actions/NotCancelled/ManageStay/Actions/ChangeDates/Alerts/CannotChangeDate.tsx @@ -1,7 +1,7 @@ "use client" 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 Alert from "@/components/TempDesignSystem/Alert" diff --git a/apps/scandic-web/components/HotelReservation/MyStay/ReferenceCard/Actions/NotCancelled/ManageStay/Actions/ChangeDates/Alerts/MultiRoomBooking.tsx b/apps/scandic-web/components/HotelReservation/MyStay/ReferenceCard/Actions/NotCancelled/ManageStay/Actions/ChangeDates/Alerts/MultiRoomBooking.tsx index 6dd7c289c..cde177682 100644 --- a/apps/scandic-web/components/HotelReservation/MyStay/ReferenceCard/Actions/NotCancelled/ManageStay/Actions/ChangeDates/Alerts/MultiRoomBooking.tsx +++ b/apps/scandic-web/components/HotelReservation/MyStay/ReferenceCard/Actions/NotCancelled/ManageStay/Actions/ChangeDates/Alerts/MultiRoomBooking.tsx @@ -1,7 +1,7 @@ "use client" 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 Alert from "@/components/TempDesignSystem/Alert" diff --git a/apps/scandic-web/components/HotelReservation/MyStay/ReferenceCard/Actions/NotCancelled/ManageStay/Actions/ChangeDates/Alerts/NotMainRoom.tsx b/apps/scandic-web/components/HotelReservation/MyStay/ReferenceCard/Actions/NotCancelled/ManageStay/Actions/ChangeDates/Alerts/NotMainRoom.tsx index 603fbf6ce..bca25b4fa 100644 --- a/apps/scandic-web/components/HotelReservation/MyStay/ReferenceCard/Actions/NotCancelled/ManageStay/Actions/ChangeDates/Alerts/NotMainRoom.tsx +++ b/apps/scandic-web/components/HotelReservation/MyStay/ReferenceCard/Actions/NotCancelled/ManageStay/Actions/ChangeDates/Alerts/NotMainRoom.tsx @@ -1,7 +1,7 @@ "use client" 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 Alert from "@/components/TempDesignSystem/Alert" diff --git a/apps/scandic-web/components/HotelReservation/MyStay/ReferenceCard/Actions/NotCancelled/ManageStay/Actions/ChangeDates/Steps/Form/Alerts/NoAvailability.tsx b/apps/scandic-web/components/HotelReservation/MyStay/ReferenceCard/Actions/NotCancelled/ManageStay/Actions/ChangeDates/Steps/Form/Alerts/NoAvailability.tsx index 47c9baa3f..5cb0c35a0 100644 --- a/apps/scandic-web/components/HotelReservation/MyStay/ReferenceCard/Actions/NotCancelled/ManageStay/Actions/ChangeDates/Steps/Form/Alerts/NoAvailability.tsx +++ b/apps/scandic-web/components/HotelReservation/MyStay/ReferenceCard/Actions/NotCancelled/ManageStay/Actions/ChangeDates/Steps/Form/Alerts/NoAvailability.tsx @@ -1,7 +1,7 @@ "use client" 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" diff --git a/apps/scandic-web/components/HotelReservation/SelectHotel/NoAvailabilityAlert.tsx b/apps/scandic-web/components/HotelReservation/SelectHotel/NoAvailabilityAlert.tsx index c90be8043..f1ff11e7f 100644 --- a/apps/scandic-web/components/HotelReservation/SelectHotel/NoAvailabilityAlert.tsx +++ b/apps/scandic-web/components/HotelReservation/SelectHotel/NoAvailabilityAlert.tsx @@ -1,5 +1,5 @@ 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 { getIntl } from "@/i18n" diff --git a/apps/scandic-web/components/HotelReservation/SelectRate/RoomsContainer/Rooms/NoAvailabilityAlert/index.tsx b/apps/scandic-web/components/HotelReservation/SelectRate/RoomsContainer/Rooms/NoAvailabilityAlert/index.tsx index 5bca5988d..6c80ed138 100644 --- a/apps/scandic-web/components/HotelReservation/SelectRate/RoomsContainer/Rooms/NoAvailabilityAlert/index.tsx +++ b/apps/scandic-web/components/HotelReservation/SelectRate/RoomsContainer/Rooms/NoAvailabilityAlert/index.tsx @@ -3,7 +3,7 @@ import { useIntl } from "react-intl" import { alternativeHotels } from "@scandic-hotels/common/constants/routes/hotelReservation" 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 { useSelectRateContext } from "@/contexts/SelectRate/SelectRateContext" diff --git a/apps/scandic-web/components/HotelReservation/SelectRate/RoomsContainer/index.tsx b/apps/scandic-web/components/HotelReservation/SelectRate/RoomsContainer/index.tsx index 4cd54f188..cea02e683 100644 --- a/apps/scandic-web/components/HotelReservation/SelectRate/RoomsContainer/index.tsx +++ b/apps/scandic-web/components/HotelReservation/SelectRate/RoomsContainer/index.tsx @@ -3,7 +3,7 @@ import { TRPCClientError } from "@trpc/client" 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 { useSelectRateContext } from "@/contexts/SelectRate/SelectRateContext" diff --git a/apps/scandic-web/components/MyPages/DigitalTeamMemberCard/Alert/index.tsx b/apps/scandic-web/components/MyPages/DigitalTeamMemberCard/Alert/index.tsx index 54f5854dd..ccbc49f35 100644 --- a/apps/scandic-web/components/MyPages/DigitalTeamMemberCard/Alert/index.tsx +++ b/apps/scandic-web/components/MyPages/DigitalTeamMemberCard/Alert/index.tsx @@ -3,7 +3,7 @@ import { useRouter, useSearchParams } from "next/navigation" 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" diff --git a/apps/scandic-web/components/SitewideAlert/index.tsx b/apps/scandic-web/components/SitewideAlert/index.tsx index fa8b941e9..bb5f1337b 100644 --- a/apps/scandic-web/components/SitewideAlert/index.tsx +++ b/apps/scandic-web/components/SitewideAlert/index.tsx @@ -6,7 +6,7 @@ import useStickyPosition from "@scandic-hotels/common/hooks/useStickyPosition" import { StickyElementNameEnum } from "@scandic-hotels/common/stores/sticky-position" import { debounce } from "@scandic-hotels/common/utils/debounce" 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 useLang from "@/hooks/useLang" diff --git a/apps/scandic-web/components/TempDesignSystem/Alert/alert.ts b/apps/scandic-web/components/TempDesignSystem/Alert/alert.ts index c04228b26..c2c946bcd 100644 --- a/apps/scandic-web/components/TempDesignSystem/Alert/alert.ts +++ b/apps/scandic-web/components/TempDesignSystem/Alert/alert.ts @@ -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 { VariantProps } from "class-variance-authority" import type { AriaRole } from "react" diff --git a/apps/scandic-web/components/TempDesignSystem/Alert/utils.tsx b/apps/scandic-web/components/TempDesignSystem/Alert/utils.tsx index 76076287d..858393735 100644 --- a/apps/scandic-web/components/TempDesignSystem/Alert/utils.tsx +++ b/apps/scandic-web/components/TempDesignSystem/Alert/utils.tsx @@ -2,7 +2,7 @@ import { MaterialIcon, type MaterialIconSetIconProps, } 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" diff --git a/apps/scandic-web/components/TempDesignSystem/Alert/variants.ts b/apps/scandic-web/components/TempDesignSystem/Alert/variants.ts index 1726bd0c6..e3f954790 100644 --- a/apps/scandic-web/components/TempDesignSystem/Alert/variants.ts +++ b/apps/scandic-web/components/TempDesignSystem/Alert/variants.ts @@ -1,6 +1,6 @@ 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" diff --git a/packages/trpc/lib/graphql/Fragments/Alert.graphql b/packages/trpc/lib/graphql/Fragments/Alert.graphql index 9b8b6f574..7162dcd05 100644 --- a/packages/trpc/lib/graphql/Fragments/Alert.graphql +++ b/packages/trpc/lib/graphql/Fragments/Alert.graphql @@ -81,6 +81,7 @@ fragment Alert on Alert { json } } + visible_on } fragment AlertRef on Alert { @@ -130,4 +131,5 @@ fragment AlertRef on Alert { system { ...System } + visible_on } diff --git a/packages/trpc/lib/graphql/Query/SiteConfig.graphql b/packages/trpc/lib/graphql/Query/SiteConfig.graphql index 4c21f5214..cd0760dbe 100644 --- a/packages/trpc/lib/graphql/Query/SiteConfig.graphql +++ b/packages/trpc/lib/graphql/Query/SiteConfig.graphql @@ -6,11 +6,13 @@ query GetSiteConfig($locale: String!) { all_site_config(limit: 1, locale: $locale) { items { sitewide_alert { - booking_widget_disabled - alertConnection { - edges { - node { - ...Alert + alerts { + booking_widget_disabled + alertConnection { + edges { + node { + ...Alert + } } } } @@ -23,10 +25,12 @@ query GetSiteConfigRef($locale: String!) { all_site_config(limit: 1, locale: $locale) { items { sitewide_alert { - alertConnection { - edges { - node { - ...AlertRef + alerts { + alertConnection { + edges { + node { + ...AlertRef + } } } } diff --git a/packages/trpc/lib/routers/contentstack/base/output.ts b/packages/trpc/lib/routers/contentstack/base/output.ts index 2291ecf11..a07809974 100644 --- a/packages/trpc/lib/routers/contentstack/base/output.ts +++ b/packages/trpc/lib/routers/contentstack/base/output.ts @@ -4,7 +4,7 @@ import { Lang } from "@scandic-hotels/common/constants/language" import { logger } from "@scandic-hotels/common/logger" 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 { cardBlockRefsSchema, @@ -744,6 +744,7 @@ export const alertSchema = z }), }), }), + visible_on: z.array(z.string()).nullable().default([]), }) .transform( ({ @@ -756,12 +757,14 @@ export const alertSchema = z has_sidepeek_button, sidepeek_button, sidepeek_content, + visible_on, }) => { const hasLink = has_link && link.link return { type, text, heading, + visible_on, phoneContact: phone_contact.display_text && phone_contact.phone_number ? { @@ -792,16 +795,20 @@ export const siteConfigSchema = z .array( z.object({ sitewide_alert: z.object({ - booking_widget_disabled: z.boolean(), - alertConnection: z.object({ - edges: z - .array( - z.object({ - node: alertSchema, - }) - ) - .max(1), - }), + alerts: z + .array( + z.object({ + booking_widget_disabled: z.boolean(), + alertConnection: z.object({ + edges: z.array( + z.object({ + node: alertSchema, + }) + ), + }), + }) + ) + .nullable(), }), }) ) @@ -818,9 +825,15 @@ export const siteConfigSchema = z 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 { - sitewideAlert: sitewide_alert.alertConnection.edges[0]?.node || null, - bookingWidgetDisabled: sitewide_alert.booking_widget_disabled, + sitewideAlert: sitewideAlertWeb?.alertConnection.edges[0]?.node || null, + bookingWidgetDisabled: sitewideAlertWeb?.booking_widget_disabled, } }) @@ -846,15 +859,29 @@ const alertConnectionRefSchema = z.object({ }), }) ), + visible_on: z.array(z.string()).nullable().default([]), }) export const siteConfigRefSchema = z.object({ all_site_config: z.object({ items: z.array( z.object({ - sitewide_alert: z.object({ - alertConnection: alertConnectionRefSchema, - }), + sitewide_alert: z + .object({ + alerts: z + .array( + z.object({ + alertConnection: alertConnectionRefSchema, + }) + ) + .nullable(), + }) + .transform((data) => { + const sitewideAlertWeb = data.alerts?.find((alert) => + alert.alertConnection.visible_on?.includes(AlertVisibleOnEnum.WEB) + ) + return { alert: sitewideAlertWeb || null } + }), system: systemSchema, }) ), diff --git a/packages/trpc/lib/routers/contentstack/base/utils.ts b/packages/trpc/lib/routers/contentstack/base/utils.ts index 87e5bac9c..2f9d3018f 100644 --- a/packages/trpc/lib/routers/contentstack/base/utils.ts +++ b/packages/trpc/lib/routers/contentstack/base/utils.ts @@ -82,9 +82,9 @@ export function getSiteConfigConnections(refs: GetSiteConfigRefData) { const siteConfigData = refs.all_site_config.items[0] 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 }) => { connections.push(node.system) diff --git a/packages/trpc/lib/routers/hotels/schemas/hotel/specialAlerts.ts b/packages/trpc/lib/routers/hotels/schemas/hotel/specialAlerts.ts index e30ae9c33..a84c1a746 100644 --- a/packages/trpc/lib/routers/hotels/schemas/hotel/specialAlerts.ts +++ b/packages/trpc/lib/routers/hotels/schemas/hotel/specialAlerts.ts @@ -3,7 +3,7 @@ import { z } from "zod" import { dt } from "@scandic-hotels/common/dt" import { nullableStringValidator } from "@scandic-hotels/common/utils/zod/stringValidator" -import { AlertTypeEnum } from "../../../../types/alertType" +import { AlertTypeEnum } from "../../../../types/alert" const specialAlertSchema = z.object({ description: nullableStringValidator, diff --git a/packages/trpc/lib/types/alertType.ts b/packages/trpc/lib/types/alert.ts similarity index 59% rename from packages/trpc/lib/types/alertType.ts rename to packages/trpc/lib/types/alert.ts index a8cfdc2f8..9fcff432f 100644 --- a/packages/trpc/lib/types/alertType.ts +++ b/packages/trpc/lib/types/alert.ts @@ -4,3 +4,8 @@ export enum AlertTypeEnum { Alarm = "alarm", Success = "success", } + +export const AlertVisibleOnEnum = { + WEB: "WEB", + APP: "APP", +} as const