chore: Cleanup booking widget with types and other minor issues
This commit is contained in:
@@ -97,7 +97,7 @@ export default function BookingWidgetClient({
|
||||
const defaultRoomsData: BookingWidgetSchema["rooms"] = params.rooms?.map(
|
||||
(room) => ({
|
||||
adults: room.adults,
|
||||
childrenInRoom: room.childrenInRoom ?? [],
|
||||
childrenInRoom: room.childrenInRoom,
|
||||
})
|
||||
) ?? [
|
||||
{
|
||||
@@ -149,21 +149,18 @@ export default function BookingWidgetClient({
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
const debouncedResizeHandler = debounce(function ([
|
||||
entry,
|
||||
]: ResizeObserverEntry[]) {
|
||||
if (entry.contentRect.width > 1366) {
|
||||
closeMobileSearch()
|
||||
}
|
||||
})
|
||||
const observer = new ResizeObserver(debouncedResizeHandler)
|
||||
const observer = new ResizeObserver(
|
||||
debounce(([entry]) => {
|
||||
if (entry.contentRect.width > 1366) {
|
||||
closeMobileSearch()
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
observer.observe(document.body)
|
||||
|
||||
return () => {
|
||||
if (observer) {
|
||||
observer.unobserve(document.body)
|
||||
}
|
||||
observer.unobserve(document.body)
|
||||
}
|
||||
}, [])
|
||||
|
||||
@@ -176,13 +173,15 @@ export default function BookingWidgetClient({
|
||||
? JSON.parse(sessionStorageSearchData)
|
||||
: undefined
|
||||
|
||||
initialSelectedLocation?.name &&
|
||||
if (initialSelectedLocation?.name) {
|
||||
methods.setValue("search", initialSelectedLocation.name)
|
||||
sessionStorageSearchData &&
|
||||
}
|
||||
if (sessionStorageSearchData) {
|
||||
methods.setValue(
|
||||
"location",
|
||||
encodeURIComponent(sessionStorageSearchData)
|
||||
)
|
||||
}
|
||||
}
|
||||
}, [methods, selectedLocation])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user