Merged in feat/SW-1370/Guarantee-my-stay-ancillaries (pull request #1545)

Feat/SW-1370/Guarantee my stay ancillaries

* feat(SW-1370): guarantee for ancillaries

* feat(SW-1370): remove console log

* feat(SW-1370): add translations

* feat(SW-1370): small fix

* feat(SW-1370): fix must be guaranteed

* feat(SW-1370): fix logic and comments pr

* feat(SW-1370): fix comments pr

* feat(SW-1370): fix comments pr

* feat(SW-1370): add translation

* feat(SW-1370): add translation and fix pr comment

* feat(SW-1370): fix pr comment

* feat(SW-1370): fix encoding path refId issue

* feat(SW-1370): refactor AddAncillaryStore usage and introduce context provider

* feat(SW-1370): refactor

* feat(SW-1370): refactor ancillaries

* feat(SW-1370): fix merge


Approved-by: Simon.Emanuelsson
This commit is contained in:
Bianca Widstam
2025-03-21 07:29:04 +00:00
parent 2bc14a6eeb
commit 3c1eee88b1
62 changed files with 1838 additions and 912 deletions

View File

@@ -21,6 +21,10 @@ export function useGuaranteePaymentFailedToast() {
return intl.formatMessage({
id: "You have cancelled to process to guarantee your booking.",
})
case "AncillaryFailed":
return intl.formatMessage({
id: "The product could not be added. Your booking is guaranteed. Please try again.",
})
default:
return intl.formatMessage({
id: "We had an issue guaranteeing your booking. Please try again.",
@@ -30,10 +34,9 @@ export function useGuaranteePaymentFailedToast() {
[intl]
)
const errorCode = searchParams.get("errorCode")
const errorMessage = getErrorMessage(errorCode)
useEffect(() => {
const errorCode = searchParams.get("errorCode")
const errorMessage = getErrorMessage(errorCode)
if (!errorCode) return
// setTimeout is needed to show toasts on page load: https://sonner.emilkowal.ski/toast#render-toast-on-page-load
@@ -45,10 +48,14 @@ export function useGuaranteePaymentFailedToast() {
toast[toastType](errorMessage)
})
const ancillary = searchParams.get("ancillary")
if ((errorCode && ancillary) || errorCode === "AncillaryFailed") {
return
}
const queryParams = new URLSearchParams(searchParams.toString())
queryParams.delete("errorCode")
router.push(`${pathname}?${queryParams.toString()}`)
}, [searchParams, pathname, errorCode, errorMessage, router])
}, [searchParams, pathname, router, getErrorMessage])
}