diff --git a/components/ContentType/HotelPage/SidePeeks/MeetingsAndConferences/index.tsx b/components/ContentType/HotelPage/SidePeeks/MeetingsAndConferences/index.tsx index c2a66cd79..6714d0eb0 100644 --- a/components/ContentType/HotelPage/SidePeeks/MeetingsAndConferences/index.tsx +++ b/components/ContentType/HotelPage/SidePeeks/MeetingsAndConferences/index.tsx @@ -1,5 +1,4 @@ import { meetingsAndConferences } from "@/constants/routes/hotelPageParams" -import { getMeetingRooms } from "@/lib/trpc/memoizedRequests" import Image from "@/components/Image" import Button from "@/components/TempDesignSystem/Button" @@ -20,15 +19,11 @@ import type { MeetingsAndConferencesSidePeekProps } from "@/types/components/hot export default async function MeetingsAndConferencesSidePeek({ meetingFacilities, descriptions, - hotelId, + meetingRooms, meetingPageUrl, }: MeetingsAndConferencesSidePeekProps) { const lang = getLang() - const [intl, meetingRooms] = await Promise.all([ - getIntl(), - getMeetingRooms({ hotelId, language: lang }), - ]) - + const intl = await getIntl() const { seatingText, roomText } = await getConferenceRoomTexts(meetingRooms) const fallbackAlt = intl.formatMessage({ id: "Creative spaces for meetings" }) diff --git a/components/ContentType/HotelPage/TabNavigation/index.tsx b/components/ContentType/HotelPage/TabNavigation/index.tsx index 4d9f76466..24187bf22 100644 --- a/components/ContentType/HotelPage/TabNavigation/index.tsx +++ b/components/ContentType/HotelPage/TabNavigation/index.tsx @@ -22,6 +22,9 @@ import { export default function TabNavigation({ hasActivities, hasFAQ, + hasMeetingRooms, + hasRestaurants, + hasWellness, tabValues, }: TabNavigationProps) { const hash = useHash() @@ -43,24 +46,36 @@ export default function TabNavigation({ hash: HotelHashValues.rooms, text: tabValues?.rooms || intl.formatMessage({ id: "Rooms" }), }, - { - hash: HotelHashValues.restaurant, - text: - tabValues?.restaurant_bar || - intl.formatMessage({ id: "Restaurant & Bar" }), - }, - { - hash: HotelHashValues.meetings, - text: - tabValues?.conferences_meetings || - intl.formatMessage({ id: "Meetings & Conferences" }), - }, - { - hash: HotelHashValues.wellness, - text: - tabValues?.health_wellness || - intl.formatMessage({ id: "Wellness & Exercise" }), - }, + ...(hasRestaurants + ? [ + { + hash: HotelHashValues.restaurant, + text: + tabValues?.restaurant_bar || + intl.formatMessage({ id: "Restaurant & Bar" }), + }, + ] + : []), + ...(hasMeetingRooms + ? [ + { + hash: HotelHashValues.meetings, + text: + tabValues?.conferences_meetings || + intl.formatMessage({ id: "Meetings & Conferences" }), + }, + ] + : []), + ...(hasWellness + ? [ + { + hash: HotelHashValues.wellness, + text: + tabValues?.health_wellness || + intl.formatMessage({ id: "Wellness & Exercise" }), + }, + ] + : []), ...(hasActivities ? [ { diff --git a/components/ContentType/HotelPage/index.tsx b/components/ContentType/HotelPage/index.tsx index 2440d9165..7c0195b46 100644 --- a/components/ContentType/HotelPage/index.tsx +++ b/components/ContentType/HotelPage/index.tsx @@ -2,7 +2,11 @@ import { notFound } from "next/navigation" import { Suspense } from "react" import { env } from "@/env/server" -import { getHotel, getHotelPage } from "@/lib/trpc/memoizedRequests" +import { + getHotel, + getHotelPage, + getMeetingRooms, +} from "@/lib/trpc/memoizedRequests" import AccordionSection from "@/components/Blocks/Accordion" import Breadcrumbs from "@/components/Breadcrumbs" @@ -11,6 +15,7 @@ import Alert from "@/components/TempDesignSystem/Alert" import BreadcrumbsSkeleton from "@/components/TempDesignSystem/Breadcrumbs/BreadcrumbsSkeleton" import TrackingSDK from "@/components/TrackingSDK" import { getLang } from "@/i18n/serverContext" +import { setFacilityCards } from "@/utils/facilityCards" import { generateHotelSchema } from "@/utils/jsonSchemas" import DynamicMap from "./Map/DynamicMap" @@ -37,22 +42,22 @@ import { getTrackingHotelData, getTrackingPageData } from "./utils" import styles from "./hotelPage.module.css" -import { FacilityCardTypeEnum } from "@/types/components/hotelPage/facilities" import type { HotelPageProps } from "@/types/components/hotelPage/hotelPage" import { HotelHashValues } from "@/types/components/hotelPage/tabNavigation" -import type { Facility } from "@/types/hotel" import { PageContentTypeEnum } from "@/types/requests/contentType" export default async function HotelPage({ hotelId }: HotelPageProps) { const lang = getLang() - const [hotelPageData, hotelData] = await Promise.all([ + const [hotelPageData, hotelData, meetingRoomsData] = await Promise.all([ getHotelPage(), getHotel({ hotelId, isCardOnlyPayment: false, language: lang, }), + getMeetingRooms({ hotelId, language: lang }), ]) + const googleMapsApiKey = env.GOOGLE_STATIC_MAP_KEY const googleMapId = env.GOOGLE_DYNAMIC_MAP_ID @@ -97,26 +102,18 @@ export default async function HotelPage({ hotelId }: HotelPageProps) { const { spaPage, activitiesCards } = content - const facilities: Facility[] = [ - { - ...restaurantImages, - id: FacilityCardTypeEnum.restaurant, - headingText: restaurantImages?.headingText ?? "", - heroImages: restaurantImages?.heroImages ?? [], - }, - { - ...conferencesAndMeetings, - id: FacilityCardTypeEnum.conference, - headingText: conferencesAndMeetings?.headingText ?? "", - heroImages: conferencesAndMeetings?.heroImages ?? [], - }, - { - ...healthAndWellness, - id: FacilityCardTypeEnum.wellness, - headingText: healthAndWellness?.headingText ?? "", - heroImages: healthAndWellness?.heroImages ?? [], - }, - ] + const hasRestaurants = restaurants.length > 0 + const hasMeetingRooms = meetingRoomsData.length > 0 + const hasWellness = healthFacilities.length > 0 + + const facilities = setFacilityCards( + restaurantImages, + conferencesAndMeetings, + healthAndWellness, + hasRestaurants, + hasMeetingRooms, + hasWellness + ) const topThreePois = pointsOfInterest.slice(0, 3) @@ -151,6 +148,9 @@ export default async function HotelPage({ hotelId }: HotelPageProps) { 0} hasFAQ={!!faq?.accordions.length} + hasWellness={hasWellness} + hasRestaurants={hasRestaurants} + hasMeetingRooms={hasMeetingRooms} tabValues={tabValues} /> @@ -183,12 +183,14 @@ export default async function HotelPage({ hotelId }: HotelPageProps) { ) : null} - + {facilities && ( + + )} {faq && faq.accordions.length > 0 && ( )} @@ -238,14 +240,18 @@ export default async function HotelPage({ hotelId }: HotelPageProps) { ecoLabels={hotelFacts.ecoLabels} descriptions={hotelContent.texts} /> - - + {hasWellness ? ( + + ) : null} + {hasRestaurants ? ( + + ) : null} {activitiesCards.map((card) => ( ))} - + {hasMeetingRooms && ( + + )} {roomCategories.map((room) => ( ))} diff --git a/types/components/hotelPage/sidepeek/meetingsAndConferences.ts b/types/components/hotelPage/sidepeek/meetingsAndConferences.ts index 7e70dac7f..d1e78e151 100644 --- a/types/components/hotelPage/sidepeek/meetingsAndConferences.ts +++ b/types/components/hotelPage/sidepeek/meetingsAndConferences.ts @@ -1,8 +1,9 @@ import type { Hotel } from "@/types/hotel" +import type { MeetingRooms } from "../meetingRooms" export type MeetingsAndConferencesSidePeekProps = { meetingFacilities: Hotel["conferencesAndMeetings"] descriptions: Hotel["hotelContent"]["texts"]["meetingDescription"] - hotelId: string + meetingRooms: MeetingRooms meetingPageUrl: string | undefined } diff --git a/types/components/hotelPage/tabNavigation.ts b/types/components/hotelPage/tabNavigation.ts index b07dd83f1..82d083636 100644 --- a/types/components/hotelPage/tabNavigation.ts +++ b/types/components/hotelPage/tabNavigation.ts @@ -22,5 +22,8 @@ type Tabs = { export type TabNavigationProps = { hasActivities: boolean hasFAQ: boolean + hasWellness: boolean + hasRestaurants: boolean + hasMeetingRooms: boolean tabValues?: Tabs | null } diff --git a/types/hotel.ts b/types/hotel.ts index 63027d822..a01d53222 100644 --- a/types/hotel.ts +++ b/types/hotel.ts @@ -32,7 +32,8 @@ export type Amenities = z.output export type CheckInData = z.output type CitySchema = z.output export type City = Pick & CitySchema["attributes"] -export type Facility = z.output & { id: string } +export type FacilityData = z.output +export type Facility = FacilityData & { id: string } export type ApiImage = z.output export type HealthFacility = z.output export type HealthFacilities = HealthFacility[] diff --git a/utils/facilityCards.ts b/utils/facilityCards.ts index 738ef9b09..e60fcad35 100644 --- a/utils/facilityCards.ts +++ b/utils/facilityCards.ts @@ -19,9 +19,53 @@ import { WellnessHeadings, } from "@/types/components/hotelPage/facilities" import { FacilityEnum } from "@/types/enums/facilities" -import type { Amenities, Facility, HealthFacilities } from "@/types/hotel" +import type { + Amenities, + Facility, + FacilityData, + HealthFacilities, +} from "@/types/hotel" import type { CardProps } from "@/components/TempDesignSystem/Card/card" +export function setFacilityCards( + restaurantImages: FacilityData | undefined, + conferencesAndMeetings: FacilityData | undefined, + healthAndWellness: FacilityData | undefined, + hasRestaurants: boolean, + hasMeetingRooms: boolean, + hasWellness: boolean +): Facility[] { + const facilities = [] + if (hasRestaurants) { + facilities.push( + setFacilityCard(restaurantImages, FacilityCardTypeEnum.restaurant) + ) + } + if (hasMeetingRooms) { + facilities.push( + setFacilityCard(conferencesAndMeetings, FacilityCardTypeEnum.conference) + ) + } + if (hasWellness) { + facilities.push( + setFacilityCard(healthAndWellness, FacilityCardTypeEnum.wellness) + ) + } + return facilities +} + +function setFacilityCard( + facility: FacilityData | undefined, + type: FacilityCardTypeEnum +): Facility { + return { + ...facility, + id: type, + headingText: facility?.headingText ?? "", + heroImages: facility?.heroImages ?? [], + } +} + export function isFacilityCard(card: FacilityCardType): card is FacilityCard { return "heading" in card }