fix: make summary sticky
This commit is contained in:
@@ -6,7 +6,7 @@ import { create, useStore } from "zustand"
|
||||
import { bedTypeSchema } from "@/components/HotelReservation/EnterDetails/BedType/schema"
|
||||
import { breakfastStoreSchema } from "@/components/HotelReservation/EnterDetails/Breakfast/schema"
|
||||
import { detailsSchema } from "@/components/HotelReservation/EnterDetails/Details/schema"
|
||||
import { getHotelReservationQueryParams } from "@/components/HotelReservation/SelectRate/RoomSelection/utils"
|
||||
import { getQueryParamsForEnterDetails } from "@/components/HotelReservation/SelectRate/RoomSelection/utils"
|
||||
|
||||
import type { BookingData } from "@/types/components/hotelReservation/enterDetails/bookingData"
|
||||
import { BreakfastPackage } from "@/types/components/hotelReservation/enterDetails/breakfast"
|
||||
@@ -37,22 +37,6 @@ interface EnterDetailsState {
|
||||
closeSidePeek: () => void
|
||||
}
|
||||
|
||||
function getUpdatedValue<T>(
|
||||
searchParams: URLSearchParams,
|
||||
key: string,
|
||||
defaultValue: T
|
||||
): T {
|
||||
const value = searchParams.get(key)
|
||||
if (value === null) return defaultValue
|
||||
if (typeof defaultValue === "number")
|
||||
return parseInt(value, 10) as unknown as T
|
||||
if (typeof defaultValue === "boolean")
|
||||
return (value === "true") as unknown as T
|
||||
if (defaultValue instanceof Date) return new Date(value) as unknown as T
|
||||
|
||||
return value as unknown as T
|
||||
}
|
||||
|
||||
export function initEditDetailsState(
|
||||
currentStep: StepEnum,
|
||||
searchParams: ReadonlyURLSearchParams
|
||||
@@ -62,32 +46,9 @@ export function initEditDetailsState(
|
||||
? sessionStorage.getItem(SESSION_STORAGE_KEY)
|
||||
: null
|
||||
|
||||
const today = new Date()
|
||||
const tomorrow = new Date()
|
||||
tomorrow.setDate(today.getDate() + 1)
|
||||
|
||||
let roomData: BookingData
|
||||
if (searchParams?.size) {
|
||||
roomData = getHotelReservationQueryParams(searchParams)
|
||||
|
||||
roomData.room = roomData.room.map((room, index) => ({
|
||||
...room,
|
||||
adults: getUpdatedValue(
|
||||
searchParams,
|
||||
`room[${index}].adults`,
|
||||
room.adults
|
||||
),
|
||||
roomtypecode: getUpdatedValue(
|
||||
searchParams,
|
||||
`room[${index}].roomtypecode`,
|
||||
room.roomtypecode
|
||||
),
|
||||
ratecode: getUpdatedValue(
|
||||
searchParams,
|
||||
`room[${index}].ratecode`,
|
||||
room.ratecode
|
||||
),
|
||||
}))
|
||||
roomData = getQueryParamsForEnterDetails(searchParams)
|
||||
}
|
||||
|
||||
const defaultUserData: EnterDetailsState["userData"] = {
|
||||
|
||||
Reference in New Issue
Block a user