diff --git a/components/Forms/BookingWidget/index.tsx b/components/Forms/BookingWidget/index.tsx index c6863f6f5..ade125cdc 100644 --- a/components/Forms/BookingWidget/index.tsx +++ b/components/Forms/BookingWidget/index.tsx @@ -33,33 +33,28 @@ export default function Form({ locations, type }: BookingWidgetFormProps) { const bookingFlowPage = locationData.type == "cities" ? selectHotel[lang] : selectRate[lang] + const bookingWidgetParams = new URLSearchParams(data.date) - const locationParam = - locationData.type == "cities" - ? "city=" + locationData.name - : "hotel=" + locationData.operaId - const dateParam = new URLSearchParams(data.date).toString() - const roomsParam = data.rooms.reduce((result, room, index) => { - result = result + `&rooms[${index}].adults=` + room.adults - result = - result + - room.children.reduce((childParams, child, childIndex) => { - childParams = - childParams + - `&rooms[${index}].child[${childIndex}].age=` + - child.age - childParams = - childParams + - `&rooms[${index}].child[${childIndex}].bed=` + - child.bed - return childParams - }, "") - return result - }, "") + if (locationData.type == "cities") + bookingWidgetParams.set("city", locationData.name) + else bookingWidgetParams.set("hotel", locationData.operaId || "") - router.push( - bookingFlowPage + "?" + locationParam + "&" + dateParam + roomsParam - ) + data.rooms.forEach((room, index) => { + bookingWidgetParams.set(`room[${index}].adults`, `${room.adults}`) + + room.children.map((child, childIndex) => { + bookingWidgetParams.set( + `room[${index}].child[${childIndex}].age`, + `${child.age}` + ) + bookingWidgetParams.set( + `room[${index}].child[${childIndex}].bed`, + `${child.bed}` + ) + }) + }) + + router.push(`${bookingFlowPage}?${bookingWidgetParams.toString()}`) } return (