import { getProfileSafely, getSelectedRoomAvailability, } from "@/lib/trpc/memoizedRequests" import Summary from "@/components/HotelReservation/EnterDetails/Summary" import { generateChildrenString, getQueryParamsForEnterDetails, mapChildrenFromString, } from "@/components/HotelReservation/SelectRate/RoomSelection/utils" import { SelectRateSearchParams } from "@/types/components/hotelReservation/selectRate/selectRate" import { LangParams, PageArgs, SearchParams } from "@/types/params" export default async function SummaryPage({ searchParams, }: PageArgs>) { const selectRoomParams = new URLSearchParams(searchParams) const { hotel, rooms, fromDate, toDate } = getQueryParamsForEnterDetails(selectRoomParams) const { adults, children, roomTypeCode, rateCode } = rooms[0] // TODO: Handle multiple rooms const availability = await getSelectedRoomAvailability({ hotelId: hotel, adults, children: children ? generateChildrenString(children) : undefined, roomStayStartDate: fromDate, roomStayEndDate: toDate, rateCode, roomTypeCode, }) const user = await getProfileSafely() if (!availability) { console.error("No hotel or availability data", availability) // TODO: handle this case return null } const prices = user && availability.memberRate ? { local: { price: availability.memberRate?.localPrice.pricePerStay, currency: availability.memberRate?.localPrice.currency, }, euro: { price: availability.memberRate?.requestedPrice?.pricePerStay, currency: availability.memberRate?.requestedPrice?.currency, }, } : { local: { price: availability.publicRate?.localPrice.pricePerStay, currency: availability.publicRate?.localPrice.currency, }, euro: { price: availability.publicRate?.requestedPrice?.pricePerStay, currency: availability.publicRate?.requestedPrice?.currency, }, } return ( ) }