refactor(SW-96): use images from API & reduce data returned in getHotel
This commit is contained in:
@@ -13,6 +13,7 @@ import {
|
||||
publicProcedure,
|
||||
router,
|
||||
} from "@/server/trpc"
|
||||
import { extractHotelImages } from "@/server/routers/utils/hotels"
|
||||
import { toApiLang } from "@/server/utils"
|
||||
|
||||
import {
|
||||
@@ -153,6 +154,10 @@ export const hotelQueryRouter = router({
|
||||
|
||||
const included = validatedHotelData.data.included || []
|
||||
|
||||
const hotelAttributes = validatedHotelData.data.data.attributes
|
||||
|
||||
const images = extractHotelImages(hotelAttributes)
|
||||
|
||||
const roomCategories = included
|
||||
? included
|
||||
.filter((item) => item.type === "roomcategories")
|
||||
@@ -193,8 +198,14 @@ export const hotelQueryRouter = router({
|
||||
})
|
||||
)
|
||||
return {
|
||||
hotel: validatedHotelData.data.data.attributes,
|
||||
roomCategories: roomCategories,
|
||||
hotelName: hotelAttributes.name,
|
||||
hotelDescription: hotelAttributes.hotelContent.texts.descriptions.short,
|
||||
hotelLocation: hotelAttributes.location,
|
||||
hotelAddress: hotelAttributes.address,
|
||||
hotelRatings: hotelAttributes.ratings,
|
||||
hotelDetailedFacilities: hotelAttributes.detailedFacilities,
|
||||
hotelImages: images,
|
||||
roomCategories,
|
||||
}
|
||||
}),
|
||||
rates: router({
|
||||
|
||||
Reference in New Issue
Block a user