diff --git a/apps/scandic-web/components/HotelReservation/HotelCard/index.tsx b/apps/scandic-web/components/HotelReservation/HotelCard/index.tsx index 324d9efe5..756c9dc4a 100644 --- a/apps/scandic-web/components/HotelReservation/HotelCard/index.tsx +++ b/apps/scandic-web/components/HotelReservation/HotelCard/index.tsx @@ -1,8 +1,12 @@ "use client" import { cx } from "class-variance-authority" -import { useParams } from "next/dist/client/components/navigation" -import { useRouter, useSearchParams } from "next/navigation" +import { + type ReadonlyURLSearchParams, + useParams, + useRouter, + useSearchParams, +} from "next/navigation" import { memo } from "react" import { useIntl } from "react-intl" @@ -180,8 +184,11 @@ function HotelCard({ /> {!availability.productType ? ( @@ -268,19 +275,41 @@ function HotelCard({ } interface PricesWrapperProps { - href: string - isClickable?: boolean children: React.ReactNode + isClickable?: boolean + hotelId: string + pathname: string + removeBookingCodeFromSearchParams: boolean + searchParams: ReadonlyURLSearchParams } -function PricesWrapper({ href, isClickable, children }: PricesWrapperProps) { +function PricesWrapper({ + children, + hotelId, + isClickable, + pathname, + removeBookingCodeFromSearchParams, + searchParams, +}: PricesWrapperProps) { const content =
{children}
- return isClickable ? ( - + if (!isClickable) { + return content + } + + const params = new URLSearchParams(searchParams) + params.delete("city") + params.set("hotel", hotelId) + + if (removeBookingCodeFromSearchParams) { + params.delete("bookingCode") + } + + const href = `${pathname}?${params.toString()}` + + return ( + {content} - ) : ( - content ) }