fix: clean up hotel and its typings
This commit is contained in:
@@ -1,14 +1,15 @@
|
||||
import type {
|
||||
Hotel,
|
||||
HotelAddress,
|
||||
HotelData,
|
||||
HotelContent,
|
||||
HotelLocation,
|
||||
HotelTripAdvisor,
|
||||
} from "@/types/hotel"
|
||||
|
||||
export type IntroSectionProps = {
|
||||
hotelName: HotelData["data"]["attributes"]["name"]
|
||||
hotelDescription: HotelData["data"]["attributes"]["hotelContent"]["texts"]["descriptions"]["short"]
|
||||
location: HotelLocation
|
||||
address: HotelAddress
|
||||
hotelDescription: HotelContent["texts"]["descriptions"]["short"]
|
||||
hotelName: Hotel["name"]
|
||||
location: HotelLocation
|
||||
tripAdvisor: HotelTripAdvisor
|
||||
}
|
||||
|
||||
@@ -10,9 +10,9 @@ import {
|
||||
} from "@/types/components/hotelPage/sidepeek/parking"
|
||||
|
||||
export default async function ParkingPrices({
|
||||
pricing,
|
||||
currency,
|
||||
freeParking,
|
||||
pricing,
|
||||
}: ParkingPricesProps) {
|
||||
const intl = await getIntl()
|
||||
const day = intl.formatMessage({ id: "Price per day" })
|
||||
|
||||
@@ -53,8 +53,8 @@ export default async function ParkingAmenity({
|
||||
</Caption>
|
||||
<Divider color="baseSurfaceSubtleHover" />
|
||||
<ParkingPrices
|
||||
pricing={data.pricing.localCurrency.ordinary}
|
||||
currency={data.pricing.localCurrency.currency}
|
||||
pricing={data.pricing.localCurrency?.ordinary}
|
||||
currency={data.pricing.localCurrency?.currency}
|
||||
freeParking={data.pricing.freeParking}
|
||||
/>
|
||||
</div>
|
||||
@@ -64,8 +64,8 @@ export default async function ParkingAmenity({
|
||||
</Caption>
|
||||
<Divider color="baseSurfaceSubtleHover" />
|
||||
<ParkingPrices
|
||||
pricing={data.pricing.localCurrency.weekend}
|
||||
currency={data.pricing.localCurrency.currency}
|
||||
pricing={data.pricing.localCurrency?.weekend}
|
||||
currency={data.pricing.localCurrency?.currency}
|
||||
freeParking={data.pricing.freeParking}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -16,8 +16,8 @@ export default async function RestaurantBarItem({
|
||||
restaurant,
|
||||
}: RestaurantBarItemProps) {
|
||||
const intl = await getIntl()
|
||||
const { name, openingDetails, menus, content } = restaurant
|
||||
const { bookTableUrl, images } = restaurant.content
|
||||
const { bookTableUrl, name, openingDetails, content, menus } = restaurant
|
||||
const { images } = restaurant.content
|
||||
const visibleImages = restaurant.content.images.slice(0, 2)
|
||||
const imageWidth = images.length === 2 ? 240 : 496
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import { notFound } from "next/navigation"
|
||||
import { Suspense } from "react"
|
||||
|
||||
import { env } from "@/env/server"
|
||||
import { getHotelData, getHotelPage } from "@/lib/trpc/memoizedRequests"
|
||||
import { getHotel, getHotelPage } from "@/lib/trpc/memoizedRequests"
|
||||
|
||||
import AccordionSection from "@/components/Blocks/Accordion"
|
||||
import Breadcrumbs from "@/components/Breadcrumbs"
|
||||
@@ -41,23 +41,27 @@ 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 { AdditionalData, Facility } from "@/types/hotel"
|
||||
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([
|
||||
getHotelPage(),
|
||||
getHotelData({ hotelId, language: lang }),
|
||||
getHotel({
|
||||
hotelId,
|
||||
isCardOnlyPayment: false,
|
||||
language: lang,
|
||||
}),
|
||||
])
|
||||
const googleMapsApiKey = env.GOOGLE_STATIC_MAP_KEY
|
||||
const googleMapId = env.GOOGLE_DYNAMIC_MAP_ID
|
||||
|
||||
if (!hotelData?.data || !hotelPageData) {
|
||||
if (!hotelData?.hotel || !hotelPageData) {
|
||||
return notFound()
|
||||
}
|
||||
|
||||
const jsonSchema = generateHotelSchema(hotelData.data.attributes)
|
||||
const jsonSchema = generateHotelSchema(hotelData.hotel)
|
||||
const { faq, content, tabValues } = hotelPageData
|
||||
const {
|
||||
name,
|
||||
@@ -73,12 +77,9 @@ export default async function HotelPage({ hotelId }: HotelPageProps) {
|
||||
location,
|
||||
ratings,
|
||||
parking,
|
||||
} = hotelData.data.attributes
|
||||
const roomCategories = hotelData.included.rooms || []
|
||||
const restaurants = hotelData.included.restaurants || []
|
||||
const additionalData =
|
||||
hotelData.included.additionalData || ({} as AdditionalData)
|
||||
|
||||
} = hotelData.hotel
|
||||
const restaurants = hotelData.restaurants
|
||||
const roomCategories = hotelData.roomCategories
|
||||
const {
|
||||
healthAndWellness,
|
||||
restaurantImages,
|
||||
@@ -87,7 +88,7 @@ export default async function HotelPage({ hotelId }: HotelPageProps) {
|
||||
gallery,
|
||||
hotelParking,
|
||||
displayWebPage,
|
||||
} = additionalData
|
||||
} = hotelData.additionalData
|
||||
|
||||
const images = gallery?.smallerImages
|
||||
const description = hotelContent.texts.descriptions.medium
|
||||
|
||||
Reference in New Issue
Block a user