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