Files
web/apps/scandic-web/components/HotelReservation/MyStay/ReferenceCard/Actions/NotUpcoming/index.tsx
Christel Westerberg 6b64cb00d6 Merged in fix/correct-rooms-rebook (pull request #3238)
fix(STAY-130): Make sure we pass correct amount of rooms to rebook url

* fix: Make sure we pass correct amount of rooms to rebook url


Approved-by: Erik Tiekstra
Approved-by: Anton Gunnarsson
Approved-by: Matilda Landström
2025-11-28 09:35:00 +00:00

66 lines
1.7 KiB
TypeScript

"use client"
import { usePathname } from "next/navigation"
import { useIntl } from "react-intl"
import { serializeBookingSearchParams } from "@scandic-hotels/booking-flow/utils/url"
import { RateTypeEnum } from "@scandic-hotels/common/constants/rateType"
import ButtonLink from "@scandic-hotels/design-system/ButtonLink"
import { isWebview } from "@/constants/routes/webviews"
import { useMyStayStore } from "@/stores/my-stay"
import useLang from "@/hooks/useLang"
import CustomerSupport from "./CustomerSupport"
import type { BookingWidgetSearchData } from "@scandic-hotels/booking-flow/BookingWidget"
export default function NotUpcoming() {
const intl = useIntl()
const pathname = usePathname()
const { rooms, mainRoom } = useMyStayStore((state) => ({
rooms: state.rooms,
mainRoom: state.mainRoom,
}))
const lang = useLang()
const bookingData: BookingWidgetSearchData = {
hotelId: mainRoom.hotelId,
rooms: rooms.map((room) => ({
adults: room.adults,
childrenInRoom: room.childrenInRoom,
})),
}
if (mainRoom.bookingCode) {
bookingData.bookingCode = mainRoom.bookingCode
}
if (mainRoom.bookingType === RateTypeEnum.Redemption) {
bookingData.searchType = "redemption"
}
const rebookUrl = serializeBookingSearchParams(bookingData)
const url = `/${lang}?${rebookUrl}`
return (
<>
{!isWebview(pathname) && (
<ButtonLink
variant="Tertiary"
size="Medium"
href={url}
typography="Body/Supporting text (caption)/smBold"
>
{intl.formatMessage({
defaultMessage: "Rebook",
id: "myStay.referenceCard.actions.rebook",
})}
</ButtonLink>
)}
<CustomerSupport />
</>
)
}