From bfc25453c7b364d4f24ecffd743cc81b5e39f88a Mon Sep 17 00:00:00 2001 From: Bianca Widstam Date: Mon, 28 Apr 2025 13:20:18 +0000 Subject: [PATCH] Merged in fix/SW-1415-my-stay-tracking-hotelId (pull request #1880) fix(SW-1415): add hotelId in tracking for my stay * fix(SW-1415): add hotelId in tracking for my stay * fix: remove toast if cancel guarantee * fix(SW-1415): rebase master * fix(SW-1415): fix comment shorthand hotelId Approved-by: Christian Andolf --- .../Payment/PaymentCallback/HandleErrorCallback.tsx | 2 +- .../AddAncillaryFlow/AddAncillaryFlowModal/index.tsx | 2 +- .../Actions/GuaranteeLateArrival/Form/index.tsx | 4 +++- apps/scandic-web/hooks/booking/useGuaranteeBooking.ts | 6 ++++-- .../hooks/booking/useGuaranteePaymentFailedToast.ts | 8 ++------ 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/apps/scandic-web/components/HotelReservation/EnterDetails/Payment/PaymentCallback/HandleErrorCallback.tsx b/apps/scandic-web/components/HotelReservation/EnterDetails/Payment/PaymentCallback/HandleErrorCallback.tsx index 2324ada8c..a7015e3da 100644 --- a/apps/scandic-web/components/HotelReservation/EnterDetails/Payment/PaymentCallback/HandleErrorCallback.tsx +++ b/apps/scandic-web/components/HotelReservation/EnterDetails/Payment/PaymentCallback/HandleErrorCallback.tsx @@ -68,7 +68,7 @@ export default function HandleErrorCallback({ event: "glaCardSaveFailed", hotelInfo: { hotelId: glaSessionData.hotelId, - lateArrivalGuarantee: glaSessionData, + lateArrivalGuarantee: glaSessionData.lateArrivalGuarantee, guaranteedProduct: "room", }, paymentInfo: { diff --git a/apps/scandic-web/components/HotelReservation/MyStay/Ancillaries/AddAncillaryFlow/AddAncillaryFlowModal/index.tsx b/apps/scandic-web/components/HotelReservation/MyStay/Ancillaries/AddAncillaryFlow/AddAncillaryFlowModal/index.tsx index c8236285b..24e33713d 100644 --- a/apps/scandic-web/components/HotelReservation/MyStay/Ancillaries/AddAncillaryFlow/AddAncillaryFlowModal/index.tsx +++ b/apps/scandic-web/components/HotelReservation/MyStay/Ancillaries/AddAncillaryFlow/AddAncillaryFlowModal/index.tsx @@ -124,7 +124,7 @@ export default function AddAncillaryFlowModal({ const addAncillary = trpc.booking.packages.useMutation() const { guaranteeBooking, isLoading, handleGuaranteeError } = - useGuaranteeBooking(booking.confirmationNumber, true) + useGuaranteeBooking(booking.confirmationNumber, true, booking.hotelId) function validateTermsAndConditions(data: AncillaryFormData): boolean { if (!data.termsAndConditions) { diff --git a/apps/scandic-web/components/HotelReservation/MyStay/ReferenceCard/Actions/NotCancelled/ManageStay/Actions/GuaranteeLateArrival/Form/index.tsx b/apps/scandic-web/components/HotelReservation/MyStay/ReferenceCard/Actions/NotCancelled/ManageStay/Actions/GuaranteeLateArrival/Form/index.tsx index 2f7ee30cb..a042331c1 100644 --- a/apps/scandic-web/components/HotelReservation/MyStay/ReferenceCard/Actions/NotCancelled/ManageStay/Actions/GuaranteeLateArrival/Form/index.tsx +++ b/apps/scandic-web/components/HotelReservation/MyStay/ReferenceCard/Actions/NotCancelled/ManageStay/Actions/GuaranteeLateArrival/Form/index.tsx @@ -14,6 +14,7 @@ import { guaranteeCallback } from "@/constants/routes/hotelReservation" import { env } from "@/env/client" import { useMyStayStore } from "@/stores/my-stay" +import { writeGlaToSessionStorage } from "@/components/HotelReservation/EnterDetails/Payment/PaymentCallback/helpers" import PaymentOptionsGroup from "@/components/HotelReservation/EnterDetails/Payment/PaymentOptionsGroup" import MySavedCards from "@/components/HotelReservation/MySavedCards" import PaymentOption from "@/components/HotelReservation/PaymentOption" @@ -59,7 +60,7 @@ export default function Form() { const guaranteeRedirectUrl = `${env.NEXT_PUBLIC_NODE_ENV === "development" ? `http://localhost:${env.NEXT_PUBLIC_PORT}` : ""}${guaranteeCallback(lang)}` const { guaranteeBooking, isLoading, handleGuaranteeError } = - useGuaranteeBooking(confirmationNumber) + useGuaranteeBooking(confirmationNumber, false, hotelId) if (isLoading) { return ( @@ -82,6 +83,7 @@ export default function Form() { cardType: savedCreditCard.cardType, } : undefined + writeGlaToSessionStorage("yes", hotelId) guaranteeBooking.mutate({ confirmationNumber, language: lang, diff --git a/apps/scandic-web/hooks/booking/useGuaranteeBooking.ts b/apps/scandic-web/hooks/booking/useGuaranteeBooking.ts index 7e77da181..21f4205ed 100644 --- a/apps/scandic-web/hooks/booking/useGuaranteeBooking.ts +++ b/apps/scandic-web/hooks/booking/useGuaranteeBooking.ts @@ -14,7 +14,8 @@ const retryInterval = 2000 export function useGuaranteeBooking( confirmationNumber: string, - isAncillaryFlow = false + isAncillaryFlow = false, + hotelId: string ) { const intl = useIntl() const router = useRouter() @@ -26,6 +27,7 @@ export function useGuaranteeBooking( trackEvent({ event: "glaCardSaveFailed", hotelInfo: { + hotelId, lateArrivalGuarantee: "yes", guaranteedProduct: isAncillaryFlow ? "room + ancillary" : "room", }, @@ -41,7 +43,7 @@ export function useGuaranteeBooking( }) ) }, - [intl, isAncillaryFlow] + [intl, isAncillaryFlow, hotelId] ) const utils = trpc.useUtils() diff --git a/apps/scandic-web/hooks/booking/useGuaranteePaymentFailedToast.ts b/apps/scandic-web/hooks/booking/useGuaranteePaymentFailedToast.ts index 3c69ba06a..c1647a707 100644 --- a/apps/scandic-web/hooks/booking/useGuaranteePaymentFailedToast.ts +++ b/apps/scandic-web/hooks/booking/useGuaranteePaymentFailedToast.ts @@ -17,11 +17,6 @@ export function useGuaranteePaymentFailedToast() { const getErrorMessage = useCallback( (errorCode: string | null) => { switch (errorCode) { - case BookingErrorCodeEnum.TransactionCancelled: - return intl.formatMessage({ - defaultMessage: - "You have cancelled to process to guarantee your booking.", - }) case "AncillaryFailed": return intl.formatMessage({ defaultMessage: @@ -40,7 +35,8 @@ export function useGuaranteePaymentFailedToast() { useEffect(() => { const errorCode = searchParams.get("errorCode") const errorMessage = getErrorMessage(errorCode) - if (!errorCode) return + if (!errorCode || errorCode === BookingErrorCodeEnum.TransactionCancelled) + return // setTimeout is needed to show toasts on page load: https://sonner.emilkowal.ski/toast#render-toast-on-page-load setTimeout(() => {