Merged in fix/destinations-speed-test (pull request #1704)

Feat(destination pages): Performance improvements

* fix/destinations: try cache full response

* Added more caching

* Removed unsed env car

* wip

* merge master

* wip

* wip

* wip

* Renaming


Approved-by: Michael Zetterberg
This commit is contained in:
Linus Flood
2025-04-02 11:37:22 +00:00
parent 961e8aea91
commit e4907d4b47
34 changed files with 381 additions and 290 deletions

View File

@@ -12,7 +12,7 @@ import {
import { trackAddAncillary } from "@/utils/tracking/myStay"
import { type AncillaryQuantityFormData,quantitySchema } from "../../schema"
import { type AncillaryQuantityFormData, quantitySchema } from "../../schema"
import styles from "./actionButtons.module.css"

View File

@@ -47,7 +47,7 @@ export default function PriceDetails({
const totalPrice = isBreakfast
? breakfastData!.priceAdult * breakfastData!.nrOfAdults +
breakfastData!.priceChild * breakfastData!.nrOfPayingChildren
breakfastData!.priceChild * breakfastData!.nrOfPayingChildren
: quantityWithCard && selectedAncillary
? selectedAncillary.price.total * quantityWithCard
: null
@@ -101,15 +101,15 @@ export default function PriceDetails({
const items = isBreakfast
? getBreakfastItems(selectedAncillary, breakfastData)
: [
{
title: selectedAncillary.title,
totalPrice: selectedAncillary.price.total,
currency: selectedAncillary.price.currency,
points: selectedAncillary.points,
quantityWithCard,
quantityWithPoints,
},
]
{
title: selectedAncillary.title,
totalPrice: selectedAncillary.price.total,
currency: selectedAncillary.price.currency,
points: selectedAncillary.points,
quantityWithCard,
quantityWithPoints,
},
]
return (
<>

View File

@@ -2,4 +2,4 @@
margin: 0 auto;
padding: var(--Spacing-x-one-and-half);
width: 100%;
}
}

View File

@@ -1,4 +1,7 @@
import type { Product, RateDefinition } from "@/types/trpc/routers/hotel/roomAvailability"
import type {
Product,
RateDefinition,
} from "@/types/trpc/routers/hotel/roomAvailability"
/**
* Get terms and rate title from the rate definitions when booking code rate
@@ -12,7 +15,7 @@ export function getRateDefinition(
product: Product,
rateDefinitions: RateDefinition[],
isUserLoggedIn: boolean,
isMainRoom: boolean,
isMainRoom: boolean
) {
return rateDefinitions.find((rateDefinition) => {
if ("member" in product && product.member && isUserLoggedIn && isMainRoom) {
@@ -28,4 +31,4 @@ export function getRateDefinition(
return rateDefinition.rateCode === product.public.rateCode
}
})
}
}

View File

@@ -8,7 +8,7 @@ import type {
export function isSelectedPriceProduct(
product: PriceProduct,
selectedRate: SelectedRate | null,
roomTypeCode: string,
roomTypeCode: string
) {
if (!selectedRate) {
return false
@@ -25,15 +25,15 @@ export function isSelectedPriceProduct(
selectedRatePublic = selectedRate.product.public
}
const selectedRateIsMember = (
member && selectedRateMember &&
(member.rateCode === selectedRateMember.rateCode)
)
const selectedRateIsMember =
member &&
selectedRateMember &&
member.rateCode === selectedRateMember.rateCode
const selectedRateIsPublic = (
standard && selectedRatePublic &&
(standard.rateCode === selectedRatePublic.rateCode)
)
const selectedRateIsPublic =
standard &&
selectedRatePublic &&
standard.rateCode === selectedRatePublic.rateCode
return !!(
(selectedRateIsMember || selectedRateIsPublic) &&
selectedRate.roomTypeCode === roomTypeCode
@@ -43,15 +43,15 @@ export function isSelectedPriceProduct(
export function isSelectedCorporateCheque(
product: CorporateChequeProduct,
selectedRate: SelectedRate | null,
roomTypeCode: string,
roomTypeCode: string
) {
if (!selectedRate || !("corporateCheque" in selectedRate.product)) {
return false
}
const isSameRateCode = (
product.corporateCheque.rateCode === selectedRate.product.corporateCheque.rateCode
)
const isSameRateCode =
product.corporateCheque.rateCode ===
selectedRate.product.corporateCheque.rateCode
const isSameRoomTypeCode = selectedRate.roomTypeCode === roomTypeCode
return isSameRateCode && isSameRoomTypeCode
}
@@ -59,15 +59,14 @@ export function isSelectedCorporateCheque(
export function isSelectedVoucher(
product: VoucherProduct,
selectedRate: SelectedRate | null,
roomTypeCode: string,
roomTypeCode: string
) {
if (!selectedRate || !("voucher" in selectedRate.product)) {
return false
}
const isSameRateCode = (
const isSameRateCode =
product.voucher.rateCode === selectedRate.product.voucher.rateCode
)
const isSameRoomTypeCode = selectedRate.roomTypeCode === roomTypeCode
return isSameRateCode && isSameRoomTypeCode
}
}

View File

@@ -1,25 +1,20 @@
import type {
RoomPackage,
} from "@/types/components/hotelReservation/selectRate/roomFilter"
import type { RoomPackage } from "@/types/components/hotelReservation/selectRate/roomFilter"
export function calculatePricePerNightPriceProduct(
pricePerNight: number,
requestedPricePerNight: number | undefined,
nights: number,
petRoomPackage?: RoomPackage,
petRoomPackage?: RoomPackage
) {
const totalPrice = petRoomPackage?.localPrice
? Math.floor(
pricePerNight + (petRoomPackage.localPrice.price / nights)
)
? Math.floor(pricePerNight + petRoomPackage.localPrice.price / nights)
: Math.floor(pricePerNight)
let totalRequestedPrice = undefined
if (requestedPricePerNight) {
if (petRoomPackage?.requestedPrice) {
totalRequestedPrice = Math.floor(
requestedPricePerNight +
(petRoomPackage.requestedPrice.price / nights)
requestedPricePerNight + petRoomPackage.requestedPrice.price / nights
)
} else {
totalRequestedPrice = Math.floor(requestedPricePerNight)

View File

@@ -5,4 +5,4 @@
gap: var(--Spacing-x1);
margin: 0;
padding: var(--Spacing-x2);
}
}

View File

@@ -6,8 +6,9 @@ import { useRatesStore } from "@/stores/select-rate"
import styles from "./rooms.module.css"
export default function ScrollToList() {
const { isSingleRoomAndHasSelection } = useRatesStore(state => ({
isSingleRoomAndHasSelection: state.booking.rooms.length === 1 && !!state.rateSummary.length,
const { isSingleRoomAndHasSelection } = useRatesStore((state) => ({
isSingleRoomAndHasSelection:
state.booking.rooms.length === 1 && !!state.rateSummary.length,
}))
useEffect(() => {

View File

@@ -5,6 +5,6 @@
grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
}
.roomList>li {
.roomList > li {
width: 100%;
}
}