sub-task/ SW-695 Prefill Guests data in booking widget
This commit is contained in:
@@ -9,6 +9,7 @@ import Form from "@/components/Forms/BookingWidget"
|
||||
import { bookingWidgetSchema } from "@/components/Forms/BookingWidget/schema"
|
||||
import { CloseLargeIcon } from "@/components/Icons"
|
||||
import { debounce } from "@/utils/debounce"
|
||||
import { getFormattedUrlQueryParams } from "@/utils/url"
|
||||
|
||||
import getHotelReservationQueryParams from "../HotelReservation/SelectRate/RoomSelection/utils"
|
||||
import MobileToggleButton from "./MobileToggleButton"
|
||||
@@ -18,6 +19,7 @@ import styles from "./bookingWidget.module.css"
|
||||
import type {
|
||||
BookingWidgetClientProps,
|
||||
BookingWidgetSchema,
|
||||
BookingWidgetSearchParams,
|
||||
} from "@/types/components/bookingWidget"
|
||||
import type { Location } from "@/types/trpc/routers/hotel/locations"
|
||||
|
||||
@@ -36,12 +38,14 @@ export default function BookingWidgetClient({
|
||||
? JSON.parse(sessionStorageSearchData)
|
||||
: undefined
|
||||
|
||||
const bookingWidgetSearchParams = searchParams
|
||||
? new URLSearchParams(searchParams)
|
||||
: undefined
|
||||
const bookingWidgetSearchData = bookingWidgetSearchParams
|
||||
? getHotelReservationQueryParams(bookingWidgetSearchParams)
|
||||
: undefined
|
||||
const bookingWidgetSearchData: BookingWidgetSearchParams | undefined =
|
||||
searchParams
|
||||
? (getFormattedUrlQueryParams(new URLSearchParams(searchParams), {
|
||||
adults: "number",
|
||||
age: "number",
|
||||
bed: "number",
|
||||
}) as BookingWidgetSearchParams)
|
||||
: undefined
|
||||
|
||||
const getLocationObj = (destination: string): Location | undefined => {
|
||||
if (destination) {
|
||||
@@ -83,7 +87,7 @@ export default function BookingWidgetClient({
|
||||
// UTC is required to handle requests from far away timezones https://scandichotels.atlassian.net/browse/SWAP-6375 & PET-507
|
||||
// This is specifically to handle timezones falling in different dates.
|
||||
fromDate: isDateParamValid
|
||||
? bookingWidgetSearchData?.fromDate.toString()
|
||||
? bookingWidgetSearchData?.fromDate?.toString()
|
||||
: dt().utc().format("YYYY-MM-DD"),
|
||||
toDate: isDateParamValid
|
||||
? bookingWidgetSearchData?.toDate?.toString()
|
||||
@@ -92,10 +96,10 @@ export default function BookingWidgetClient({
|
||||
bookingCode: "",
|
||||
redemption: false,
|
||||
voucher: false,
|
||||
rooms: [
|
||||
rooms: bookingWidgetSearchData?.room ?? [
|
||||
{
|
||||
adults: 1,
|
||||
children: [],
|
||||
child: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user