Merged in feat/BOOK-529-update-GLA-design-mystay (pull request #3230)

Feat/BOOK-529 update GLA design mystay

* feat(BOOK-529): update gla design on my stay

* feat(BOOK-529): open gla modal if error

* feat(BOOK-529): add inline accordion to storybook

* feat(529): move errormessage below message

* feat(529): update infomodal

* feat(BOOK-529): update infomodal

* feat(BOOK-529): hide guarantee info for adding ancillaries if prepaid

* feat(BOOK-529): update width on info dialog

* feat(BOOK-529): fix alignment

* feat(BOOK-529): check if member price

* feat(BOOK-529): refactor msg

* feat(BOOK-529): refactor terms and conditions to own component

* feat(BOOK-529): clean up confirmation step


Approved-by: Christel Westerberg
This commit is contained in:
Bianca Widstam
2025-11-28 14:27:25 +00:00
parent 22dd2f60fe
commit 46fa42750f
39 changed files with 681 additions and 485 deletions

View File

@@ -1,69 +0,0 @@
"use client"
import { usePathname, useRouter, useSearchParams } from "next/navigation"
import { useCallback, useEffect, useRef } from "react"
import { useIntl } from "react-intl"
import { toast } from "@scandic-hotels/design-system/Toast"
import { BookingErrorCodeEnum } from "@scandic-hotels/trpc/enums/bookingErrorCode"
import { isAncillaryError } from "@/components/HotelReservation/MyStay/utils"
export function useGuaranteePaymentFailedToast() {
const hasRunOnce = useRef(false)
const intl = useIntl()
const searchParams = useSearchParams()
const pathname = usePathname()
const router = useRouter()
const getErrorMessage = useCallback(
(errorCode: string | null) => {
switch (errorCode) {
case BookingErrorCodeEnum.TransactionCancelled:
return intl.formatMessage({
id: "guaranteePayment.cancelled",
defaultMessage:
"You have cancelled the payment. Your booking is not guaranteed.",
})
default:
return intl.formatMessage({
id: "guaranteePayment.failed",
defaultMessage:
"We had an issue guaranteeing your booking. Please try again.",
})
}
},
[intl]
)
useEffect(() => {
// To prevent multiple toasts in strict mode
if (hasRunOnce.current) {
return
}
const errorCode = searchParams.get("errorCode")
if (!errorCode) {
return
}
// Ancillary errors are handled in AddAncillaryFlowModal
if (isAncillaryError(searchParams)) {
hasRunOnce.current = true
return
}
const errorMessage = getErrorMessage(errorCode)
const toastType =
errorCode === BookingErrorCodeEnum.TransactionCancelled
? "warning"
: "error"
toast[toastType](errorMessage)
const queryParams = new URLSearchParams(searchParams.toString())
queryParams.delete("errorCode")
router.push(`${pathname}?${queryParams.toString()}`)
hasRunOnce.current = true
}, [searchParams, pathname, router, getErrorMessage])
}