Merged in feat/SW-1370/Guarantee-my-stay-ancillaries (pull request #1545)
Feat/SW-1370/Guarantee my stay ancillaries * feat(SW-1370): guarantee for ancillaries * feat(SW-1370): remove console log * feat(SW-1370): add translations * feat(SW-1370): small fix * feat(SW-1370): fix must be guaranteed * feat(SW-1370): fix logic and comments pr * feat(SW-1370): fix comments pr * feat(SW-1370): fix comments pr * feat(SW-1370): add translation * feat(SW-1370): add translation and fix pr comment * feat(SW-1370): fix pr comment * feat(SW-1370): fix encoding path refId issue * feat(SW-1370): refactor AddAncillaryStore usage and introduce context provider * feat(SW-1370): refactor * feat(SW-1370): refactor ancillaries * feat(SW-1370): fix merge Approved-by: Simon.Emanuelsson
This commit is contained in:
@@ -1,3 +0,0 @@
|
||||
.layout {
|
||||
background-color: var(--Base-Background-Primary-Normal);
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
import styles from "./layout.module.css"
|
||||
|
||||
import type { LangParams, LayoutArgs } from "@/types/params"
|
||||
|
||||
export default function GuaranteePaymentCallbackLayout({
|
||||
children,
|
||||
}: React.PropsWithChildren<LayoutArgs<LangParams>>) {
|
||||
return <div className={styles.layout}>{children}</div>
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { redirect } from "next/navigation"
|
||||
import { notFound, redirect } from "next/navigation"
|
||||
|
||||
import {
|
||||
BookingErrorCodeEnum,
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
import { myStay } from "@/constants/routes/myStay"
|
||||
import { serverClient } from "@/lib/trpc/server"
|
||||
|
||||
import GuaranteeCallback from "@/components/HotelReservation/MyStay/Ancillaries/GuaranteeCallback"
|
||||
import LoadingSpinner from "@/components/LoadingSpinner"
|
||||
|
||||
import type { LangParams, PageArgs } from "@/types/params"
|
||||
@@ -18,28 +19,38 @@ export default async function GuaranteePaymentCallbackPage({
|
||||
LangParams,
|
||||
{
|
||||
status: PaymentCallbackStatusEnum
|
||||
refId: string
|
||||
RefId: string
|
||||
confirmationNumber?: string
|
||||
ancillary?: string
|
||||
}
|
||||
>) {
|
||||
console.log(`[gla-payment-callback] callback started`)
|
||||
const lang = params.lang
|
||||
const status = searchParams.status
|
||||
const confirmationNumber = searchParams.confirmationNumber
|
||||
const refId = searchParams.refId
|
||||
const myStayUrl = `${myStay[lang]}?RefId=${refId}`
|
||||
|
||||
if (
|
||||
status === PaymentCallbackStatusEnum.Success &&
|
||||
confirmationNumber &&
|
||||
refId
|
||||
) {
|
||||
console.log(`[gla-payment-callback] redirecting to: ${myStayUrl}`)
|
||||
redirect(myStayUrl)
|
||||
const refId = searchParams.RefId
|
||||
if (!refId) {
|
||||
notFound()
|
||||
}
|
||||
const isAncillaryFlow = searchParams.ancillary
|
||||
|
||||
const myStayUrl = `${myStay[lang]}?RefId=${encodeURIComponent(refId)}`
|
||||
const searchObject = new URLSearchParams()
|
||||
|
||||
if (status === PaymentCallbackStatusEnum.Success && confirmationNumber) {
|
||||
if (isAncillaryFlow) {
|
||||
return (
|
||||
<GuaranteeCallback
|
||||
returnUrl={myStayUrl}
|
||||
confirmationNumber={confirmationNumber}
|
||||
lang={lang}
|
||||
/>
|
||||
)
|
||||
}
|
||||
console.log(`[gla-payment-callback] redirecting to: ${myStayUrl}`)
|
||||
return redirect(myStayUrl)
|
||||
}
|
||||
|
||||
let errorMessage = undefined
|
||||
|
||||
if (confirmationNumber) {
|
||||
@@ -48,9 +59,7 @@ export default async function GuaranteePaymentCallbackPage({
|
||||
confirmationNumber,
|
||||
})
|
||||
|
||||
// TODO: how to handle errors for multiple rooms?
|
||||
const error = bookingStatus.errors.find((e) => e.errorCode)
|
||||
|
||||
errorMessage =
|
||||
error?.description ??
|
||||
`No error message found for booking ${confirmationNumber}, status: ${status}`
|
||||
@@ -67,17 +76,17 @@ export default async function GuaranteePaymentCallbackPage({
|
||||
)
|
||||
if (status === PaymentCallbackStatusEnum.Cancel) {
|
||||
searchObject.set("errorCode", BookingErrorCodeEnum.TransactionCancelled)
|
||||
}
|
||||
if (status === PaymentCallbackStatusEnum.Error) {
|
||||
searchObject.set(
|
||||
"errorCode",
|
||||
BookingErrorCodeEnum.TransactionFailed.toString()
|
||||
)
|
||||
} else if (status === PaymentCallbackStatusEnum.Error) {
|
||||
searchObject.set("errorCode", BookingErrorCodeEnum.TransactionFailed)
|
||||
errorMessage = `Failed to get booking status for ${confirmationNumber}, status: ${status}`
|
||||
}
|
||||
}
|
||||
console.log(errorMessage)
|
||||
redirect(`${myStayUrl}?${searchObject.toString()}`)
|
||||
|
||||
if (isAncillaryFlow) {
|
||||
searchObject.set("ancillary", "ancillary")
|
||||
}
|
||||
redirect(`${myStayUrl}&${searchObject.toString()}`)
|
||||
}
|
||||
|
||||
return <LoadingSpinner />
|
||||
|
||||
@@ -62,14 +62,14 @@ export default async function DetailsPage({
|
||||
|
||||
const packages = room.packages
|
||||
? await getPackages({
|
||||
adults: room.adults,
|
||||
children: room.childrenInRoom?.length,
|
||||
endDate: booking.toDate,
|
||||
hotelId: booking.hotelId,
|
||||
packageCodes: room.packages,
|
||||
startDate: booking.fromDate,
|
||||
lang,
|
||||
})
|
||||
adults: room.adults,
|
||||
children: room.childrenInRoom?.length,
|
||||
endDate: booking.toDate,
|
||||
hotelId: booking.hotelId,
|
||||
packageCodes: room.packages,
|
||||
startDate: booking.fromDate,
|
||||
lang,
|
||||
})
|
||||
: null
|
||||
|
||||
const roomAvailability = await getSelectedRoomAvailability({
|
||||
@@ -113,10 +113,6 @@ export default async function DetailsPage({
|
||||
})
|
||||
}
|
||||
const isCardOnlyPayment = rooms.some((room) => room?.mustBeGuaranteed)
|
||||
const memberMustBeGuaranteed = rooms.some(
|
||||
(room) => room?.memberMustBeGuaranteed
|
||||
)
|
||||
const isFlexRate = rooms.some((room) => room.isFlexRate)
|
||||
|
||||
const hotelData = await getHotel({
|
||||
hotelId: booking.hotelId,
|
||||
@@ -191,9 +187,6 @@ export default async function DetailsPage({
|
||||
hotel.merchantInformationData.alternatePaymentOptions
|
||||
}
|
||||
supportedCards={hotel.merchantInformationData.cards}
|
||||
mustBeGuaranteed={isCardOnlyPayment}
|
||||
memberMustBeGuaranteed={memberMustBeGuaranteed}
|
||||
isFlexRate={isFlexRate}
|
||||
/>
|
||||
</Suspense>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user