Files
web/apps/scandic-web/components/HotelReservation/MyStay/ReferenceCard/Actions/NotUpcoming/index.tsx
Christel Westerberg 6083eea5cc Merged in fix/STAY-65-manage-stay (pull request #3089)
Fix/STAY-65 manage stay

* fix: Disable manage stay for past bookings

* fix: handle past and cancelled stay the same

* fix: indentify past booking

* fix: refactor to use design system components


Approved-by: Erik Tiekstra
2025-11-07 06:43:13 +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: [mainRoom, ...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 />
</>
)
}