feat: Convert Selected-Room to Steplike design and fix select-rate link

This commit is contained in:
Arvid Norlin
2024-11-04 16:11:25 +01:00
parent 7bf89e80ff
commit e8e23a2113
10 changed files with 148 additions and 107 deletions

View File

@@ -1,6 +1,7 @@
import { getFormattedUrlQueryParams } from "@/utils/url"
import { BedTypeEnum } from "@/types/components/bookingWidget/enums"
import { BookingData } from "@/types/components/hotelReservation/enterDetails/bookingData"
import type {
Child,
SelectRateSearchParams,
@@ -52,3 +53,26 @@ export function getQueryParamsForEnterDetails(searchParams: URLSearchParams) {
rateCode: room[0].ratecode,
}
}
export function createSelectRateUrl(roomData: BookingData) {
const { hotel, fromDate, toDate } = roomData
const params = new URLSearchParams({ fromDate, toDate, hotel })
roomData.room.forEach((room, index) => {
params.set(`room[${index}].adults`, room.adults.toString())
if (room.child) {
room.child.forEach((child, childIndex) => {
params.set(
`room[${index}].child[${childIndex}].age`,
child.age.toString()
)
params.set(
`room[${index}].child[${childIndex}].bed`,
child.bed.toString()
)
})
}
})
return params
}