From 1e89fd4fe740c1918ce892797acb0c32816e4d99 Mon Sep 17 00:00:00 2001 From: Tobias Johansson Date: Wed, 25 Jun 2025 12:05:48 +0000 Subject: [PATCH] Merged in fix/SW-1702-new-search-map-view (pull request #2423) fix(SW-1702): Check if map view in Booking widget * fix(SW-1702): Check if map view in Booking widget * fix: change includes to endsWith Approved-by: Arvid Norlin --- .../components/Forms/BookingWidget/index.tsx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/apps/scandic-web/components/Forms/BookingWidget/index.tsx b/apps/scandic-web/components/Forms/BookingWidget/index.tsx index 850800f97..e56d3092e 100644 --- a/apps/scandic-web/components/Forms/BookingWidget/index.tsx +++ b/apps/scandic-web/components/Forms/BookingWidget/index.tsx @@ -1,12 +1,16 @@ "use client" -import { useRouter } from "next/navigation" +import { usePathname, useRouter } from "next/navigation" import { useTransition } from "react" import { Form as FormRAC } from "react-aria-components" import { useFormContext } from "react-hook-form" import { REDEMPTION } from "@/constants/booking" -import { selectHotel, selectRate } from "@/constants/routes/hotelReservation" +import { + selectHotel, + selectHotelMap, + selectRate, +} from "@/constants/routes/hotelReservation" import useLang from "@/hooks/useLang" import { trackBookingSearchClick } from "@/utils/tracking/booking" @@ -27,6 +31,7 @@ const formId = "booking-widget" export default function Form({ type, onClose }: BookingWidgetFormProps) { const router = useRouter() + const pathname = usePathname() const lang = useLang() const [isPending, startTransition] = useTransition() @@ -39,7 +44,12 @@ export default function Form({ type, onClose }: BookingWidgetFormProps) { function onSubmit(data: BookingWidgetSchema) { trackBookingSearchClick(data.search, data.hotel ? "hotel" : "destination") - const bookingFlowPage = data.hotel ? selectRate(lang) : selectHotel(lang) + const isMapView = pathname.endsWith("/map") + const bookingFlowPage = data.hotel + ? selectRate(lang) + : isMapView + ? selectHotelMap(lang) + : selectHotel(lang) const bookingWidgetParams = serializeBookingSearchParams({ rooms: data.rooms, ...data.date,