fix(BOOK-599): Filtering on correct values for hotel pages now and added comments
Approved-by: Matilda Landström
This commit is contained in:
@@ -149,6 +149,13 @@ export default async function HotelPage({
|
||||
|
||||
const isThemed = hotelTheme !== DEFAULT_THEME
|
||||
const galleryImages = mapApiImagesToGalleryImages(images ?? [])
|
||||
const filteredAlerts = specialAlerts.filter(({ endDate, name }) => {
|
||||
// Hotel alerts should only be shown if they:
|
||||
// - Have no end date or Have an end date in the future (including today)
|
||||
// - Are not of type 'HotelChildrenInBooking'
|
||||
const shouldShowNow = !endDate || dt().isSameOrBefore(dt(endDate), "day")
|
||||
return name !== AlertName.HotelChildrenInBooking && shouldShowNow
|
||||
})
|
||||
|
||||
return (
|
||||
<div className={styles.pageContainer}>
|
||||
@@ -194,28 +201,16 @@ export default async function HotelPage({
|
||||
|
||||
<AmenitiesList detailedFacilities={detailedFacilities} />
|
||||
</div>
|
||||
{specialAlerts.length ? (
|
||||
{filteredAlerts.length ? (
|
||||
<div className={styles.alertsContainer}>
|
||||
{specialAlerts
|
||||
.filter((alert) => {
|
||||
const now = dt().utc().format("YYYY-MM-DD")
|
||||
const shouldShowNow =
|
||||
alert.startDate && alert.endDate
|
||||
? alert.startDate <= now && alert.endDate >= now
|
||||
: true
|
||||
return (
|
||||
alert.name !== AlertName.HotelChildrenInBooking &&
|
||||
shouldShowNow
|
||||
)
|
||||
})
|
||||
.map((alert) => (
|
||||
<Alert
|
||||
key={alert.id}
|
||||
type={alert.type}
|
||||
heading={alert.heading}
|
||||
text={alert.text}
|
||||
/>
|
||||
))}
|
||||
{filteredAlerts.map((alert) => (
|
||||
<Alert
|
||||
key={alert.id}
|
||||
type={alert.type}
|
||||
heading={alert.heading}
|
||||
text={alert.text}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user