chore(SW-3397) Moved Confirmation component with Header to booking-flow package * chore(SW-3397) Moved Confirmation component with Header to booking-flow package * chore(SW-3397): Optimised code Approved-by: Anton Gunnarsson
65 lines
2.1 KiB
TypeScript
65 lines
2.1 KiB
TypeScript
"use client"
|
|
import { useEffect } from "react"
|
|
import { useIntl } from "react-intl"
|
|
|
|
import { myStay } from "@scandic-hotels/common/constants/routes/myStay"
|
|
|
|
import useLang from "@/hooks/useLang"
|
|
|
|
import Promo from "./Promo"
|
|
|
|
import styles from "./promos.module.css"
|
|
|
|
import type { AdditionalInfoCookieValue } from "@scandic-hotels/booking-flow/types/components/findMyBooking/additionalInfoCookieValue"
|
|
|
|
import type { PromosProps } from "@/types/components/hotelReservation/bookingConfirmation/promos"
|
|
|
|
export default function Promos({ booking }: PromosProps) {
|
|
const intl = useIntl()
|
|
const lang = useLang()
|
|
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 = `${myStay[lang]}?RefId=${encodeURIComponent(refId)}`
|
|
return (
|
|
<div className={styles.promos}>
|
|
<Promo
|
|
buttonText={intl.formatMessage({
|
|
defaultMessage: "View and buy add-ons",
|
|
})}
|
|
href={myStayURL}
|
|
text={intl.formatMessage({
|
|
defaultMessage:
|
|
"Discover the little extra touches to make your upcoming stay even more unforgettable.",
|
|
})}
|
|
title={intl.formatMessage({
|
|
defaultMessage: "Spice things up",
|
|
})}
|
|
/>
|
|
<Promo
|
|
buttonText={intl.formatMessage({
|
|
defaultMessage: "Book another stay",
|
|
})}
|
|
href={`/${lang}?hotel=${hotelId}`}
|
|
text={intl.formatMessage({
|
|
defaultMessage:
|
|
"Get inspired and start dreaming beyond your next trip. Explore more Scandic destinations.",
|
|
})}
|
|
title={intl.formatMessage({
|
|
defaultMessage: "Book your next stay",
|
|
})}
|
|
/>
|
|
</div>
|
|
)
|
|
}
|