Merged in feat/SW-1368-1369-Guarantee-late-arrival (pull request #1512)
Feat/SW-1368 1369 Guarantee late arrival * feat(SW-1368-SW-1369): guarantee late arrival for confirmation page and my stay * feat(SW-1368-SW-1369): guarantee late arrival updated design * feat(SW-1368-SW-1369): add translations * feat(SW-1368-SW-1369): add translations * feat(SW-1368-SW-1369): fix merge with master * feat(SW-1368-SW-1369): add translations * feat(SW-1368-SW-1369): add redirect with refId * feat(SW-1368-SW-1369): if booking completed redirect to confirmation page * feat(SW-1368-SW-1369): fix comments pr * feat(SW-1368-SW-1369): fix comments pr * feat(SW-1368-SW-1369): fix rebase master * feat(SW-1368-SW-1369): fix duplicate flex rate check * feat(SW-1368-SW-1369): if any room is flex, card must be used * feat(SW-1368-SW-1369): move callback route * feat(SW-1368-SW-1369): top align checkbox * feat(SW-1368-SW-1369): top align checkbox Approved-by: Tobias Johansson Approved-by: Niclas Edenvin
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
.layout {
|
||||
background-color: var(--Base-Background-Primary-Normal);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
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>
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
import { redirect } from "next/navigation"
|
||||
|
||||
import { BookingErrorCodeEnum } from "@/constants/booking"
|
||||
import { hotelreservation } from "@/constants/routes/hotelReservation"
|
||||
import { serverClient } from "@/lib/trpc/server"
|
||||
|
||||
import LoadingSpinner from "@/components/LoadingSpinner"
|
||||
|
||||
import type { LangParams, PageArgs } from "@/types/params"
|
||||
|
||||
export default async function GuaranteePaymentCallbackPage({
|
||||
params,
|
||||
searchParams,
|
||||
}: PageArgs<
|
||||
LangParams,
|
||||
{
|
||||
status: "error" | "success" | "cancel"
|
||||
refId: string
|
||||
confirmationNumber?: 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 = `${hotelreservation(lang)}/my-stay/${encodeURIComponent(refId)}`
|
||||
|
||||
if (status === "success" && confirmationNumber && refId) {
|
||||
console.log(`[gla-payment-callback] redirecting to: ${myStayUrl}`)
|
||||
redirect(myStayUrl)
|
||||
}
|
||||
|
||||
const searchObject = new URLSearchParams()
|
||||
|
||||
let errorMessage = undefined
|
||||
|
||||
if (confirmationNumber) {
|
||||
try {
|
||||
const bookingStatus = await serverClient().booking.status({
|
||||
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}`
|
||||
|
||||
searchObject.set(
|
||||
"errorCode",
|
||||
error
|
||||
? error.errorCode.toString()
|
||||
: BookingErrorCodeEnum.TransactionFailed
|
||||
)
|
||||
} catch {
|
||||
console.error(
|
||||
`[gla-payment-callback] failed to get booking status for ${confirmationNumber}, status: ${status}`
|
||||
)
|
||||
if (status === "cancel") {
|
||||
searchObject.set("errorCode", BookingErrorCodeEnum.TransactionCancelled)
|
||||
}
|
||||
if (status === "error") {
|
||||
searchObject.set(
|
||||
"errorCode",
|
||||
BookingErrorCodeEnum.TransactionFailed.toString()
|
||||
)
|
||||
errorMessage = `Failed to get booking status for ${confirmationNumber}, status: ${status}`
|
||||
}
|
||||
}
|
||||
console.log(errorMessage)
|
||||
redirect(`${myStayUrl}?${searchObject.toString()}`)
|
||||
}
|
||||
|
||||
return <LoadingSpinner />
|
||||
}
|
||||
@@ -66,6 +66,7 @@ export default async function DetailsPage({
|
||||
roomStayStartDate: booking.fromDate,
|
||||
roomStayEndDate: booking.toDate,
|
||||
roomTypeCode: room.roomTypeCode,
|
||||
counterRateCode: room.counterRateCode,
|
||||
bookingCode: booking.bookingCode,
|
||||
}
|
||||
|
||||
@@ -89,13 +90,13 @@ export default async function DetailsPage({
|
||||
// redirect back to select-rate if availability call fails
|
||||
redirect(`${selectRate(lang)}?${selectRoomParams.toString()}`)
|
||||
}
|
||||
|
||||
rooms.push({
|
||||
bedTypes: roomAvailability.bedTypes,
|
||||
breakfastIncluded: roomAvailability.breakfastIncluded,
|
||||
cancellationRule: roomAvailability.cancellationRule,
|
||||
cancellationText: roomAvailability.cancellationText,
|
||||
isFlexRate: roomAvailability.isFlexRate,
|
||||
mustBeGuaranteed: roomAvailability.mustBeGuaranteed,
|
||||
memberMustBeGuaranteed: roomAvailability.memberMustBeGuaranteed,
|
||||
packages,
|
||||
rateTitle: roomAvailability.rateTitle,
|
||||
rateDetails: roomAvailability.rateDetails ?? [],
|
||||
@@ -109,8 +110,12 @@ export default async function DetailsPage({
|
||||
roomAvailability.selectedRoom.status === AvailabilityEnum.Available,
|
||||
})
|
||||
}
|
||||
|
||||
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,
|
||||
isCardOnlyPayment,
|
||||
@@ -197,6 +202,9 @@ 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