"use client" import { useEffect } from "react" import { useIntl } from "react-intl" import { useBookingFlowConfig } from "../../../bookingFlowConfig/bookingFlowConfigContext" import useLang from "../../../hooks/useLang" import { Promo } from "./Promo" import styles from "./promos.module.css" import type { BookingConfirmation } from "@scandic-hotels/trpc/types/bookingConfirmation" import type { AdditionalInfoCookieValue } from "../../../types/components/findMyBooking/additionalInfoCookieValue" type PromosProps = Pick export function Promos({ booking }: PromosProps) { const intl = useIntl() const lang = useLang() const { routes } = useBookingFlowConfig() 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: AdditionalInfoCookieValue = { email, firstName, lastName, confirmationNumber, } document.cookie = `bv=${JSON.stringify(value)}; Path=/; Max-Age=600; Secure; SameSite=Strict` }, [confirmationNumber, email, firstName, lastName]) const myStayURL = `${routes.myStay[lang]}?RefId=${encodeURIComponent(refId)}` return (
) }