24 lines
528 B
TypeScript
24 lines
528 B
TypeScript
import type { RouterOutput } from "@/lib/trpc/client"
|
|
|
|
export function getBookedHotelRoom(
|
|
hotel: RouterOutput["booking"]["confirmation"]["hotel"],
|
|
roomTypeCode: string
|
|
) {
|
|
const room = hotel.included?.rooms?.find((include) => {
|
|
return include.roomTypes.find((roomType) => roomType.code === roomTypeCode)
|
|
})
|
|
if (!room) {
|
|
return null
|
|
}
|
|
const bedType = room.roomTypes.find(
|
|
(roomType) => roomType.code === roomTypeCode
|
|
)
|
|
if (!bedType) {
|
|
return null
|
|
}
|
|
return {
|
|
...room,
|
|
bedType,
|
|
}
|
|
}
|