Merged in feat/SW-1076-no-room-availability (pull request #1467)

Feat/SW-1076 no room availability

* fix: update booking error codes

* feat(SW-1076): handle no room availabilty on enter-details

* fix: parse to json in api mutation instead of expecting json

* fix: remove 'isComplete' state from sectionAccordion because it was not needed


Approved-by: Simon.Emanuelsson
This commit is contained in:
Tobias Johansson
2025-03-10 12:13:15 +00:00
parent 131cbfcda3
commit 7c233ab846
23 changed files with 139 additions and 63 deletions

View File

@@ -4,7 +4,7 @@ import { usePathname, useRouter, useSearchParams } from "next/navigation"
import { useCallback, useEffect } from "react"
import { useIntl } from "react-intl"
import { PaymentErrorCodeEnum } from "@/constants/booking"
import { BookingErrorCodeEnum } from "@/constants/booking"
import { useEnterDetailsStore } from "@/stores/enter-details"
import { toast } from "@/components/TempDesignSystem/Toasts"
@@ -19,9 +19,9 @@ export function usePaymentFailedToast() {
const router = useRouter()
const getErrorMessage = useCallback(
(errorCode: PaymentErrorCodeEnum) => {
(errorCode: string | null) => {
switch (errorCode) {
case PaymentErrorCodeEnum.Cancelled:
case BookingErrorCodeEnum.TransactionCancelled:
return intl.formatMessage({
id: "You have now cancelled your payment.",
})
@@ -34,8 +34,7 @@ export function usePaymentFailedToast() {
[intl]
)
const errorCodeString = searchParams.get("errorCode")
const errorCode = Number(errorCodeString) as PaymentErrorCodeEnum
const errorCode = searchParams.get("errorCode")
const errorMessage = getErrorMessage(errorCode)
useEffect(() => {
@@ -44,7 +43,9 @@ export function usePaymentFailedToast() {
// setTimeout is needed to show toasts on page load: https://sonner.emilkowal.ski/toast#render-toast-on-page-load
setTimeout(() => {
const toastType =
errorCode === PaymentErrorCodeEnum.Cancelled ? "warning" : "error"
errorCode === BookingErrorCodeEnum.TransactionCancelled
? "warning"
: "error"
toast[toastType](errorMessage)
})