Feat/SW-2113 allow feature combinations * feat(SW-2113): Refactor features data to be fetched on filter room filter change * feat(SW-2113): added loading state * fix: now clear room selection when applying filter and room doesnt exists. And added room features to mobile summary * fix * fix: add package to price details * feat(SW-2113): added buttons to room filter * fix: active room * fix: remove console log * fix: added form and close handler to room package filter * fix: add restriction so you cannot select pet room with allergy room and vice versa * fix: fixes from review feedback * fix * fix: hide modify button if on nextcoming rooms if no selection is made, and adjust filter logic in togglePackage * fix: forgot to use roomFeatureCodes from input.. * fix: naming Approved-by: Simon.Emanuelsson
73 lines
1.7 KiB
TypeScript
73 lines
1.7 KiB
TypeScript
"use client"
|
|
|
|
import { dt } from "@/lib/dt"
|
|
|
|
import useLang from "@/hooks/useLang"
|
|
import RatesProvider from "@/providers/RatesProvider"
|
|
|
|
import { useHotelPackages, useRoomsAvailability } from "../utils"
|
|
import RateSummary from "./RateSummary"
|
|
import Rooms from "./Rooms"
|
|
import { RoomsContainerSkeleton } from "./RoomsContainerSkeleton"
|
|
|
|
import type { RoomsContainerProps } from "@/types/components/hotelReservation/selectRate/roomsContainer"
|
|
|
|
export function RoomsContainer({
|
|
adultArray,
|
|
booking,
|
|
childArray,
|
|
fromDate,
|
|
hotelData,
|
|
isUserLoggedIn,
|
|
toDate,
|
|
}: RoomsContainerProps) {
|
|
const lang = useLang()
|
|
|
|
const fromDateString = dt(fromDate).format("YYYY-MM-DD")
|
|
const toDateString = dt(toDate).format("YYYY-MM-DD")
|
|
|
|
const { data: roomsAvailability, isPending: isLoadingAvailability } =
|
|
useRoomsAvailability(
|
|
adultArray,
|
|
hotelData.hotel.id,
|
|
fromDateString,
|
|
toDateString,
|
|
lang,
|
|
childArray,
|
|
booking
|
|
)
|
|
|
|
const { data: packages, isPending: isLoadingPackages } = useHotelPackages(
|
|
adultArray,
|
|
childArray,
|
|
fromDateString,
|
|
toDateString,
|
|
hotelData.hotel.id,
|
|
lang
|
|
)
|
|
|
|
if (isLoadingAvailability || isLoadingPackages) {
|
|
return <RoomsContainerSkeleton />
|
|
}
|
|
|
|
if (packages === null) {
|
|
// TODO: Log packages error
|
|
console.error("[RoomsContainer] unable to fetch packages")
|
|
}
|
|
|
|
return (
|
|
<RatesProvider
|
|
booking={booking}
|
|
hotelType={hotelData.hotel.hotelType}
|
|
isUserLoggedIn={isUserLoggedIn}
|
|
packages={packages}
|
|
roomCategories={hotelData.roomCategories}
|
|
roomsAvailability={roomsAvailability}
|
|
vat={hotelData.hotel.vat}
|
|
>
|
|
<Rooms />
|
|
<RateSummary isUserLoggedIn={isUserLoggedIn} />
|
|
</RatesProvider>
|
|
)
|
|
}
|