feat(SW-2116): Use refId instead of confirmationNumber
This commit is contained in:
@@ -13,7 +13,7 @@ const maxRetries = 15
|
||||
const retryInterval = 2000
|
||||
|
||||
export function useGuaranteeBooking(
|
||||
confirmationNumber: string,
|
||||
refId: string,
|
||||
isAncillaryFlow = false,
|
||||
hotelId: string
|
||||
) {
|
||||
@@ -50,11 +50,12 @@ export function useGuaranteeBooking(
|
||||
const guaranteeBooking = trpc.booking.guarantee.useMutation({
|
||||
onSuccess: (result) => {
|
||||
if (result) {
|
||||
const mainRoom = result.rooms[0]
|
||||
if (result.reservationStatus == BookingStatusEnum.BookingCompleted) {
|
||||
utils.booking.get.invalidate({ confirmationNumber })
|
||||
utils.booking.get.invalidate({ refId: mainRoom.refId })
|
||||
} else {
|
||||
setIsPollingForBookingStatus(true)
|
||||
utils.booking.status.invalidate({ confirmationNumber })
|
||||
utils.booking.status.invalidate({ refId: mainRoom.refId })
|
||||
}
|
||||
} else {
|
||||
handleGuaranteeError()
|
||||
@@ -66,7 +67,7 @@ export function useGuaranteeBooking(
|
||||
})
|
||||
|
||||
const bookingStatus = useHandleBookingStatus({
|
||||
confirmationNumber,
|
||||
refId,
|
||||
expectedStatuses: [BookingStatusEnum.BookingCompleted],
|
||||
maxRetries,
|
||||
retryInterval,
|
||||
@@ -76,7 +77,7 @@ export function useGuaranteeBooking(
|
||||
useEffect(() => {
|
||||
if (bookingStatus?.data?.paymentUrl && isPollingForBookingStatus) {
|
||||
router.push(bookingStatus.data.paymentUrl)
|
||||
utils.booking.get.invalidate({ confirmationNumber })
|
||||
utils.booking.get.invalidate({ refId })
|
||||
setIsPollingForBookingStatus(false)
|
||||
} else if (bookingStatus.isTimeout) {
|
||||
handleGuaranteeError("Timeout")
|
||||
@@ -87,7 +88,7 @@ export function useGuaranteeBooking(
|
||||
handleGuaranteeError,
|
||||
setIsPollingForBookingStatus,
|
||||
isPollingForBookingStatus,
|
||||
confirmationNumber,
|
||||
refId,
|
||||
utils.booking.get,
|
||||
])
|
||||
|
||||
|
||||
@@ -7,13 +7,13 @@ import { trpc } from "@/lib/trpc/client"
|
||||
import type { BookingStatusEnum } from "@/constants/booking"
|
||||
|
||||
export function useHandleBookingStatus({
|
||||
confirmationNumber,
|
||||
refId,
|
||||
expectedStatuses,
|
||||
maxRetries,
|
||||
retryInterval,
|
||||
enabled,
|
||||
}: {
|
||||
confirmationNumber: string | null
|
||||
refId: string | null
|
||||
expectedStatuses: BookingStatusEnum[]
|
||||
maxRetries: number
|
||||
retryInterval: number
|
||||
@@ -22,7 +22,7 @@ export function useHandleBookingStatus({
|
||||
const retries = useRef(0)
|
||||
|
||||
const query = trpc.booking.status.useQuery(
|
||||
{ confirmationNumber: confirmationNumber ?? "" },
|
||||
{ refId: refId ?? "" },
|
||||
{
|
||||
enabled,
|
||||
refetchInterval: (query) => {
|
||||
|
||||
Reference in New Issue
Block a user