Merged in fix/BOOK-599-filter-alert-booking-flow (pull request #3314)
fix(BOOK-599): filter displayInBookingFlow alert * fix(BOOK-599): filter displayInBookingFlow alert * fix(BOOK-599): filter displayinbookingflow on confirmation page Approved-by: Linus Flood
This commit is contained in:
committed by
Linus Flood
parent
276027045e
commit
8682e66047
@@ -2,13 +2,13 @@ import { notFound } from "next/navigation"
|
|||||||
|
|
||||||
import { AlertTypeEnum } from "@scandic-hotels/common/constants/alert"
|
import { AlertTypeEnum } from "@scandic-hotels/common/constants/alert"
|
||||||
import { dt } from "@scandic-hotels/common/dt"
|
import { dt } from "@scandic-hotels/common/dt"
|
||||||
|
import { hasOverlappingDates } from "@scandic-hotels/common/dt/utils/hasOverlappingDates"
|
||||||
import { Alert } from "@scandic-hotels/design-system/Alert"
|
import { Alert } from "@scandic-hotels/design-system/Alert"
|
||||||
import { Divider } from "@scandic-hotels/design-system/Divider"
|
import { Divider } from "@scandic-hotels/design-system/Divider"
|
||||||
import { HotelTypeEnum } from "@scandic-hotels/trpc/enums/hotelType"
|
import { HotelTypeEnum } from "@scandic-hotels/trpc/enums/hotelType"
|
||||||
|
|
||||||
import { BookingConfirmationProvider } from "../../providers/BookingConfirmationProvider"
|
import { BookingConfirmationProvider } from "../../providers/BookingConfirmationProvider"
|
||||||
import { getBookingConfirmation } from "../../trpc/memoizedRequests/getBookingConfirmation"
|
import { getBookingConfirmation } from "../../trpc/memoizedRequests/getBookingConfirmation"
|
||||||
import { filterOverlappingDates } from "../../utils/SelectRate"
|
|
||||||
import { SidePanel } from "../SidePanel"
|
import { SidePanel } from "../SidePanel"
|
||||||
import { Confirmation } from "./Confirmation"
|
import { Confirmation } from "./Confirmation"
|
||||||
import { HotelDetails } from "./HotelDetails"
|
import { HotelDetails } from "./HotelDetails"
|
||||||
@@ -46,7 +46,14 @@ export async function BookingConfirmation({
|
|||||||
if (!room) {
|
if (!room) {
|
||||||
return notFound()
|
return notFound()
|
||||||
}
|
}
|
||||||
|
const validAlerts = hotel.specialAlerts.filter(
|
||||||
|
(alert) =>
|
||||||
|
hasOverlappingDates(
|
||||||
|
alert,
|
||||||
|
dt(booking.checkInDate),
|
||||||
|
dt(booking.checkOutDate)
|
||||||
|
) && alert.displayInBookingFlow
|
||||||
|
)
|
||||||
return (
|
return (
|
||||||
<BookingConfirmationProvider
|
<BookingConfirmationProvider
|
||||||
bookingCode={booking.bookingCode}
|
bookingCode={booking.bookingCode}
|
||||||
@@ -87,11 +94,7 @@ export async function BookingConfirmation({
|
|||||||
<PaymentDetails />
|
<PaymentDetails />
|
||||||
<Divider color="Border/Divider/Subtle" />
|
<Divider color="Border/Divider/Subtle" />
|
||||||
<HotelDetails hotel={hotel} />
|
<HotelDetails hotel={hotel} />
|
||||||
{filterOverlappingDates(
|
{validAlerts.map((alert) => (
|
||||||
hotel.specialAlerts,
|
|
||||||
dt(booking.checkInDate),
|
|
||||||
dt(booking.checkOutDate)
|
|
||||||
).map((alert) => (
|
|
||||||
<div key={alert.id}>
|
<div key={alert.id}>
|
||||||
<Alert
|
<Alert
|
||||||
type={alert.type}
|
type={alert.type}
|
||||||
|
|||||||
@@ -33,8 +33,10 @@ export async function SelectRate({
|
|||||||
isInValidFNF = cookieStore.get("sc")?.value !== "1"
|
isInValidFNF = cookieStore.get("sc")?.value !== "1"
|
||||||
}
|
}
|
||||||
|
|
||||||
const validAlerts = hotelData.hotel.specialAlerts.filter((alert) =>
|
const validAlerts = hotelData.hotel.specialAlerts.filter(
|
||||||
hasOverlappingDates(alert, dt(booking.fromDate), dt(booking.toDate))
|
(alert) =>
|
||||||
|
hasOverlappingDates(alert, dt(booking.fromDate), dt(booking.toDate)) &&
|
||||||
|
alert.displayInBookingFlow
|
||||||
)
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user