fix: add packages data from query param
This commit is contained in:
@@ -17,9 +17,11 @@ export default async function SummaryPage({
|
||||
searchParams,
|
||||
}: PageArgs<LangParams, SearchParams<SelectRateSearchParams>>) {
|
||||
const selectRoomParams = new URLSearchParams(searchParams)
|
||||
const { hotel, adults, children, roomTypeCode, rateCode, fromDate, toDate } =
|
||||
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,
|
||||
@@ -39,25 +41,25 @@ export default async function SummaryPage({
|
||||
|
||||
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.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,
|
||||
},
|
||||
}
|
||||
local: {
|
||||
price: availability.publicRate?.localPrice.pricePerStay,
|
||||
currency: availability.publicRate?.localPrice.currency,
|
||||
},
|
||||
euro: {
|
||||
price: availability.publicRate?.requestedPrice?.pricePerStay,
|
||||
currency: availability.publicRate?.requestedPrice?.currency,
|
||||
},
|
||||
}
|
||||
|
||||
return (
|
||||
<Summary
|
||||
|
||||
@@ -39,14 +39,13 @@ export default async function StepPage({
|
||||
const selectRoomParams = new URLSearchParams(searchParams)
|
||||
const {
|
||||
hotel: hotelId,
|
||||
adults,
|
||||
children,
|
||||
roomTypeCode,
|
||||
rateCode,
|
||||
rooms,
|
||||
fromDate,
|
||||
toDate,
|
||||
} = getQueryParamsForEnterDetails(selectRoomParams)
|
||||
|
||||
const { adults, children, roomTypeCode, rateCode } = rooms[0] // TODO: Handle multiple rooms
|
||||
|
||||
const childrenAsString = children && generateChildrenString(children)
|
||||
|
||||
const breakfastInput = { adults, fromDate, hotelId, toDate }
|
||||
|
||||
@@ -2,6 +2,7 @@ import { getFormattedUrlQueryParams } from "@/utils/url"
|
||||
|
||||
import { BedTypeEnum } from "@/types/components/bookingWidget/enums"
|
||||
import { BookingData } from "@/types/components/hotelReservation/enterDetails/bookingData"
|
||||
import { RoomPackageCodeEnum } from "@/types/components/hotelReservation/selectRate/roomFilter"
|
||||
import type {
|
||||
Child,
|
||||
SelectRateSearchParams,
|
||||
@@ -41,16 +42,21 @@ export function mapChildrenFromString(rawChildrenString: string) {
|
||||
})
|
||||
}
|
||||
|
||||
export function getQueryParamsForEnterDetails(searchParams: URLSearchParams) {
|
||||
export function getQueryParamsForEnterDetails(
|
||||
searchParams: URLSearchParams
|
||||
): BookingData {
|
||||
const selectRoomParamsObject = getHotelReservationQueryParams(searchParams)
|
||||
|
||||
const { room } = selectRoomParamsObject
|
||||
return {
|
||||
...selectRoomParamsObject,
|
||||
adults: room[0].adults, // TODO: Handle multiple rooms
|
||||
children: room[0].child, // TODO: Handle multiple rooms and children
|
||||
roomTypeCode: room[0].roomtype,
|
||||
rateCode: room[0].ratecode,
|
||||
rooms: room.map((room) => ({
|
||||
adults: room.adults, // TODO: Handle multiple rooms
|
||||
child: room.child, // TODO: Handle multiple rooms and children
|
||||
roomTypeCode: room.roomtype,
|
||||
rateCode: room.ratecode,
|
||||
packages: room.packages?.split(",") as RoomPackageCodeEnum[],
|
||||
})),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,11 +64,11 @@ export function createSelectRateUrl(roomData: BookingData) {
|
||||
const { hotel, fromDate, toDate } = roomData
|
||||
const params = new URLSearchParams({ fromDate, toDate, hotel })
|
||||
|
||||
roomData.room.forEach((room, index) => {
|
||||
roomData.rooms.forEach((room, index) => {
|
||||
params.set(`room[${index}].adults`, room.adults.toString())
|
||||
|
||||
if (room.child) {
|
||||
room.child.forEach((child, childIndex) => {
|
||||
if (room.children) {
|
||||
room.children.forEach((child, childIndex) => {
|
||||
params.set(
|
||||
`room[${index}].child[${childIndex}].age`,
|
||||
child.age.toString()
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { BedTypeEnum } from "../../bookingWidget/enums"
|
||||
import { RoomPackageCodeEnum } from "../selectRate/roomFilter"
|
||||
|
||||
interface Child {
|
||||
bed: BedTypeEnum
|
||||
@@ -7,15 +8,16 @@ interface Child {
|
||||
|
||||
interface Room {
|
||||
adults: number
|
||||
roomtype?: string
|
||||
ratecode?: string
|
||||
child?: Child[]
|
||||
roomTypeCode: string
|
||||
rateCode: string
|
||||
children?: Child[]
|
||||
packages?: RoomPackageCodeEnum[]
|
||||
}
|
||||
export interface BookingData {
|
||||
hotel: string
|
||||
fromDate: string
|
||||
toDate: string
|
||||
room: Room[]
|
||||
rooms: Room[]
|
||||
}
|
||||
|
||||
type Price = {
|
||||
|
||||
@@ -13,6 +13,7 @@ interface Room {
|
||||
ratecode: string
|
||||
counterratecode?: string
|
||||
child?: Child[]
|
||||
packages?: string
|
||||
}
|
||||
|
||||
export interface SelectRateSearchParams {
|
||||
|
||||
Reference in New Issue
Block a user