From 630cc12215df9b4832919be44d3e5e845fa66493 Mon Sep 17 00:00:00 2001 From: Hrishikesh Vaipurkar Date: Fri, 1 Aug 2025 08:27:27 +0000 Subject: [PATCH] Merged in fix/SW-3205-mystay-anonymous-booking- (pull request #2584) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .../Header/Actions/ManageBooking.tsx | 5 +++-- .../BookingConfirmation/Promos/index.tsx | 5 +++-- .../HotelReservation/MyStay/index.tsx | 20 ++++++++++--------- 3 files changed, 17 insertions(+), 13 deletions(-) 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 3ae3d8c63..3943709aa 100644 --- a/apps/scandic-web/components/HotelReservation/BookingConfirmation/Header/Actions/ManageBooking.tsx +++ b/apps/scandic-web/components/HotelReservation/BookingConfirmation/Header/Actions/ManageBooking.tsx @@ -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]) diff --git a/apps/scandic-web/components/HotelReservation/BookingConfirmation/Promos/index.tsx b/apps/scandic-web/components/HotelReservation/BookingConfirmation/Promos/index.tsx index 8fc50b5e6..ff3a20bff 100644 --- a/apps/scandic-web/components/HotelReservation/BookingConfirmation/Promos/index.tsx +++ b/apps/scandic-web/components/HotelReservation/BookingConfirmation/Promos/index.tsx @@ -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]) diff --git a/apps/scandic-web/components/HotelReservation/MyStay/index.tsx b/apps/scandic-web/components/HotelReservation/MyStay/index.tsx index 1b3fc771d..fa58d4343 100644 --- a/apps/scandic-web/components/HotelReservation/MyStay/index.tsx +++ b/apps/scandic-web/components/HotelReservation/MyStay/index.tsx @@ -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,