fix: clean up hotel and its typings
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { Suspense } from "react"
|
||||
|
||||
import { getHotelData } from "@/lib/trpc/memoizedRequests"
|
||||
import { getHotel } from "@/lib/trpc/memoizedRequests"
|
||||
|
||||
import { mapFacilityToIcon } from "@/components/ContentType/HotelPage/data"
|
||||
import ImageGallery from "@/components/ImageGallery"
|
||||
@@ -18,55 +18,44 @@ import { NoRoomsAlert } from "./NoRoomsAlert"
|
||||
|
||||
import styles from "./hotelInfoCard.module.css"
|
||||
|
||||
import type { Child } from "@/types/components/hotelReservation/selectRate/selectRate"
|
||||
import type { Lang } from "@/constants/languages"
|
||||
|
||||
type Props = {
|
||||
hotelId: number
|
||||
lang: Lang
|
||||
fromDate: Date
|
||||
toDate: Date
|
||||
adultCount: number
|
||||
childArray?: Child[]
|
||||
}
|
||||
import type { HotelInfoCardProps } from "@/types/components/hotelReservation/selectRate/hotelInfoCard"
|
||||
|
||||
export default async function HotelInfoCard({
|
||||
hotelId,
|
||||
lang,
|
||||
...props
|
||||
}: Props) {
|
||||
const hotelData = await getHotelData({
|
||||
}: HotelInfoCardProps) {
|
||||
const hotelData = await getHotel({
|
||||
hotelId: hotelId.toString(),
|
||||
isCardOnlyPayment: false,
|
||||
language: lang,
|
||||
})
|
||||
|
||||
const hotelAttributes = hotelData?.data.attributes
|
||||
const hotel = hotelData?.hotel
|
||||
const intl = await getIntl()
|
||||
|
||||
const sortedFacilities = hotelAttributes?.detailedFacilities
|
||||
const sortedFacilities = hotel?.detailedFacilities
|
||||
.sort((a, b) => b.sortOrder - a.sortOrder)
|
||||
.slice(0, 5)
|
||||
|
||||
return (
|
||||
<article className={styles.container}>
|
||||
{hotelAttributes && (
|
||||
{hotel && (
|
||||
<section className={styles.wrapper}>
|
||||
<div className={styles.imageWrapper}>
|
||||
<ImageGallery
|
||||
title={hotelAttributes.name}
|
||||
images={hotelAttributes.galleryImages}
|
||||
title={hotel.name}
|
||||
images={hotel.galleryImages}
|
||||
fill
|
||||
/>
|
||||
{hotelAttributes.ratings?.tripAdvisor && (
|
||||
<TripAdvisorChip
|
||||
rating={hotelAttributes.ratings.tripAdvisor.rating}
|
||||
/>
|
||||
{hotel.ratings?.tripAdvisor && (
|
||||
<TripAdvisorChip rating={hotel.ratings.tripAdvisor.rating} />
|
||||
)}
|
||||
</div>
|
||||
<div className={styles.hotelContent}>
|
||||
<div className={styles.hotelInformation}>
|
||||
<Title as="h2" textTransform="uppercase">
|
||||
{hotelAttributes.name}
|
||||
{hotel.name}
|
||||
</Title>
|
||||
<div className={styles.hotelAddressDescription}>
|
||||
<Caption color="uiTextMediumContrast">
|
||||
@@ -75,16 +64,16 @@ export default async function HotelInfoCard({
|
||||
id: "{address}, {city} ∙ {distanceToCityCenterInKm} km to city center",
|
||||
},
|
||||
{
|
||||
address: hotelAttributes.address.streetAddress,
|
||||
city: hotelAttributes.address.city,
|
||||
distanceToCityCenterInKm: getSingleDecimal(
|
||||
hotelAttributes.location.distanceToCentre / 1000
|
||||
address: hotel.address.streetAddress,
|
||||
city: hotel.address.city,
|
||||
distanceToCityCentreInKm: getSingleDecimal(
|
||||
hotel.location.distanceToCentre / 1000
|
||||
),
|
||||
}
|
||||
)}
|
||||
</Caption>
|
||||
<Body color="uiTextHighContrast">
|
||||
{hotelAttributes.hotelContent.texts.descriptions.medium}
|
||||
{hotel.hotelContent.texts.descriptions.medium}
|
||||
</Body>
|
||||
</div>
|
||||
</div>
|
||||
@@ -111,15 +100,15 @@ export default async function HotelInfoCard({
|
||||
</div>
|
||||
<ReadMore
|
||||
label={intl.formatMessage({ id: "Show all amenities" })}
|
||||
hotelId={hotelAttributes.operaId}
|
||||
hotel={hotelAttributes}
|
||||
hotelId={hotel.operaId}
|
||||
hotel={hotel}
|
||||
showCTA={false}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
)}
|
||||
{hotelAttributes?.specialAlerts.map((alert) => {
|
||||
{hotel?.specialAlerts.map((alert) => {
|
||||
return (
|
||||
<div className={styles.hotelAlert} key={`wrapper_${alert.id}`}>
|
||||
<Alert
|
||||
|
||||
Reference in New Issue
Block a user