Merged in fix/SW-3205-mystay-anonymous-booking- (pull request #2584)
fix(SW-3205): Disabled ancillary points and saved cards for anonymous booking * fix(SW-3205): Disabled ancillary points and saved cards for anonymous booking * fix(SW-2903 SW-3205): Updated code to be consistent in all scenarios Approved-by: Anton Gunnarsson Approved-by: Matilda Landström
This commit is contained in:
@@ -11,6 +11,7 @@ import Link from "@/components/TempDesignSystem/Link"
|
||||
import useLang from "@/hooks/useLang"
|
||||
|
||||
import type { ManageBookingProps } from "@/types/components/hotelReservation/bookingConfirmation/actions/manageBooking"
|
||||
import type { AdditionalInfoCookieValue } from "@/components/HotelReservation/FindMyBooking/AdditionalInfoForm"
|
||||
|
||||
export default function ManageBooking({ booking }: ManageBookingProps) {
|
||||
const intl = useIntl()
|
||||
@@ -20,12 +21,12 @@ export default function ManageBooking({ booking }: ManageBookingProps) {
|
||||
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({
|
||||
const value: AdditionalInfoCookieValue = {
|
||||
email,
|
||||
firstName,
|
||||
lastName,
|
||||
confirmationNumber,
|
||||
}).toString()
|
||||
}
|
||||
document.cookie = `bv=${JSON.stringify(value)}; Path=/; Max-Age=600; Secure; SameSite=Strict`
|
||||
}, [confirmationNumber, email, firstName, lastName])
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import Promo from "./Promo"
|
||||
import styles from "./promos.module.css"
|
||||
|
||||
import type { PromosProps } from "@/types/components/hotelReservation/bookingConfirmation/promos"
|
||||
import type { AdditionalInfoCookieValue } from "../../FindMyBooking/AdditionalInfoForm"
|
||||
|
||||
export default function Promos({ booking }: PromosProps) {
|
||||
const intl = useIntl()
|
||||
@@ -19,12 +20,12 @@ export default function Promos({ booking }: PromosProps) {
|
||||
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({
|
||||
const value: AdditionalInfoCookieValue = {
|
||||
email,
|
||||
firstName,
|
||||
lastName,
|
||||
confirmationNumber,
|
||||
}).toString()
|
||||
}
|
||||
document.cookie = `bv=${JSON.stringify(value)}; Path=/; Max-Age=600; Secure; SameSite=Strict`
|
||||
}, [confirmationNumber, email, firstName, lastName])
|
||||
|
||||
|
||||
@@ -146,7 +146,8 @@ export default async function MyStay(props: {
|
||||
if (shouldFetchBreakfastPackages) {
|
||||
void getPackages(packagesInput)
|
||||
}
|
||||
if (user) {
|
||||
const isOwnBooking = user?.email === booking.guest.email
|
||||
if (user && isOwnBooking) {
|
||||
void getSavedPaymentCardsSafely(savedPaymentCardsInput)
|
||||
}
|
||||
|
||||
@@ -155,7 +156,7 @@ export default async function MyStay(props: {
|
||||
breakfastPackages = await getPackages(packagesInput)
|
||||
}
|
||||
let savedCreditCards = null
|
||||
if (user) {
|
||||
if (user && isOwnBooking) {
|
||||
savedCreditCards = await getSavedPaymentCardsSafely(
|
||||
savedPaymentCardsInput
|
||||
)
|
||||
@@ -193,13 +194,14 @@ export default async function MyStay(props: {
|
||||
},
|
||||
} satisfies BookingConfirmation
|
||||
|
||||
const maskedUser = user
|
||||
? ({
|
||||
...user,
|
||||
email: maskValue.email(user.email),
|
||||
phoneNumber: maskValue.phone(user.phoneNumber ?? ""),
|
||||
} satisfies SafeUser)
|
||||
: null
|
||||
const maskedUser =
|
||||
user && isOwnBooking
|
||||
? ({
|
||||
...user,
|
||||
email: maskValue.email(user.email),
|
||||
phoneNumber: maskValue.phone(user.phoneNumber ?? ""),
|
||||
} satisfies SafeUser)
|
||||
: null
|
||||
|
||||
hotel.specialAlerts = getHotelAlertsForBookingDates(
|
||||
hotel.specialAlerts,
|
||||
|
||||
Reference in New Issue
Block a user