fix: reset searchparams after errorcode from planet

This commit is contained in:
Christel Westerberg
2024-12-12 15:41:29 +01:00
parent 658afd0327
commit 8534405358
3 changed files with 30 additions and 7 deletions

View File

@@ -5,10 +5,14 @@ import { useCallback, useEffect } from "react"
import { useIntl } from "react-intl"
import { PaymentErrorCodeEnum } from "@/constants/booking"
import { useEnterDetailsStore } from "@/stores/enter-details"
import { toast } from "@/components/TempDesignSystem/Toasts"
export function usePaymentFailedToast() {
const updateSearchParams = useEnterDetailsStore(
(state) => state.actions.updateSeachParamString
)
const intl = useIntl()
const searchParams = useSearchParams()
const pathname = usePathname()
@@ -43,6 +47,15 @@ export function usePaymentFailedToast() {
const queryParams = new URLSearchParams(searchParams.toString())
queryParams.delete("errorCode")
updateSearchParams(queryParams.toString())
router.push(`${pathname}?${queryParams.toString()}`)
}, [searchParams, pathname, errorCode, errorMessage, router])
}, [
searchParams,
pathname,
errorCode,
errorMessage,
router,
updateSearchParams,
])
}