diff --git a/components/ContentType/HotelPage/Rooms/index.tsx b/components/ContentType/HotelPage/Rooms/index.tsx index b6fd241f5..52b0bebbf 100644 --- a/components/ContentType/HotelPage/Rooms/index.tsx +++ b/components/ContentType/HotelPage/Rooms/index.tsx @@ -22,20 +22,20 @@ export function Rooms({ rooms }: RoomsProps) { const mappedRooms = rooms .map((room) => { - const size = `${room.attributes.roomSize.min} - ${room.attributes.roomSize.max} m²` + const size = `${room.roomSize.min} - ${room.roomSize.max} m²` const personLabel = - room.attributes.occupancy.total === 1 + room.occupancy.total === 1 ? intl.formatMessage({ id: "hotelPages.rooms.roomCard.person" }) : intl.formatMessage({ id: "hotelPages.rooms.roomCard.persons" }) - const subtitle = `${size} (${room.attributes.occupancy.total} ${personLabel})` + const subtitle = `${size} (${room.occupancy.total} ${personLabel})` return { id: room.id, - images: room.attributes.content.images, - title: room.attributes.name, + images: room.images, + title: room.name, subtitle: subtitle, - sortOrder: room.attributes.sortOrder, + sortOrder: room.sortOrder, popularChoice: null, } }) diff --git a/components/HotelReservation/SelectRate/RoomSelection/RoomCard/index.tsx b/components/HotelReservation/SelectRate/RoomSelection/RoomCard/index.tsx index d39f90bd5..4404b562c 100644 --- a/components/HotelReservation/SelectRate/RoomSelection/RoomCard/index.tsx +++ b/components/HotelReservation/SelectRate/RoomSelection/RoomCard/index.tsx @@ -53,16 +53,16 @@ export default function RoomCard({ } const roomSize = roomCategories.find( - (category) => category.attributes.name === roomConfiguration.roomType - )?.attributes.roomSize + (category) => category.name === roomConfiguration.roomType + )?.roomSize const occupancy = roomCategories.find( - (category) => category.attributes.name === roomConfiguration.roomType - )?.attributes.occupancy.total + (category) => category.name === roomConfiguration.roomType + )?.occupancy.total const roomDescription = roomCategories.find( - (room) => room.attributes.name === roomConfiguration.roomType - )?.attributes.content.texts.descriptions.short + (room) => room.name === roomConfiguration.roomType + )?.descriptions.short return (
diff --git a/server/routers/hotels/output.ts b/server/routers/hotels/output.ts index 8d8be4274..ae889441e 100644 --- a/server/routers/hotels/output.ts +++ b/server/routers/hotels/output.ts @@ -425,26 +425,39 @@ const roomFacilitiesSchema = z.object({ sortOrder: z.number(), }) -export const roomSchema = z.object({ - attributes: z.object({ - name: z.string(), - sortOrder: z.number(), - content: roomContentSchema, - roomTypes: z.array(roomTypesSchema), - roomFacilities: z.array(roomFacilitiesSchema), - occupancy: z.object({ - total: z.number(), - adults: z.number(), - children: z.number(), +export const roomSchema = z + .object({ + attributes: z.object({ + name: z.string(), + sortOrder: z.number(), + content: roomContentSchema, + roomTypes: z.array(roomTypesSchema), + roomFacilities: z.array(roomFacilitiesSchema), + occupancy: z.object({ + total: z.number(), + adults: z.number(), + children: z.number(), + }), + roomSize: z.object({ + min: z.number(), + max: z.number(), + }), }), - roomSize: z.object({ - min: z.number(), - max: z.number(), - }), - }), - id: z.string(), - type: z.enum(["roomcategories"]), -}) + id: z.string(), + type: z.enum(["roomcategories"]), + }) + .transform((data) => { + return { + descriptions: data.attributes.content.texts.descriptions, + id: data.id, + images: data.attributes.content.images, + name: data.attributes.name, + occupancy: data.attributes.occupancy, + roomSize: data.attributes.roomSize, + sortOrder: data.attributes.sortOrder, + type: data.type, + } + }) const merchantInformationSchema = z.object({ webMerchantId: z.string(), diff --git a/types/components/hotelPage/roomCard.ts b/types/components/hotelPage/roomCard.ts index 4d07f170c..425edc128 100644 --- a/types/components/hotelPage/roomCard.ts +++ b/types/components/hotelPage/roomCard.ts @@ -2,7 +2,7 @@ import type { RoomData } from "@/types/hotel" export interface RoomCardProps { id: string - images: RoomData["attributes"]["content"]["images"] + images: RoomData["images"] title: string subtitle: string badgeTextTransKey: string | null