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 useLang from "@/hooks/useLang"
|
||||||
|
|
||||||
import type { ManageBookingProps } from "@/types/components/hotelReservation/bookingConfirmation/actions/manageBooking"
|
import type { ManageBookingProps } from "@/types/components/hotelReservation/bookingConfirmation/actions/manageBooking"
|
||||||
|
import type { AdditionalInfoCookieValue } from "@/components/HotelReservation/FindMyBooking/AdditionalInfoForm"
|
||||||
|
|
||||||
export default function ManageBooking({ booking }: ManageBookingProps) {
|
export default function ManageBooking({ booking }: ManageBookingProps) {
|
||||||
const intl = useIntl()
|
const intl = useIntl()
|
||||||
@@ -20,12 +21,12 @@ export default function ManageBooking({ booking }: ManageBookingProps) {
|
|||||||
const { email, firstName, lastName } = booking.guest
|
const { email, firstName, lastName } = booking.guest
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Setting the `bv` cookie allows direct access to My stay without prompting for more information.
|
// Setting the `bv` cookie allows direct access to My stay without prompting for more information.
|
||||||
const value = new URLSearchParams({
|
const value: AdditionalInfoCookieValue = {
|
||||||
email,
|
email,
|
||||||
firstName,
|
firstName,
|
||||||
lastName,
|
lastName,
|
||||||
confirmationNumber,
|
confirmationNumber,
|
||||||
}).toString()
|
}
|
||||||
document.cookie = `bv=${JSON.stringify(value)}; Path=/; Max-Age=600; Secure; SameSite=Strict`
|
document.cookie = `bv=${JSON.stringify(value)}; Path=/; Max-Age=600; Secure; SameSite=Strict`
|
||||||
}, [confirmationNumber, email, firstName, lastName])
|
}, [confirmationNumber, email, firstName, lastName])
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import Promo from "./Promo"
|
|||||||
import styles from "./promos.module.css"
|
import styles from "./promos.module.css"
|
||||||
|
|
||||||
import type { PromosProps } from "@/types/components/hotelReservation/bookingConfirmation/promos"
|
import type { PromosProps } from "@/types/components/hotelReservation/bookingConfirmation/promos"
|
||||||
|
import type { AdditionalInfoCookieValue } from "../../FindMyBooking/AdditionalInfoForm"
|
||||||
|
|
||||||
export default function Promos({ booking }: PromosProps) {
|
export default function Promos({ booking }: PromosProps) {
|
||||||
const intl = useIntl()
|
const intl = useIntl()
|
||||||
@@ -19,12 +20,12 @@ export default function Promos({ booking }: PromosProps) {
|
|||||||
const { email, firstName, lastName } = booking.guest
|
const { email, firstName, lastName } = booking.guest
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Setting the `bv` cookie allows direct access to My stay without prompting for more information.
|
// Setting the `bv` cookie allows direct access to My stay without prompting for more information.
|
||||||
const value = new URLSearchParams({
|
const value: AdditionalInfoCookieValue = {
|
||||||
email,
|
email,
|
||||||
firstName,
|
firstName,
|
||||||
lastName,
|
lastName,
|
||||||
confirmationNumber,
|
confirmationNumber,
|
||||||
}).toString()
|
}
|
||||||
document.cookie = `bv=${JSON.stringify(value)}; Path=/; Max-Age=600; Secure; SameSite=Strict`
|
document.cookie = `bv=${JSON.stringify(value)}; Path=/; Max-Age=600; Secure; SameSite=Strict`
|
||||||
}, [confirmationNumber, email, firstName, lastName])
|
}, [confirmationNumber, email, firstName, lastName])
|
||||||
|
|
||||||
|
|||||||
@@ -146,7 +146,8 @@ export default async function MyStay(props: {
|
|||||||
if (shouldFetchBreakfastPackages) {
|
if (shouldFetchBreakfastPackages) {
|
||||||
void getPackages(packagesInput)
|
void getPackages(packagesInput)
|
||||||
}
|
}
|
||||||
if (user) {
|
const isOwnBooking = user?.email === booking.guest.email
|
||||||
|
if (user && isOwnBooking) {
|
||||||
void getSavedPaymentCardsSafely(savedPaymentCardsInput)
|
void getSavedPaymentCardsSafely(savedPaymentCardsInput)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,7 +156,7 @@ export default async function MyStay(props: {
|
|||||||
breakfastPackages = await getPackages(packagesInput)
|
breakfastPackages = await getPackages(packagesInput)
|
||||||
}
|
}
|
||||||
let savedCreditCards = null
|
let savedCreditCards = null
|
||||||
if (user) {
|
if (user && isOwnBooking) {
|
||||||
savedCreditCards = await getSavedPaymentCardsSafely(
|
savedCreditCards = await getSavedPaymentCardsSafely(
|
||||||
savedPaymentCardsInput
|
savedPaymentCardsInput
|
||||||
)
|
)
|
||||||
@@ -193,13 +194,14 @@ export default async function MyStay(props: {
|
|||||||
},
|
},
|
||||||
} satisfies BookingConfirmation
|
} satisfies BookingConfirmation
|
||||||
|
|
||||||
const maskedUser = user
|
const maskedUser =
|
||||||
? ({
|
user && isOwnBooking
|
||||||
...user,
|
? ({
|
||||||
email: maskValue.email(user.email),
|
...user,
|
||||||
phoneNumber: maskValue.phone(user.phoneNumber ?? ""),
|
email: maskValue.email(user.email),
|
||||||
} satisfies SafeUser)
|
phoneNumber: maskValue.phone(user.phoneNumber ?? ""),
|
||||||
: null
|
} satisfies SafeUser)
|
||||||
|
: null
|
||||||
|
|
||||||
hotel.specialAlerts = getHotelAlertsForBookingDates(
|
hotel.specialAlerts = getHotelAlertsForBookingDates(
|
||||||
hotel.specialAlerts,
|
hotel.specialAlerts,
|
||||||
|
|||||||
Reference in New Issue
Block a user