Merge master
This commit is contained in:
@@ -14,7 +14,6 @@ import {
|
||||
getProfileSafely,
|
||||
getSavedPaymentCardsSafely,
|
||||
} from "@/lib/trpc/memoizedRequests"
|
||||
import { decrypt } from "@/server/routers/utils/encryption"
|
||||
|
||||
import { auth } from "@/auth"
|
||||
import AdditionalInfoForm from "@/components/HotelReservation/FindMyBooking/AdditionalInfoForm"
|
||||
@@ -34,6 +33,7 @@ import Image from "@/components/Image"
|
||||
import { getIntl } from "@/i18n"
|
||||
import { setLang } from "@/i18n/serverContext"
|
||||
import MyStayProvider from "@/providers/MyStay"
|
||||
import { parseRefId } from "@/utils/refId"
|
||||
import { isValidSession } from "@/utils/session"
|
||||
import { getCurrentWebUrl } from "@/utils/url"
|
||||
|
||||
@@ -47,24 +47,21 @@ export default async function MyStay({
|
||||
searchParams,
|
||||
}: PageArgs<LangParams, { RefId?: string }>) {
|
||||
setLang(params.lang)
|
||||
|
||||
const refId = searchParams.RefId
|
||||
|
||||
if (!refId) {
|
||||
notFound()
|
||||
}
|
||||
|
||||
const value = decrypt(refId)
|
||||
if (!value) {
|
||||
return notFound()
|
||||
}
|
||||
const session = await auth()
|
||||
const isLoggedIn = isValidSession(session)
|
||||
const { confirmationNumber, lastName } = parseRefId(refId)
|
||||
|
||||
const [confirmationNumber, lastName] = value.split(",")
|
||||
const bv = cookies().get("bv")?.value
|
||||
let bookingConfirmation
|
||||
if (isLoggedIn) {
|
||||
bookingConfirmation = await getBookingConfirmation(confirmationNumber)
|
||||
bookingConfirmation = await getBookingConfirmation(refId, params.lang)
|
||||
} else if (bv) {
|
||||
const params = new URLSearchParams(bv)
|
||||
const firstName = params.get("firstName")
|
||||
@@ -78,26 +75,17 @@ export default async function MyStay({
|
||||
email
|
||||
)
|
||||
} else {
|
||||
return (
|
||||
<RenderAdditionalInfoForm
|
||||
confirmationNumber={confirmationNumber}
|
||||
lastName={lastName}
|
||||
/>
|
||||
)
|
||||
return <RenderAdditionalInfoForm refId={refId} lastName={lastName} />
|
||||
}
|
||||
} else {
|
||||
return (
|
||||
<RenderAdditionalInfoForm
|
||||
confirmationNumber={confirmationNumber}
|
||||
lastName={lastName}
|
||||
/>
|
||||
)
|
||||
return <RenderAdditionalInfoForm refId={refId} lastName={lastName} />
|
||||
}
|
||||
if (!bookingConfirmation) {
|
||||
return notFound()
|
||||
}
|
||||
|
||||
const { additionalData, booking, hotel, roomCategories } = bookingConfirmation
|
||||
const { booking, hotelData } = bookingConfirmation
|
||||
const { hotel } = hotelData
|
||||
|
||||
const user = await getProfileSafely()
|
||||
const intl = await getIntl()
|
||||
@@ -109,9 +97,7 @@ export default async function MyStay({
|
||||
const fromDate = dt(booking.checkInDate).format("YYYY-MM-DD")
|
||||
const toDate = dt(booking.checkOutDate).format("YYYY-MM-DD")
|
||||
|
||||
const linkedReservationsPromise = getLinkedReservations({
|
||||
rooms: booking.linkedReservations,
|
||||
})
|
||||
const linkedReservationsPromise = getLinkedReservations(refId, params.lang)
|
||||
|
||||
const packagesInput = {
|
||||
adults: booking.adults,
|
||||
@@ -133,9 +119,9 @@ export default async function MyStay({
|
||||
(pkg) => pkg.code === BreakfastPackageEnum.REGULAR_BREAKFAST
|
||||
)
|
||||
const breakfastIncluded = booking.rateDefinition.breakfastIncluded
|
||||
const alreadyHasABreakfastSelection =
|
||||
const shouldFetchBreakfastPackages =
|
||||
!hasBreakfastPackage && !breakfastIncluded
|
||||
if (alreadyHasABreakfastSelection) {
|
||||
if (shouldFetchBreakfastPackages) {
|
||||
void getPackages(packagesInput)
|
||||
}
|
||||
void getSavedPaymentCardsSafely(savedPaymentCardsInput)
|
||||
@@ -147,7 +133,7 @@ export default async function MyStay({
|
||||
})
|
||||
|
||||
let breakfastPackages = null
|
||||
if (alreadyHasABreakfastSelection) {
|
||||
if (shouldFetchBreakfastPackages) {
|
||||
breakfastPackages = await getPackages(packagesInput)
|
||||
}
|
||||
const savedCreditCards = await getSavedPaymentCardsSafely(
|
||||
@@ -156,7 +142,7 @@ export default async function MyStay({
|
||||
|
||||
const imageSrc =
|
||||
hotel.hotelContent.images.imageSizes.large ??
|
||||
additionalData.gallery?.heroImages[0]?.imageSizes.large ??
|
||||
hotelData.additionalData.gallery?.heroImages[0]?.imageSizes.large ??
|
||||
hotel.galleryImages[0]?.imageSizes.large
|
||||
|
||||
const baseUrl = env.PUBLIC_URL || "https://www.scandichotels.com"
|
||||
@@ -173,7 +159,7 @@ export default async function MyStay({
|
||||
lang={params.lang}
|
||||
linkedReservationsPromise={linkedReservationsPromise}
|
||||
refId={refId}
|
||||
roomCategories={roomCategories}
|
||||
roomCategories={hotelData.roomCategories}
|
||||
savedCreditCards={savedCreditCards}
|
||||
>
|
||||
<main className={styles.main}>
|
||||
@@ -232,10 +218,7 @@ export default async function MyStay({
|
||||
return (
|
||||
<main className={styles.main}>
|
||||
<div className={styles.form}>
|
||||
<AdditionalInfoForm
|
||||
confirmationNumber={confirmationNumber}
|
||||
lastName={lastName}
|
||||
/>
|
||||
<AdditionalInfoForm refId={refId} lastName={lastName} />
|
||||
</div>
|
||||
</main>
|
||||
)
|
||||
@@ -269,19 +252,16 @@ export default async function MyStay({
|
||||
}
|
||||
|
||||
function RenderAdditionalInfoForm({
|
||||
confirmationNumber,
|
||||
refId,
|
||||
lastName,
|
||||
}: {
|
||||
confirmationNumber: string
|
||||
refId: string
|
||||
lastName: string
|
||||
}) {
|
||||
return (
|
||||
<main className={styles.main}>
|
||||
<div className={styles.form}>
|
||||
<AdditionalInfoForm
|
||||
confirmationNumber={confirmationNumber}
|
||||
lastName={lastName}
|
||||
/>
|
||||
<AdditionalInfoForm refId={refId} lastName={lastName} />
|
||||
</div>
|
||||
</main>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user