feat(SW-2116): Use refId instead of confirmationNumber
This commit is contained in:
@@ -18,12 +18,12 @@ const validBookingStatuses = [
|
||||
]
|
||||
|
||||
interface HandleStatusPollingProps {
|
||||
confirmationNumber: string
|
||||
refId: string
|
||||
successRedirectUrl: string
|
||||
}
|
||||
|
||||
export default function HandleSuccessCallback({
|
||||
confirmationNumber,
|
||||
refId,
|
||||
successRedirectUrl,
|
||||
}: HandleStatusPollingProps) {
|
||||
const router = useRouter()
|
||||
@@ -33,7 +33,7 @@ export default function HandleSuccessCallback({
|
||||
error,
|
||||
isTimeout,
|
||||
} = useHandleBookingStatus({
|
||||
confirmationNumber,
|
||||
refId,
|
||||
expectedStatuses: validBookingStatuses,
|
||||
maxRetries: 10,
|
||||
retryInterval: 2000,
|
||||
|
||||
@@ -12,7 +12,6 @@ import { Button } from "@scandic-hotels/design-system/Button"
|
||||
import { Typography } from "@scandic-hotels/design-system/Typography"
|
||||
|
||||
import {
|
||||
BOOKING_CONFIRMATION_NUMBER,
|
||||
BookingStatusEnum,
|
||||
PAYMENT_METHOD_TITLES,
|
||||
PaymentMethodEnum,
|
||||
@@ -111,7 +110,7 @@ export default function PaymentClient({
|
||||
(state) => state.actions.setIsSubmittingDisabled
|
||||
)
|
||||
|
||||
const [bookingNumber, setBookingNumber] = useState<string>("")
|
||||
const [refId, setRefId] = useState("")
|
||||
const [isPollingForBookingStatus, setIsPollingForBookingStatus] =
|
||||
useState(false)
|
||||
|
||||
@@ -156,13 +155,15 @@ export default function PaymentClient({
|
||||
return
|
||||
}
|
||||
|
||||
const mainRoom = result.rooms[0]
|
||||
|
||||
if (result.reservationStatus == BookingStatusEnum.BookingCompleted) {
|
||||
const confirmationUrl = `${bookingConfirmation(lang)}?${BOOKING_CONFIRMATION_NUMBER}=${result.id}`
|
||||
const confirmationUrl = `${bookingConfirmation(lang)}?RefId=${encodeURIComponent(mainRoom.refId)}`
|
||||
router.push(confirmationUrl)
|
||||
return
|
||||
}
|
||||
|
||||
setBookingNumber(result.id)
|
||||
setRefId(mainRoom.refId)
|
||||
|
||||
const hasPriceChange = result.rooms.some((r) => r.priceChangedMetadata)
|
||||
if (hasPriceChange) {
|
||||
@@ -200,7 +201,7 @@ export default function PaymentClient({
|
||||
})
|
||||
|
||||
const bookingStatus = useHandleBookingStatus({
|
||||
confirmationNumber: bookingNumber,
|
||||
refId,
|
||||
expectedStatuses: [BookingStatusEnum.BookingCompleted],
|
||||
maxRetries,
|
||||
retryInterval,
|
||||
@@ -263,7 +264,8 @@ export default function PaymentClient({
|
||||
bookingStatus?.data?.reservationStatus ===
|
||||
BookingStatusEnum.BookingCompleted
|
||||
) {
|
||||
const confirmationUrl = `${bookingConfirmation(lang)}?${BOOKING_CONFIRMATION_NUMBER}=${bookingStatus?.data?.id}`
|
||||
const mainRoom = bookingStatus.data.rooms[0]
|
||||
const confirmationUrl = `${bookingConfirmation(lang)}?RefId=${encodeURIComponent(mainRoom.refId)}`
|
||||
router.push(confirmationUrl)
|
||||
} else if (bookingStatus.isTimeout) {
|
||||
handlePaymentError("Timeout")
|
||||
@@ -633,9 +635,7 @@ export default function PaymentClient({
|
||||
: ""
|
||||
router.push(`${selectRate(lang)}${allSearchParams}`)
|
||||
}}
|
||||
onAccept={() =>
|
||||
priceChange.mutate({ confirmationNumber: bookingNumber })
|
||||
}
|
||||
onAccept={() => priceChange.mutate({ refId })}
|
||||
/>
|
||||
) : null}
|
||||
</section>
|
||||
|
||||
Reference in New Issue
Block a user