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
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
const { attributes } = hotelData
|
const { hotel } = hotelData
|
||||||
const hotels = [attributes]
|
const hotels = [hotel]
|
||||||
|
|
||||||
const hotelFilters = await serverClient().hotel.getFilters({
|
const hotelFilters = await serverClient().hotel.getFilters({
|
||||||
hotelId: "879",
|
hotelId: "879",
|
||||||
|
|||||||
@@ -15,14 +15,13 @@ export default async function SelectRate({ params }: PageArgs<LangParams>) {
|
|||||||
setLang(params.lang)
|
setLang(params.lang)
|
||||||
|
|
||||||
// TODO: pass the correct hotel ID
|
// TODO: pass the correct hotel ID
|
||||||
const hotel = await serverClient().hotel.getHotel({
|
const hotelData = await serverClient().hotel.getHotel({
|
||||||
hotelId: "879",
|
hotelId: "879",
|
||||||
language: getLang(),
|
language: getLang(),
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!hotel) return null
|
if (!hotelData) return null
|
||||||
|
const { hotel } = hotelData
|
||||||
const { attributes } = hotel
|
|
||||||
|
|
||||||
const rooms = await serverClient().hotel.getRates({
|
const rooms = await serverClient().hotel.getRates({
|
||||||
// TODO: pass the correct hotel ID and all other parameters that should be included in the search
|
// 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}>
|
<div className={styles.page}>
|
||||||
<main className={styles.content}>
|
<main className={styles.content}>
|
||||||
<div className={styles.hotelInfo}>
|
<div className={styles.hotelInfo}>
|
||||||
<HotelCard hotel={attributes} />
|
<HotelCard hotel={hotel} />
|
||||||
</div>
|
</div>
|
||||||
<RoomSelection rooms={rooms} />
|
<RoomSelection rooms={rooms} />
|
||||||
<FlexibilitySelection />
|
<FlexibilitySelection />
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ export default async function HotelPage() {
|
|||||||
include: ["RoomCategories"],
|
include: ["RoomCategories"],
|
||||||
})
|
})
|
||||||
if (!hotelData) return null
|
if (!hotelData) return null
|
||||||
const { attributes, roomCategories } = hotelData
|
const { hotel, roomCategories } = hotelData
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.pageContainer}>
|
<div className={styles.pageContainer}>
|
||||||
@@ -33,14 +33,14 @@ export default async function HotelPage() {
|
|||||||
<main className={styles.mainSection}>
|
<main className={styles.mainSection}>
|
||||||
<div className={styles.introContainer}>
|
<div className={styles.introContainer}>
|
||||||
<IntroSection
|
<IntroSection
|
||||||
hotelName={attributes.name}
|
hotelName={hotel.name}
|
||||||
hotelDescription={attributes.hotelContent.texts.descriptions.short}
|
hotelDescription={hotel.hotelContent.texts.descriptions.short}
|
||||||
location={attributes.location}
|
location={hotel.location}
|
||||||
address={attributes.address}
|
address={hotel.address}
|
||||||
tripAdvisor={attributes.ratings?.tripAdvisor}
|
tripAdvisor={hotel.ratings?.tripAdvisor}
|
||||||
/>
|
/>
|
||||||
<SidePeeks />
|
<SidePeeks />
|
||||||
<AmenitiesList detailedFacilities={attributes.detailedFacilities} />
|
<AmenitiesList detailedFacilities={hotel.detailedFacilities} />
|
||||||
</div>
|
</div>
|
||||||
<Rooms rooms={roomCategories} />
|
<Rooms rooms={roomCategories} />
|
||||||
</main>
|
</main>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { z } from "zod"
|
import { z } from "zod"
|
||||||
|
|
||||||
import { fromUppercaseToLangEnum } from "@/utils/languages"
|
import { fromUppercaseToLangEnum } from "@/server/utils"
|
||||||
|
|
||||||
const RatingsSchema = z
|
const RatingsSchema = z
|
||||||
.object({
|
.object({
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ export const hotelQueryRouter = router({
|
|||||||
})
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
attributes: validatedHotelData.data.data.attributes,
|
hotel: validatedHotelData.data.data.attributes,
|
||||||
roomCategories: roomCategories,
|
roomCategories: roomCategories,
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -26,3 +26,12 @@ const toApiLangMap: { [key in Lang]: string } = {
|
|||||||
[Lang.da]: "Da",
|
[Lang.da]: "Da",
|
||||||
[Lang.de]: "De",
|
[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}`
|
(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