diff --git a/components/ContentType/HotelPage/AmenitiesList/index.tsx b/components/ContentType/HotelPage/AmenitiesList/index.tsx index 20bad025d..06483f434 100644 --- a/components/ContentType/HotelPage/AmenitiesList/index.tsx +++ b/components/ContentType/HotelPage/AmenitiesList/index.tsx @@ -10,12 +10,12 @@ import { getLang } from "@/i18n/serverContext" import styles from "./amenitiesList.module.css" -import { HotelData } from "@/types/hotel" +import type { Amenities } from "@/types/hotel" export default async function AmenitiesList({ detailedFacilities, }: { - detailedFacilities: HotelData["data"]["attributes"]["detailedFacilities"] + detailedFacilities: Amenities }) { const intl = await getIntl() const sortedAmenities = detailedFacilities diff --git a/components/ContentType/HotelPage/Facilities/CardGrid/index.tsx b/components/ContentType/HotelPage/Facilities/CardGrid/index.tsx index 1f1b9cc58..924d2c1ed 100644 --- a/components/ContentType/HotelPage/Facilities/CardGrid/index.tsx +++ b/components/ContentType/HotelPage/Facilities/CardGrid/index.tsx @@ -6,31 +6,40 @@ import { sortCards } from "@/utils/imageCard" import styles from "./cardGrid.module.css" import type { CardGridProps } from "@/types/components/hotelPage/facilities" +import type { CardProps } from "@/components/TempDesignSystem/Card/card" -export default async function CardGrid({ facility }: CardGridProps) { - const imageCard = sortCards(facility) - const nrCards = facility.length +export default async function CardGrid({ facilities }: CardGridProps) { + const imageCard = sortCards(facilities) + const nrCards = facilities.length + + function getCardClassName(card: CardProps): string { + if (nrCards === 1) { + return styles.spanThree + } else if (nrCards === 2 && card.backgroundImage) { + return styles.spanTwo + } + return styles.spanOne + } return (
- {facility.map((card: any, idx: number) => ( + {facilities.map((card: CardProps, idx: number) => ( ))} diff --git a/components/ContentType/HotelPage/Facilities/index.tsx b/components/ContentType/HotelPage/Facilities/index.tsx index 8775d0de2..04245c573 100644 --- a/components/ContentType/HotelPage/Facilities/index.tsx +++ b/components/ContentType/HotelPage/Facilities/index.tsx @@ -4,13 +4,16 @@ import CardGrid from "./CardGrid" import styles from "./facilities.module.css" -import type { FacilityProps } from "@/types/components/hotelPage/facilities" +import type { + FacilityCards, + FacilityProps, +} from "@/types/components/hotelPage/facilities" export default async function Facilities({ facilities }: FacilityProps) { return ( - {facilities.map((facility: any, idx: number) => ( - + {facilities.map((facilityCards: FacilityCards, idx: number) => ( + ))} ) diff --git a/components/TempDesignSystem/Card/CardImage/index.tsx b/components/TempDesignSystem/Card/CardImage/index.tsx index 2ee17f37d..876316c8c 100644 --- a/components/TempDesignSystem/Card/CardImage/index.tsx +++ b/components/TempDesignSystem/Card/CardImage/index.tsx @@ -15,10 +15,16 @@ export default function CardImage({
{imageCards.map( - ({ backgroundImage }) => + ({ backgroundImage }, idx: Number) => backgroundImage && ( {backgroundImage.title} = [ + const facilities: Facility[] = [ { ...apiJson.data.attributes.restaurantImages, id: FacilityEnum.restaurant, diff --git a/types/components/hotelPage/facilities.ts b/types/components/hotelPage/facilities.ts index 71babc174..0e539615a 100644 --- a/types/components/hotelPage/facilities.ts +++ b/types/components/hotelPage/facilities.ts @@ -1,15 +1,15 @@ import type { CardProps } from "@/components/TempDesignSystem/Card/card" -export type FacilityCards = Array +export type FacilityCards = CardProps[] -export type Facilities = Array +export type Facilities = FacilityCards[] export type FacilityProps = { facilities: Facilities } export type CardGridProps = { - facility: FacilityCards + facilities: FacilityCards } export enum FacilityEnum { @@ -17,3 +17,10 @@ export enum FacilityEnum { conference = "meetings-and-conferences", restaurant = "restaurant-and-bar", } + +export enum RestaurantHeadings { + restaurantAndBar = "Restaurant & Bar", + bar = "Bar", + restaurant = "Restaurant", + breakfastRestaurant = "Breakfast restaurant", +} diff --git a/types/hotel.ts b/types/hotel.ts index f4436fb6c..203e2423f 100644 --- a/types/hotel.ts +++ b/types/hotel.ts @@ -1,6 +1,7 @@ import { z } from "zod" import { + facilitySchema, getHotelDataSchema, parkingSchema, pointOfInterestSchema, @@ -13,6 +14,8 @@ export type Hotel = HotelData["data"]["attributes"] export type HotelAddress = HotelData["data"]["attributes"]["address"] export type HotelLocation = HotelData["data"]["attributes"]["location"] +export type Amenities = HotelData["data"]["attributes"]["detailedFacilities"] + type HotelRatings = HotelData["data"]["attributes"]["ratings"] export type HotelTripAdvisor = | NonNullable["tripAdvisor"] @@ -52,3 +55,4 @@ export enum PointOfInterestGroupEnum { } export type ParkingData = z.infer +export type Facility = z.infer & { id: string } diff --git a/utils/facilityCards.ts b/utils/facilityCards.ts index 3e9fd0d67..e8143de74 100644 --- a/utils/facilityCards.ts +++ b/utils/facilityCards.ts @@ -11,11 +11,11 @@ import { type Facilities, type FacilityCards, FacilityEnum, + RestaurantHeadings, } from "@/types/components/hotelPage/facilities" import type { ImageVaultAsset } from "@/types/components/imageVault" -import type { HotelData } from "@/types/hotel" +import type { Amenities, Facility } from "@/types/hotel" import type { CardProps } from "@/components/TempDesignSystem/Card/card" -import type { Facility } from "@/server/routers/hotels/output" type ActivityCard = { background_image?: ImageVaultAsset @@ -55,8 +55,8 @@ export function setActivityCard(activitiesCard: ActivityCard): FacilityCards { } export async function setFacilityCards( - facilities: Array, - amenities: HotelData["data"]["attributes"]["detailedFacilities"] + facilities: Facility[], + amenities: Amenities ) { const lang = getLang() const intl = await getIntl() @@ -135,28 +135,27 @@ export async function setFacilityCards( return cards } -export function getRestaurantHeading( - amenities: HotelData["data"]["attributes"]["detailedFacilities"] -) { +export function getRestaurantHeading(amenities: Amenities): RestaurantHeadings { const hasBar = amenities.some( (facility) => facility.id == 1606 || facility.id == 1014 // bar & rooftop bar id ) const hasRestaurant = amenities.some((facility) => facility.id == 1383) // restaurant id //let href, - let title: string + let title: RestaurantHeadings + if (hasBar && hasRestaurant) { //href = restaurantAndBar - title = "Restaurant & Bar" + title = RestaurantHeadings.restaurantAndBar } else if (hasBar) { //href = bar - title = "Bar" + title = RestaurantHeadings.bar } else if (hasRestaurant) { //href = restaurant - title = "Restaurant" + title = RestaurantHeadings.restaurant } else { //href = breakfastRestaurant - title = "Breakfast restaurant" + title = RestaurantHeadings.breakfastRestaurant } return title }