fix(BOOK-418): Refactored StandaloneHotelCardDialog and fixed pricing issue when using redemption or booking codes

Approved-by: Bianca Widstam
This commit is contained in:
Erik Tiekstra
2025-10-20 10:40:38 +00:00
parent 710309b7eb
commit 3e3a7fc423
12 changed files with 605 additions and 412 deletions

View File

@@ -0,0 +1,25 @@
import { usePathname, useSearchParams } from "next/navigation"
import { useMemo } from "react"
export function useUrlWithSearchParam(
searchParam: { key: string; value: string },
path?: string | null
) {
const { key, value } = searchParam
const pathname = path ?? usePathname()
const searchParams = useSearchParams()
return useMemo(() => {
const newUrl = new URL(pathname, window.location.origin)
// Preserve existing search params
searchParams.forEach((val, key) => {
newUrl.searchParams.set(key, val)
})
// Set or override the specific search param
newUrl.searchParams.set(key, value)
return newUrl
}, [pathname, searchParams, key, value])
}