diff --git a/apps/scandic-web/components/HotelReservation/BookingConfirmation/Promos/index.tsx b/apps/scandic-web/components/HotelReservation/BookingConfirmation/Promos/index.tsx index c35b08676..13b37fc70 100644 --- a/apps/scandic-web/components/HotelReservation/BookingConfirmation/Promos/index.tsx +++ b/apps/scandic-web/components/HotelReservation/BookingConfirmation/Promos/index.tsx @@ -1,9 +1,8 @@ "use client" +import { useEffect } from "react" import { useIntl } from "react-intl" -import { homeHrefs } from "@/constants/homeHrefs" -import { myBooking } from "@/constants/myBooking" -import { env } from "@/env/client" +import { myStay } from "@/constants/routes/myStay" import useLang from "@/hooks/useLang" @@ -13,22 +12,30 @@ import styles from "./promos.module.css" import type { PromosProps } from "@/types/components/hotelReservation/bookingConfirmation/promos" -export default function Promos({ - confirmationNumber, - hotelId, - lastName, -}: PromosProps) { +export default function Promos({ booking }: PromosProps) { const intl = useIntl() const lang = useLang() - const homeUrl = homeHrefs[env.NEXT_PUBLIC_NODE_ENV][lang] - const myBookingUrl = myBooking[env.NEXT_PUBLIC_NODE_ENV][lang] + const { refId, confirmationNumber, hotelId } = 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 (