diff --git a/apps/scandic-web/components/HotelReservation/SelectRate/HotelInfoCard/index.tsx b/apps/scandic-web/components/HotelReservation/SelectRate/HotelInfoCard/index.tsx
index 80e2c8bc8..4e32cd25e 100644
--- a/apps/scandic-web/components/HotelReservation/SelectRate/HotelInfoCard/index.tsx
+++ b/apps/scandic-web/components/HotelReservation/SelectRate/HotelInfoCard/index.tsx
@@ -1,6 +1,8 @@
import { Divider } from "@scandic-hotels/design-system/Divider"
import { Typography } from "@scandic-hotels/design-system/Typography"
+import { dt } from "@/lib/dt"
+
import { FacilityToIcon } from "@/components/ContentType/HotelPage/data"
import ImageGallery from "@/components/ImageGallery"
import SkeletonShimmer from "@/components/SkeletonShimmer"
@@ -18,7 +20,10 @@ import styles from "./hotelInfoCard.module.css"
import type { HotelInfoCardProps } from "@/types/components/hotelReservation/selectRate/hotelInfoCard"
import { SidePeekEnum } from "@/types/components/hotelReservation/sidePeek"
-export default async function HotelInfoCard({ hotel }: HotelInfoCardProps) {
+export default async function HotelInfoCard({
+ booking,
+ hotel,
+}: HotelInfoCardProps) {
const intl = await getIntl()
const sortedFacilities = hotel.detailedFacilities
@@ -27,6 +32,9 @@ export default async function HotelInfoCard({ hotel }: HotelInfoCardProps) {
const galleryImages = mapApiImagesToGalleryImages(hotel.galleryImages || [])
+ const fromDate = dt(booking.fromDate)
+ const toDate = dt(booking.toDate)
+
return (
@@ -94,16 +102,41 @@ export default async function HotelInfoCard({ hotel }: HotelInfoCardProps) {
- {hotel.specialAlerts.map((alert) => (
-
- ))}
+ {hotel.specialAlerts.map((alert) => {
+ if (alert.endDate && alert.startDate) {
+ const endDate = dt(alert.endDate)
+ const startDate = dt(alert.startDate)
+
+ const fromDateIsBetweenAlertDates = dt(fromDate).isBetween(
+ startDate,
+ endDate,
+ "date",
+ "[]"
+ )
+ const toDateIsBetweenAlertDates = dt(toDate).isBetween(
+ startDate,
+ endDate,
+ "date",
+ "[]"
+ )
+ const bookingSpanIsBetweenAlertDates =
+ fromDateIsBetweenAlertDates && toDateIsBetweenAlertDates
+ if (!bookingSpanIsBetweenAlertDates) {
+ return null
+ }
+ }
+
+ return (
+
+ )
+ })}
)
}
diff --git a/apps/scandic-web/components/HotelReservation/SelectRate/index.tsx b/apps/scandic-web/components/HotelReservation/SelectRate/index.tsx
index 7cdc7e6ee..9c1e240f5 100644
--- a/apps/scandic-web/components/HotelReservation/SelectRate/index.tsx
+++ b/apps/scandic-web/components/HotelReservation/SelectRate/index.tsx
@@ -27,6 +27,7 @@ export default async function SelectRatePage({
if (!searchDetails?.hotel) {
return notFound()
}
+
const { adultsInRoom, childrenInRoom, hotel, noOfRooms, bookingCode } =
searchDetails
@@ -47,7 +48,7 @@ export default async function SelectRatePage({
}
return (
<>
-
+
{isInValidFNF ? (
diff --git a/apps/scandic-web/lib/dt.ts b/apps/scandic-web/lib/dt.ts
index 5f8a90eac..97bc873ff 100644
--- a/apps/scandic-web/lib/dt.ts
+++ b/apps/scandic-web/lib/dt.ts
@@ -8,6 +8,7 @@ import nb from "dayjs/locale/nb"
import advancedFormat from "dayjs/plugin/advancedFormat"
import customParseFormat from "dayjs/plugin/customParseFormat"
import duration from "dayjs/plugin/duration"
+import isBetween from "dayjs/plugin/isBetween"
import isSameOrAfter from "dayjs/plugin/isSameOrAfter"
import isSameOrBefore from "dayjs/plugin/isSameOrBefore"
import isToday from "dayjs/plugin/isToday"
@@ -35,5 +36,6 @@ d.extend(isSameOrAfter)
d.extend(isSameOrBefore)
d.extend(duration)
d.extend(customParseFormat)
+d.extend(isBetween)
export const dt = d
diff --git a/apps/scandic-web/server/routers/hotels/schemas/hotel/specialAlerts.ts b/apps/scandic-web/server/routers/hotels/schemas/hotel/specialAlerts.ts
index f9d062dfd..c23f81f7a 100644
--- a/apps/scandic-web/server/routers/hotels/schemas/hotel/specialAlerts.ts
+++ b/apps/scandic-web/server/routers/hotels/schemas/hotel/specialAlerts.ts
@@ -22,11 +22,12 @@ export const specialAlertsSchema = z
.transform((data) => {
const now = dt().utc().format("YYYY-MM-DD")
const filteredAlerts = data.filter((alert) => {
- const shouldShowNow =
- alert.startDate && alert.endDate
- ? alert.startDate <= now && alert.endDate >= now
- : true
const hasText = alert.description || alert.title
+ const hasDates = alert.startDate && alert.endDate
+ if (!hasDates) {
+ return hasText
+ }
+ const shouldShowNow = alert.startDate <= now && alert.endDate >= now
return shouldShowNow && hasText
})
return filteredAlerts.map((alert, idx) => ({
@@ -36,5 +37,7 @@ export const specialAlertsSchema = z
text: alert.description || null,
type: AlertTypeEnum.Info,
displayInBookingFlow: alert.displayInBookingFlow,
+ endDate: alert.endDate,
+ startDate: alert.startDate,
}))
})
diff --git a/apps/scandic-web/types/components/hotelReservation/selectRate/hotelInfoCard.ts b/apps/scandic-web/types/components/hotelReservation/selectRate/hotelInfoCard.ts
index fb5071870..2acbc62fa 100644
--- a/apps/scandic-web/types/components/hotelReservation/selectRate/hotelInfoCard.ts
+++ b/apps/scandic-web/types/components/hotelReservation/selectRate/hotelInfoCard.ts
@@ -1,5 +1,7 @@
import type { Hotel } from "@/types/hotel"
+import type { SelectRateBooking } from "./selectRate"
export interface HotelInfoCardProps {
+ booking: SelectRateBooking
hotel: Hotel
}