From 35a2ae9dcc2c86831ce43d259fe7ba0bb280bab9 Mon Sep 17 00:00:00 2001 From: Michael Zetterberg Date: Tue, 6 May 2025 09:26:02 +0200 Subject: [PATCH] feat: allow direct access to my stay from booking confirmation --- .../Confirmation/index.tsx | 4 +-- .../Header/Actions/ManageBooking.tsx | 25 +++++++++++++++++-- .../BookingConfirmation/Header/index.tsx | 10 ++------ .../BookingConfirmation/index.tsx | 7 +----- .../actions/manageBooking.ts | 7 +++--- .../bookingConfirmation.ts | 1 - .../bookingConfirmation/header.ts | 1 - 7 files changed, 32 insertions(+), 23 deletions(-) diff --git a/apps/scandic-web/components/HotelReservation/BookingConfirmation/Confirmation/index.tsx b/apps/scandic-web/components/HotelReservation/BookingConfirmation/Confirmation/index.tsx index 88b99038c..fc68de76e 100644 --- a/apps/scandic-web/components/HotelReservation/BookingConfirmation/Confirmation/index.tsx +++ b/apps/scandic-web/components/HotelReservation/BookingConfirmation/Confirmation/index.tsx @@ -1,4 +1,5 @@ "use client" + import { useRef } from "react" import Header from "@/components/HotelReservation/BookingConfirmation/Header" @@ -11,13 +12,12 @@ export default function Confirmation({ booking, hotel, children, - refId, }: React.PropsWithChildren) { const mainRef = useRef(null) return (
-
+
{children}
) diff --git a/apps/scandic-web/components/HotelReservation/BookingConfirmation/Header/Actions/ManageBooking.tsx b/apps/scandic-web/components/HotelReservation/BookingConfirmation/Header/Actions/ManageBooking.tsx index 28a81406d..b8766c386 100644 --- a/apps/scandic-web/components/HotelReservation/BookingConfirmation/Header/Actions/ManageBooking.tsx +++ b/apps/scandic-web/components/HotelReservation/BookingConfirmation/Header/Actions/ManageBooking.tsx @@ -1,15 +1,36 @@ "use client" + +import { useEffect } from "react" import { useIntl } from "react-intl" import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon" +import { myStay } from "@/constants/routes/myStay" + import Button from "@/components/TempDesignSystem/Button" import Link from "@/components/TempDesignSystem/Link" +import useLang from "@/hooks/useLang" import type { ManageBookingProps } from "@/types/components/hotelReservation/bookingConfirmation/actions/manageBooking" -export default function ManageBooking({ bookingUrl }: ManageBookingProps) { +export default function ManageBooking({ booking }: ManageBookingProps) { const intl = useIntl() + const lang = useLang() + + const { refId, confirmationNumber } = booking + const { email, firstName, lastName } = booking.guest + useEffect(() => { + // Setting the `bv` cookie allows direct access to My stay without prompting for more information. + const value = new URLSearchParams({ + email, + firstName, + lastName, + confirmationNumber, + }).toString() + document.cookie = `bv=${encodeURIComponent(value)}; Path=/; Max-Age=600; Secure; SameSite=Strict` + }, [confirmationNumber, email, firstName, lastName]) + + const myStayURL = `${myStay[lang]}?RefId=${encodeURIComponent(refId)}` return (