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:
@@ -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)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user