feat: filters work together
This commit is contained in:
committed by
Michael Zetterberg
parent
31370fe711
commit
d72c84d949
@@ -6,7 +6,7 @@ import {
|
|||||||
getBreakfastPackages,
|
getBreakfastPackages,
|
||||||
getHotel,
|
getHotel,
|
||||||
getProfileSafely,
|
getProfileSafely,
|
||||||
getSelectedRoomsAvailability,
|
getSelectedRoomsAvailabilityEnterDetails,
|
||||||
} from "@/lib/trpc/memoizedRequests"
|
} from "@/lib/trpc/memoizedRequests"
|
||||||
|
|
||||||
import HotelHeader from "@/components/HotelReservation/EnterDetails/Header"
|
import HotelHeader from "@/components/HotelReservation/EnterDetails/Header"
|
||||||
@@ -61,7 +61,7 @@ export default async function DetailsPage({
|
|||||||
void getBreakfastPackages(breakfastInput)
|
void getBreakfastPackages(breakfastInput)
|
||||||
void getProfileSafely()
|
void getProfileSafely()
|
||||||
|
|
||||||
const roomsAvailability = await getSelectedRoomsAvailability({
|
const roomsAvailability = await getSelectedRoomsAvailabilityEnterDetails({
|
||||||
booking,
|
booking,
|
||||||
lang,
|
lang,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ export default function useModifyStay({
|
|||||||
const data = await utils.hotel.availability.myStay.fetch({
|
const data = await utils.hotel.availability.myStay.fetch({
|
||||||
booking: {
|
booking: {
|
||||||
fromDate: formValues.checkInDate,
|
fromDate: formValues.checkInDate,
|
||||||
|
toDate: formValues.checkOutDate,
|
||||||
hotelId: bookedRoom.hotelId,
|
hotelId: bookedRoom.hotelId,
|
||||||
room: {
|
room: {
|
||||||
adults: bookedRoom.adults,
|
adults: bookedRoom.adults,
|
||||||
@@ -87,7 +88,6 @@ export default function useModifyStay({
|
|||||||
rateCode: bookedRoom.rateDefinition.rateCode,
|
rateCode: bookedRoom.rateDefinition.rateCode,
|
||||||
roomTypeCode: bookedRoom.roomTypeCode,
|
roomTypeCode: bookedRoom.roomTypeCode,
|
||||||
},
|
},
|
||||||
toDate: formValues.checkOutDate,
|
|
||||||
},
|
},
|
||||||
lang,
|
lang,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import { getTotalPrice } from "./utils"
|
|||||||
import styles from "./rateSummary.module.css"
|
import styles from "./rateSummary.module.css"
|
||||||
|
|
||||||
import type { RateSummaryProps } from "@/types/components/hotelReservation/selectRate/rateSummary"
|
import type { RateSummaryProps } from "@/types/components/hotelReservation/selectRate/rateSummary"
|
||||||
import { RoomPackageCodeEnum } from "@/types/components/hotelReservation/selectRate/roomFilter"
|
|
||||||
import { RateEnum } from "@/types/enums/rate"
|
import { RateEnum } from "@/types/enums/rate"
|
||||||
import { RateTypeEnum } from "@/types/enums/rateType"
|
import { RateTypeEnum } from "@/types/enums/rateType"
|
||||||
|
|
||||||
@@ -265,15 +264,12 @@ export default function RateSummary({ isUserLoggedIn }: RateSummaryProps) {
|
|||||||
return total
|
return total
|
||||||
}
|
}
|
||||||
|
|
||||||
const hasSelectedPetRoom = roomPackages.find(
|
const selectedPackagesPrice = roomPackages.reduce(
|
||||||
(pkg) => pkg.code === RoomPackageCodeEnum.PET_ROOM
|
(acc, pkg) => acc + pkg.localPrice.totalPrice,
|
||||||
)
|
0
|
||||||
if (!hasSelectedPetRoom) {
|
|
||||||
return total + price
|
|
||||||
}
|
|
||||||
return (
|
|
||||||
total + price + hasSelectedPetRoom.localPrice.totalPrice
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
return total + price + selectedPackagesPrice
|
||||||
}, 0),
|
}, 0),
|
||||||
currency: mainRoomCurrency,
|
currency: mainRoomCurrency,
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ import { useRoomContext } from "@/contexts/SelectRate/Room"
|
|||||||
|
|
||||||
import styles from "./selectedRoomPanel.module.css"
|
import styles from "./selectedRoomPanel.module.css"
|
||||||
|
|
||||||
import { RoomPackageCodeEnum } from "@/types/components/hotelReservation/selectRate/roomFilter"
|
|
||||||
import { CurrencyEnum } from "@/types/enums/currency"
|
import { CurrencyEnum } from "@/types/enums/currency"
|
||||||
import { RateEnum } from "@/types/enums/rate"
|
import { RateEnum } from "@/types/enums/rate"
|
||||||
|
|
||||||
@@ -70,13 +69,11 @@ export default function SelectedRoomPanel() {
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
let petRoomPrice = 0
|
const selectedPackagesPrice = selectedPackages.reduce(
|
||||||
const petRoomPackageSelected = selectedPackages.find(
|
(total, pkg) => total + pkg.localPrice.totalPrice,
|
||||||
(pkg) => pkg.code === RoomPackageCodeEnum.PET_ROOM
|
0
|
||||||
)
|
)
|
||||||
if (petRoomPackageSelected) {
|
const selectedPackagesPricePerNight = selectedPackagesPrice / nights
|
||||||
petRoomPrice = petRoomPackageSelected.localPrice.totalPrice / nights
|
|
||||||
}
|
|
||||||
|
|
||||||
const night = intl.formatMessage({ id: "night" })
|
const night = intl.formatMessage({ id: "night" })
|
||||||
let selectedProduct
|
let selectedProduct
|
||||||
@@ -87,10 +84,10 @@ export default function SelectedRoomPanel() {
|
|||||||
selectedRate.product.member
|
selectedRate.product.member
|
||||||
) {
|
) {
|
||||||
const { localPrice } = selectedRate.product.member
|
const { localPrice } = selectedRate.product.member
|
||||||
selectedProduct = `${localPrice.pricePerNight + petRoomPrice} ${localPrice.currency} / ${night}`
|
selectedProduct = `${localPrice.pricePerNight + selectedPackagesPricePerNight} ${localPrice.currency} / ${night}`
|
||||||
} else if ("public" in selectedRate.product && selectedRate.product.public) {
|
} else if ("public" in selectedRate.product && selectedRate.product.public) {
|
||||||
const { localPrice } = selectedRate.product.public
|
const { localPrice } = selectedRate.product.public
|
||||||
selectedProduct = `${localPrice.pricePerNight + petRoomPrice} ${localPrice.currency} / ${night}`
|
selectedProduct = `${localPrice.pricePerNight + selectedPackagesPricePerNight} ${localPrice.currency} / ${night}`
|
||||||
} else if ("corporateCheque" in selectedRate.product) {
|
} else if ("corporateCheque" in selectedRate.product) {
|
||||||
const { localPrice } = selectedRate.product.corporateCheque
|
const { localPrice } = selectedRate.product.corporateCheque
|
||||||
selectedProduct = `${localPrice.numberOfCheques} ${CurrencyEnum.CC}`
|
selectedProduct = `${localPrice.numberOfCheques} ${CurrencyEnum.CC}`
|
||||||
|
|||||||
@@ -63,26 +63,25 @@ export default function BookingCodeFilter() {
|
|||||||
appendRegularRates(room?.roomConfigurations)
|
appendRegularRates(room?.roomConfigurations)
|
||||||
}
|
}
|
||||||
|
|
||||||
const hideFilterDespiteBookingCode =
|
const hideFilter = rooms.some((room) =>
|
||||||
rooms.length &&
|
room.products.some((product) => {
|
||||||
rooms.every((room) =>
|
const isRedemption = Array.isArray(product)
|
||||||
room.products.every((product) => {
|
if (isRedemption) {
|
||||||
const isRedemption = Array.isArray(product)
|
return true
|
||||||
if (isRedemption) {
|
}
|
||||||
return true
|
|
||||||
}
|
|
||||||
const isCorporateCheque =
|
|
||||||
product.rateDefinition?.rateType === RateTypeEnum.CorporateCheque
|
|
||||||
const isVoucher =
|
|
||||||
product.rateDefinition?.rateType === RateTypeEnum.Voucher
|
|
||||||
return isCorporateCheque || isVoucher
|
|
||||||
})
|
|
||||||
)
|
|
||||||
|
|
||||||
if (
|
switch (product.rateDefinition.rateType) {
|
||||||
(booking.bookingCode && hideFilterDespiteBookingCode) ||
|
case RateTypeEnum.Arb:
|
||||||
!booking.bookingCode
|
case RateTypeEnum.CorporateCheque:
|
||||||
) {
|
case RateTypeEnum.Voucher:
|
||||||
|
return true
|
||||||
|
default:
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
|
if (hideFilter || !booking.bookingCode) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import type { SymbolCodepoints } from "react-material-symbols"
|
import type { MaterialSymbolProps } from "react-material-symbols"
|
||||||
|
|
||||||
import { RoomPackageCodeEnum } from "@/types/components/hotelReservation/selectRate/roomFilter"
|
import { RoomPackageCodeEnum } from "@/types/components/hotelReservation/selectRate/roomFilter"
|
||||||
import type { PackageEnum } from "@/types/requests/packages"
|
import type { PackageEnum } from "@/types/requests/packages"
|
||||||
|
|
||||||
export function getIconNameByPackageCode(
|
export function getIconNameByPackageCode(
|
||||||
packageCode: PackageEnum
|
packageCode: PackageEnum
|
||||||
): SymbolCodepoints {
|
): MaterialSymbolProps["icon"] {
|
||||||
switch (packageCode) {
|
switch (packageCode) {
|
||||||
case RoomPackageCodeEnum.PET_ROOM:
|
case RoomPackageCodeEnum.PET_ROOM:
|
||||||
return "pets"
|
return "pets"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import type { SymbolCodepoints } from "react-material-symbols"
|
import type { MaterialSymbolProps } from "react-material-symbols"
|
||||||
|
|
||||||
export function getBedIconName(name: string): SymbolCodepoints {
|
export function getBedIconName(name: string): MaterialSymbolProps["icon"] {
|
||||||
const iconMappings = [
|
const iconMappings = [
|
||||||
{
|
{
|
||||||
icon: "bed",
|
icon: "bed",
|
||||||
@@ -25,5 +25,5 @@ export function getBedIconName(name: string): SymbolCodepoints {
|
|||||||
]
|
]
|
||||||
|
|
||||||
const icon = iconMappings.find((icon) => icon.texts.includes(name))
|
const icon = iconMappings.find((icon) => icon.texts.includes(name))
|
||||||
return icon ? (icon.icon as SymbolCodepoints) : "single_bed"
|
return icon ? (icon.icon as MaterialSymbolProps["icon"]) : "single_bed"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -608,7 +608,7 @@
|
|||||||
"Pet room charge including VAT": "Gebyr for kæledyrsværelse inkl. moms",
|
"Pet room charge including VAT": "Gebyr for kæledyrsværelse inkl. moms",
|
||||||
"Pet-friendly": "Kæledyrsvenlig",
|
"Pet-friendly": "Kæledyrsvenlig",
|
||||||
"Pet-friendly rooms have an additional fee of 20 EUR per stay": "Kæledyrsrum har en ekstra gebyr på 20 EUR per ophold",
|
"Pet-friendly rooms have an additional fee of 20 EUR per stay": "Kæledyrsrum har en ekstra gebyr på 20 EUR per ophold",
|
||||||
"Pet-friendly rooms include a charge of approx. <b>{price}/stay</b>": "Kæledyrsvenlige værelser inkluderer et gebyr på ca. <b>{price}</b>/ophold",
|
"Pet-friendly rooms include a charge of approx. <b>{price}/stay</b>": "Kæledyrsvenlige værelser inkluderer et gebyr på ca. <b>{price}/ophold</b>",
|
||||||
"Phone": "Telefon",
|
"Phone": "Telefon",
|
||||||
"Phone is required": "Telefonnummer er påkrævet",
|
"Phone is required": "Telefonnummer er påkrævet",
|
||||||
"Phone number": "Telefonnummer",
|
"Phone number": "Telefonnummer",
|
||||||
|
|||||||
@@ -607,7 +607,7 @@
|
|||||||
"Pet room charge including VAT": "Haustierzimmergebühr inkl. MwSt.",
|
"Pet room charge including VAT": "Haustierzimmergebühr inkl. MwSt.",
|
||||||
"Pet-friendly": "Haustierfreundlich",
|
"Pet-friendly": "Haustierfreundlich",
|
||||||
"Pet-friendly rooms have an additional fee of 20 EUR per stay": "Haustierzimmer haben einen zusätzlichen Preis von 20 EUR pro Aufenthalt",
|
"Pet-friendly rooms have an additional fee of 20 EUR per stay": "Haustierzimmer haben einen zusätzlichen Preis von 20 EUR pro Aufenthalt",
|
||||||
"Pet-friendly rooms include a charge of approx. <b>{price}/stay</b>": "Für haustierfreundliche Zimmer fällt eine Gebühr von ca. <b>{price}</b>/Aufenthalt an.",
|
"Pet-friendly rooms include a charge of approx. <b>{price}/stay</b>": "Für haustierfreundliche Zimmer fällt eine Gebühr von ca. <b>{price}/Aufenthalt an.</b>",
|
||||||
"Phone": "Telefon",
|
"Phone": "Telefon",
|
||||||
"Phone is required": "Telefon ist erforderlich",
|
"Phone is required": "Telefon ist erforderlich",
|
||||||
"Phone number": "Telefonnummer",
|
"Phone number": "Telefonnummer",
|
||||||
|
|||||||
@@ -606,7 +606,7 @@
|
|||||||
"Pet room charge including VAT": "Lemmikkihuoneen maksu sis. ALV",
|
"Pet room charge including VAT": "Lemmikkihuoneen maksu sis. ALV",
|
||||||
"Pet-friendly": "Lemmikkiystävällinen",
|
"Pet-friendly": "Lemmikkiystävällinen",
|
||||||
"Pet-friendly rooms have an additional fee of 20 EUR per stay": "Lemmikkihuoneen lisäkustannus on 20 EUR per majoitus",
|
"Pet-friendly rooms have an additional fee of 20 EUR per stay": "Lemmikkihuoneen lisäkustannus on 20 EUR per majoitus",
|
||||||
"Pet-friendly rooms include a charge of approx. <b>{price}/stay</b>": "Lemmikkiystävälliset huoneet sisältävät n. <b>{price}</b>/yöpyminen",
|
"Pet-friendly rooms include a charge of approx. <b>{price}/stay</b>": "Lemmikkiystävälliset huoneet sisältävät n. <b>{price}/yöpyminen</b>",
|
||||||
"Phone": "Puhelin",
|
"Phone": "Puhelin",
|
||||||
"Phone is required": "Puhelin vaaditaan",
|
"Phone is required": "Puhelin vaaditaan",
|
||||||
"Phone number": "Puhelinnumero",
|
"Phone number": "Puhelinnumero",
|
||||||
|
|||||||
@@ -605,7 +605,7 @@
|
|||||||
"Pet room charge including VAT": "Kjæledyrromsgebyr inkl. MVA",
|
"Pet room charge including VAT": "Kjæledyrromsgebyr inkl. MVA",
|
||||||
"Pet-friendly": "Dyrevennlig",
|
"Pet-friendly": "Dyrevennlig",
|
||||||
"Pet-friendly rooms have an additional fee of 20 EUR per stay": "Kjæledyrsrom har en tilleggsavgift på 20 EUR per opphold",
|
"Pet-friendly rooms have an additional fee of 20 EUR per stay": "Kjæledyrsrom har en tilleggsavgift på 20 EUR per opphold",
|
||||||
"Pet-friendly rooms include a charge of approx. <b>{price}/stay</b>": "Kjæledyrvennlige rom inkluderer en kostnad på ca. <b>{price}</b>/opphold",
|
"Pet-friendly rooms include a charge of approx. <b>{price}/stay</b>": "Kjæledyrvennlige rom inkluderer en kostnad på ca. <b>{price}/opphold</b>",
|
||||||
"Phone": "Telefon",
|
"Phone": "Telefon",
|
||||||
"Phone is required": "Telefon kreves",
|
"Phone is required": "Telefon kreves",
|
||||||
"Phone number": "Telefonnummer",
|
"Phone number": "Telefonnummer",
|
||||||
|
|||||||
@@ -605,7 +605,7 @@
|
|||||||
"Pet room charge including VAT": "Avgift för husdjursrum inkl. moms",
|
"Pet room charge including VAT": "Avgift för husdjursrum inkl. moms",
|
||||||
"Pet-friendly": "Husdjursvänlig",
|
"Pet-friendly": "Husdjursvänlig",
|
||||||
"Pet-friendly rooms have an additional fee of 20 EUR per stay": "Husdjursrum har en extra avgift på 20 EUR per vistelse",
|
"Pet-friendly rooms have an additional fee of 20 EUR per stay": "Husdjursrum har en extra avgift på 20 EUR per vistelse",
|
||||||
"Pet-friendly rooms include a charge of approx. <b>{price}/stay</b>": "Husdjursvänliga rum har en avgift på ca. <b>{price}/vistelse",
|
"Pet-friendly rooms include a charge of approx. <b>{price}/stay</b>": "Husdjursvänliga rum har en avgift på ca. <b>{price}/vistelse</b>",
|
||||||
"Phone": "Telefon",
|
"Phone": "Telefon",
|
||||||
"Phone is required": "Telefonnummer är obligatorisk",
|
"Phone is required": "Telefonnummer är obligatorisk",
|
||||||
"Phone number": "Telefonnummer",
|
"Phone number": "Telefonnummer",
|
||||||
|
|||||||
@@ -339,7 +339,7 @@ export const getJumpToData = cache(async function getMemoizedJumpToData() {
|
|||||||
return null
|
return null
|
||||||
})
|
})
|
||||||
|
|
||||||
export const getSelectedRoomsAvailability = cache(
|
export const getSelectedRoomsAvailabilityEnterDetails = cache(
|
||||||
async function getMemoizedSelectedRoomsAvailability(
|
async function getMemoizedSelectedRoomsAvailability(
|
||||||
input: RoomsAvailabilityExtendedInputSchema
|
input: RoomsAvailabilityExtendedInputSchema
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -1252,12 +1252,12 @@ export async function getRoomsAvailability(
|
|||||||
|
|
||||||
const cacheClient = await getCacheClient()
|
const cacheClient = await getCacheClient()
|
||||||
const availabilityResponses = await Promise.allSettled(
|
const availabilityResponses = await Promise.allSettled(
|
||||||
rooms.map(async (room: RoomsAvailabilityInputRoom) => {
|
rooms.map((room: RoomsAvailabilityInputRoom) => {
|
||||||
const cacheKey = {
|
const cacheKey = {
|
||||||
...baseCacheKey,
|
...baseCacheKey,
|
||||||
room,
|
room,
|
||||||
}
|
}
|
||||||
return await cacheClient.cacheOrGet(
|
return cacheClient.cacheOrGet(
|
||||||
stringify(cacheKey),
|
stringify(cacheKey),
|
||||||
async function () {
|
async function () {
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user