feat: refactor NewDates, clean up legacy code
This reverts commit 0c7836fa59.
This commit is contained in:
@@ -28,7 +28,8 @@ import BookingSummary from "@/components/HotelReservation/MyStay/BookingSummary"
|
||||
import { Header } from "@/components/HotelReservation/MyStay/Header"
|
||||
import Promo from "@/components/HotelReservation/MyStay/Promo"
|
||||
import { ReferenceCard } from "@/components/HotelReservation/MyStay/ReferenceCard"
|
||||
import Rooms from "@/components/HotelReservation/MyStay/Rooms"
|
||||
import MultiRoom from "@/components/HotelReservation/MyStay/Rooms/MultiRoom"
|
||||
import SingleRoom from "@/components/HotelReservation/MyStay/Rooms/SingleRoom"
|
||||
import SidePeek from "@/components/HotelReservation/SidePeek"
|
||||
import Image from "@/components/Image"
|
||||
import { getIntl } from "@/i18n"
|
||||
@@ -116,6 +117,11 @@ export default async function MyStay({
|
||||
rooms: booking.linkedReservations,
|
||||
})
|
||||
|
||||
const ancillariesInput = {
|
||||
fromDate,
|
||||
hotelId: hotel.operaId,
|
||||
toDate,
|
||||
}
|
||||
const packagesInput = {
|
||||
adults: booking.adults,
|
||||
children: booking.childrenAges.length,
|
||||
@@ -141,21 +147,27 @@ export default async function MyStay({
|
||||
if (shouldFetchBreakfastPackages) {
|
||||
void getPackages(packagesInput)
|
||||
}
|
||||
void getSavedPaymentCardsSafely(savedPaymentCardsInput)
|
||||
|
||||
const ancillaryPackages = await getAncillaryPackages({
|
||||
fromDate,
|
||||
hotelId: hotel.operaId,
|
||||
toDate,
|
||||
})
|
||||
if (user) {
|
||||
void getSavedPaymentCardsSafely(savedPaymentCardsInput)
|
||||
}
|
||||
if (booking.showAncillaries) {
|
||||
void getAncillaryPackages(ancillariesInput)
|
||||
}
|
||||
|
||||
let breakfastPackages = null
|
||||
if (shouldFetchBreakfastPackages) {
|
||||
breakfastPackages = await getPackages(packagesInput)
|
||||
}
|
||||
const savedCreditCards = await getSavedPaymentCardsSafely(
|
||||
savedPaymentCardsInput
|
||||
)
|
||||
let savedCreditCards = null
|
||||
if (user) {
|
||||
savedCreditCards = await getSavedPaymentCardsSafely(
|
||||
savedPaymentCardsInput
|
||||
)
|
||||
}
|
||||
let ancillaryPackagesPromise = null
|
||||
if (booking.showAncillaries) {
|
||||
ancillaryPackagesPromise = getAncillaryPackages(ancillariesInput)
|
||||
}
|
||||
|
||||
const imageSrc =
|
||||
hotel.hotelContent.images.imageSizes.large ??
|
||||
@@ -196,9 +208,9 @@ export default async function MyStay({
|
||||
<Header cityName={hotel.cityName} name={hotel.name} />
|
||||
<ReferenceCard />
|
||||
</div>
|
||||
{booking.showAncillaries && (
|
||||
{booking.showAncillaries && ancillaryPackagesPromise && (
|
||||
<Ancillaries
|
||||
ancillaries={ancillaryPackages}
|
||||
ancillariesPromise={ancillaryPackagesPromise}
|
||||
booking={booking}
|
||||
packages={breakfastPackages}
|
||||
user={user}
|
||||
@@ -207,7 +219,8 @@ export default async function MyStay({
|
||||
/>
|
||||
)}
|
||||
|
||||
<Rooms user={user} />
|
||||
<SingleRoom user={user} />
|
||||
<MultiRoom user={user} />
|
||||
|
||||
<BookingSummary hotel={hotel} />
|
||||
<Promo
|
||||
|
||||
@@ -28,7 +28,8 @@ import BookingSummary from "@/components/HotelReservation/MyStay/BookingSummary"
|
||||
import { Header } from "@/components/HotelReservation/MyStay/Header"
|
||||
import Promo from "@/components/HotelReservation/MyStay/Promo"
|
||||
import { ReferenceCard } from "@/components/HotelReservation/MyStay/ReferenceCard"
|
||||
import Rooms from "@/components/HotelReservation/MyStay/Rooms"
|
||||
import MultiRoom from "@/components/HotelReservation/MyStay/Rooms/MultiRoom"
|
||||
import SingleRoom from "@/components/HotelReservation/MyStay/Rooms/SingleRoom"
|
||||
import SidePeek from "@/components/HotelReservation/SidePeek"
|
||||
import Image from "@/components/Image"
|
||||
import { getIntl } from "@/i18n"
|
||||
@@ -113,6 +114,11 @@ export default async function MyStay({
|
||||
rooms: booking.linkedReservations,
|
||||
})
|
||||
|
||||
const ancillariesInput = {
|
||||
fromDate,
|
||||
hotelId: hotel.operaId,
|
||||
toDate,
|
||||
}
|
||||
const packagesInput = {
|
||||
adults: booking.adults,
|
||||
children: booking.childrenAges.length,
|
||||
@@ -133,26 +139,32 @@ 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)
|
||||
|
||||
const ancillaryPackages = await getAncillaryPackages({
|
||||
fromDate,
|
||||
hotelId: hotel.operaId,
|
||||
toDate,
|
||||
})
|
||||
if (user) {
|
||||
void getSavedPaymentCardsSafely(savedPaymentCardsInput)
|
||||
}
|
||||
if (booking.showAncillaries) {
|
||||
void getAncillaryPackages(ancillariesInput)
|
||||
}
|
||||
|
||||
let breakfastPackages = null
|
||||
if (alreadyHasABreakfastSelection) {
|
||||
if (shouldFetchBreakfastPackages) {
|
||||
breakfastPackages = await getPackages(packagesInput)
|
||||
}
|
||||
const savedCreditCards = await getSavedPaymentCardsSafely(
|
||||
savedPaymentCardsInput
|
||||
)
|
||||
let savedCreditCards = null
|
||||
if (user) {
|
||||
savedCreditCards = await getSavedPaymentCardsSafely(
|
||||
savedPaymentCardsInput
|
||||
)
|
||||
}
|
||||
let ancillaryPackagesPromise = null
|
||||
if (booking.showAncillaries) {
|
||||
ancillaryPackagesPromise = getAncillaryPackages(ancillariesInput)
|
||||
}
|
||||
|
||||
const imageSrc =
|
||||
hotel.hotelContent.images.imageSizes.large ??
|
||||
@@ -193,9 +205,9 @@ export default async function MyStay({
|
||||
<Header cityName={hotel.cityName} name={hotel.name} />
|
||||
<ReferenceCard />
|
||||
</div>
|
||||
{booking.showAncillaries && (
|
||||
{booking.showAncillaries && ancillaryPackagesPromise && (
|
||||
<Ancillaries
|
||||
ancillaries={ancillaryPackages}
|
||||
ancillariesPromise={ancillaryPackagesPromise}
|
||||
booking={booking}
|
||||
packages={breakfastPackages}
|
||||
user={user}
|
||||
@@ -204,7 +216,8 @@ export default async function MyStay({
|
||||
/>
|
||||
)}
|
||||
|
||||
<Rooms user={user} />
|
||||
<SingleRoom user={user} />
|
||||
<MultiRoom user={user} />
|
||||
|
||||
<BookingSummary hotel={hotel} />
|
||||
<Promo
|
||||
|
||||
Reference in New Issue
Block a user