fix(SW-188): improve semantics, use hotel instead of attribute naming
This commit is contained in:
@@ -27,8 +27,8 @@ export default async function SelectHotelPage({
|
||||
return null
|
||||
}
|
||||
|
||||
const { attributes } = hotelData
|
||||
const hotels = [attributes]
|
||||
const { hotel } = hotelData
|
||||
const hotels = [hotel]
|
||||
|
||||
const hotelFilters = await serverClient().hotel.getFilters({
|
||||
hotelId: "879",
|
||||
|
||||
@@ -15,14 +15,13 @@ export default async function SelectRate({ params }: PageArgs<LangParams>) {
|
||||
setLang(params.lang)
|
||||
|
||||
// TODO: pass the correct hotel ID
|
||||
const hotel = await serverClient().hotel.getHotel({
|
||||
const hotelData = await serverClient().hotel.getHotel({
|
||||
hotelId: "879",
|
||||
language: getLang(),
|
||||
})
|
||||
|
||||
if (!hotel) return null
|
||||
|
||||
const { attributes } = hotel
|
||||
if (!hotelData) return null
|
||||
const { hotel } = hotelData
|
||||
|
||||
const rooms = await serverClient().hotel.getRates({
|
||||
// TODO: pass the correct hotel ID and all other parameters that should be included in the search
|
||||
@@ -33,7 +32,7 @@ export default async function SelectRate({ params }: PageArgs<LangParams>) {
|
||||
<div className={styles.page}>
|
||||
<main className={styles.content}>
|
||||
<div className={styles.hotelInfo}>
|
||||
<HotelCard hotel={attributes} />
|
||||
<HotelCard hotel={hotel} />
|
||||
</div>
|
||||
<RoomSelection rooms={rooms} />
|
||||
<FlexibilitySelection />
|
||||
|
||||
@@ -25,7 +25,7 @@ export default async function HotelPage() {
|
||||
include: ["RoomCategories"],
|
||||
})
|
||||
if (!hotelData) return null
|
||||
const { attributes, roomCategories } = hotelData
|
||||
const { hotel, roomCategories } = hotelData
|
||||
|
||||
return (
|
||||
<div className={styles.pageContainer}>
|
||||
@@ -33,14 +33,14 @@ export default async function HotelPage() {
|
||||
<main className={styles.mainSection}>
|
||||
<div className={styles.introContainer}>
|
||||
<IntroSection
|
||||
hotelName={attributes.name}
|
||||
hotelDescription={attributes.hotelContent.texts.descriptions.short}
|
||||
location={attributes.location}
|
||||
address={attributes.address}
|
||||
tripAdvisor={attributes.ratings?.tripAdvisor}
|
||||
hotelName={hotel.name}
|
||||
hotelDescription={hotel.hotelContent.texts.descriptions.short}
|
||||
location={hotel.location}
|
||||
address={hotel.address}
|
||||
tripAdvisor={hotel.ratings?.tripAdvisor}
|
||||
/>
|
||||
<SidePeeks />
|
||||
<AmenitiesList detailedFacilities={attributes.detailedFacilities} />
|
||||
<AmenitiesList detailedFacilities={hotel.detailedFacilities} />
|
||||
</div>
|
||||
<Rooms rooms={roomCategories} />
|
||||
</main>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { z } from "zod"
|
||||
|
||||
import { fromUppercaseToLangEnum } from "@/utils/languages"
|
||||
import { fromUppercaseToLangEnum } from "@/server/utils"
|
||||
|
||||
const RatingsSchema = z
|
||||
.object({
|
||||
|
||||
@@ -72,7 +72,7 @@ export const hotelQueryRouter = router({
|
||||
})
|
||||
|
||||
return {
|
||||
attributes: validatedHotelData.data.data.attributes,
|
||||
hotel: validatedHotelData.data.data.attributes,
|
||||
roomCategories: roomCategories,
|
||||
}
|
||||
}),
|
||||
|
||||
@@ -26,3 +26,12 @@ const toApiLangMap: { [key in Lang]: string } = {
|
||||
[Lang.da]: "Da",
|
||||
[Lang.de]: "De",
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to convert langs in uppercase or capitalized format (e.g. the Hotel endpoint)
|
||||
* to to Lang enum.
|
||||
*/
|
||||
export function fromUppercaseToLangEnum(lang: string): Lang | undefined {
|
||||
const lowerCaseLang = lang.toLowerCase()
|
||||
return Object.values(Lang).find((l) => l === lowerCaseLang)
|
||||
}
|
||||
|
||||
@@ -5,12 +5,3 @@ export function findLang(pathname: string) {
|
||||
(l) => pathname.startsWith(`/${l}/`) || pathname === `/${l}`
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to convert langs in uppercase or capitalized format (e.g. the Hotel endpoint)
|
||||
* to to Lang enum.
|
||||
*/
|
||||
export function fromUppercaseToLangEnum(lang: string): Lang | undefined {
|
||||
const lowerCaseLang = lang.toLowerCase()
|
||||
return Object.values(Lang).find((l) => l === lowerCaseLang)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user