fix: make summary sticky
This commit is contained in:
@@ -20,23 +20,31 @@ export default async function SummaryPage({
|
||||
const { hotel, adults, children, roomTypeCode, rateCode, fromDate, toDate } =
|
||||
getQueryParamsForEnterDetails(selectRoomParams)
|
||||
|
||||
const user = await getProfileSafely()
|
||||
const hotelData = await getHotelData(hotel, params.lang, undefined, [HotelIncludeEnum.RoomCategories])
|
||||
const availability = await getRoomAvailability({
|
||||
hotelId: parseInt(hotel),
|
||||
adults,
|
||||
children,
|
||||
roomStayStartDate: fromDate,
|
||||
roomStayEndDate: toDate,
|
||||
})
|
||||
const [user, hotelData, availability] = await Promise.all([
|
||||
getProfileSafely(),
|
||||
getHotelData({
|
||||
hotelId: hotel,
|
||||
language: params.lang,
|
||||
include: [HotelIncludeEnum.RoomCategories],
|
||||
}),
|
||||
getRoomAvailability({
|
||||
hotelId: parseInt(hotel),
|
||||
adults,
|
||||
children,
|
||||
roomStayStartDate: fromDate,
|
||||
roomStayEndDate: toDate,
|
||||
}),
|
||||
])
|
||||
|
||||
if (!hotelData?.data || !hotelData?.included || !availability) {
|
||||
console.error("No hotel or availability data", hotelData, availability)
|
||||
|
||||
// TODO: handle this case
|
||||
return null
|
||||
}
|
||||
|
||||
const cancellationText =
|
||||
availability?.rateDefinitions.find((rate) => rate.rateCode === rateCode)
|
||||
?.cancellationText ?? ""
|
||||
const chosenRoom = availability.roomConfigurations.find(
|
||||
(availRoom) => availRoom.roomTypeCode === roomTypeCode
|
||||
)
|
||||
@@ -47,28 +55,31 @@ export default async function SummaryPage({
|
||||
return null
|
||||
}
|
||||
|
||||
const cancellationText =
|
||||
availability?.rateDefinitions.find((rate) => rate.rateCode === rateCode)
|
||||
?.cancellationText ?? ""
|
||||
const memberRate = chosenRoom.products.find(
|
||||
(rate) => rate.productType.member?.rateCode === rateCode
|
||||
)?.productType.member
|
||||
|
||||
const memberPrice =
|
||||
chosenRoom.products.find(
|
||||
(rate) => rate.productType.member?.rateCode === rateCode
|
||||
)?.productType.member?.localPrice.pricePerStay ?? "0"
|
||||
const publicRate = chosenRoom.products.find(
|
||||
(rate) => rate.productType.public?.rateCode === rateCode
|
||||
)?.productType.public
|
||||
|
||||
const publicPrice =
|
||||
chosenRoom.products.find(
|
||||
(rate) => rate.productType.public?.rateCode === rateCode
|
||||
)?.productType.public?.localPrice.pricePerStay ?? "0"
|
||||
|
||||
const price = user ? memberPrice : publicPrice
|
||||
const prices = user
|
||||
? {
|
||||
local: memberRate?.localPrice.pricePerStay,
|
||||
euro: memberRate?.requestedPrice?.pricePerStay,
|
||||
}
|
||||
: {
|
||||
local: publicRate?.localPrice.pricePerStay,
|
||||
euro: publicRate?.requestedPrice?.pricePerStay,
|
||||
}
|
||||
|
||||
return (
|
||||
<Summary
|
||||
isMember={!!user}
|
||||
room={{
|
||||
roomType: chosenRoom.roomType,
|
||||
price: formatNumber(parseInt(price)),
|
||||
localPrice: formatNumber(parseInt(prices.local ?? "0")),
|
||||
euroPrice: formatNumber(parseInt(prices.euro ?? "0")),
|
||||
adults,
|
||||
cancellationText,
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user