Merged in fix/SW-1693-subpage-check (pull request #1373)
Fix(SW-1693): Don't render hotel subpages if not supposed to * fix(SW-1693): don't render hotel subpage if not supposed to Approved-by: Erik Tiekstra Approved-by: Fredrik Thorsson
This commit is contained in:
@@ -19,7 +19,7 @@ import MeetingsAdditionalContent from "./AdditionalContent/Meetings"
|
|||||||
import HotelSubpageAdditionalContent from "./AdditionalContent"
|
import HotelSubpageAdditionalContent from "./AdditionalContent"
|
||||||
import HtmlContent from "./HtmlContent"
|
import HtmlContent from "./HtmlContent"
|
||||||
import HotelSubpageSidebar from "./Sidebar"
|
import HotelSubpageSidebar from "./Sidebar"
|
||||||
import { getSubpageData } from "./utils"
|
import { getSubpageData, verifySubpageShouldExist } from "./utils"
|
||||||
|
|
||||||
import styles from "./hotelSubpage.module.css"
|
import styles from "./hotelSubpage.module.css"
|
||||||
|
|
||||||
@@ -40,6 +40,10 @@ export default async function HotelSubpage({
|
|||||||
notFound()
|
notFound()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!verifySubpageShouldExist(hotelData, subpage)) {
|
||||||
|
notFound()
|
||||||
|
}
|
||||||
|
|
||||||
const pageData = getSubpageData(intl, subpage, hotelData)
|
const pageData = getSubpageData(intl, subpage, hotelData)
|
||||||
if (!pageData) {
|
if (!pageData) {
|
||||||
notFound()
|
notFound()
|
||||||
|
|||||||
@@ -91,3 +91,37 @@ export function getSubpageData(
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function verifySubpageShouldExist(
|
||||||
|
hotelData: HotelData,
|
||||||
|
subpage: string
|
||||||
|
): boolean {
|
||||||
|
const isRestaurant = hotelData.restaurants.find(
|
||||||
|
(restaurant) => restaurant.nameInUrl === subpage
|
||||||
|
)
|
||||||
|
if (isRestaurant) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
const additionalData = hotelData.additionalData
|
||||||
|
switch (subpage) {
|
||||||
|
case additionalData.hotelParking.nameInUrl:
|
||||||
|
if (additionalData.displayWebPage.parking) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
case additionalData.healthAndFitness.nameInUrl:
|
||||||
|
if (additionalData.displayWebPage.healthGym) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
case additionalData.hotelSpecialNeeds.nameInUrl:
|
||||||
|
if (additionalData.displayWebPage.specialNeeds) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
case additionalData.meetingRooms.nameInUrl:
|
||||||
|
if (additionalData.displayWebPage.meetingRoom) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user