From bcf03108726c84be6cc33fa941830847a58aea06 Mon Sep 17 00:00:00 2001 From: Bianca Widstam Date: Mon, 24 Mar 2025 08:26:07 +0000 Subject: [PATCH] Merged in fix/polling-status-guarantee (pull request #1601) fix: refetch data for confirmation number to avoid booking already completed * fix: refetch data for confirmation number to avoid booking already completed Approved-by: Christian Andolf --- apps/scandic-web/hooks/booking/useGuaranteeBooking.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/apps/scandic-web/hooks/booking/useGuaranteeBooking.ts b/apps/scandic-web/hooks/booking/useGuaranteeBooking.ts index 56097f778..323407632 100644 --- a/apps/scandic-web/hooks/booking/useGuaranteeBooking.ts +++ b/apps/scandic-web/hooks/booking/useGuaranteeBooking.ts @@ -30,14 +30,17 @@ export function useGuaranteeBooking({ }) ) }, [intl]) - + const utils = trpc.useUtils() const guaranteeBooking = trpc.booking.guarantee.useMutation({ - onSuccess: (result) => { + onSuccess: (result, variables) => { if (result) { if (result.reservationStatus == BookingStatusEnum.BookingCompleted) { handleBookingCompleted() } else { setIsPollingForBookingStatus(true) + utils.booking.status.invalidate({ + confirmationNumber: variables.confirmationNumber, + }) } } else { handlePaymentError() @@ -66,7 +69,7 @@ export function useGuaranteeBooking({ } else if (bookingStatus.isTimeout) { handlePaymentError() } - }, [bookingStatus, router, intl, handlePaymentError]) + }, [bookingStatus, router, handlePaymentError]) const isLoading = guaranteeBooking.isPending ||