Merged in feat/SW-2113-allow-feature-combinations (pull request #1719)
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
This commit is contained in:
@@ -24,14 +24,16 @@ export default function RoomProvider({
|
||||
roomAvailability,
|
||||
searchParams,
|
||||
selectedFilter,
|
||||
selectedPackages,
|
||||
} = useRatesStore((state) => ({
|
||||
activeRoom: state.activeRoom,
|
||||
booking: state.booking,
|
||||
roomAvailability: state.roomsAvailability?.[idx],
|
||||
searchParams: state.searchParams,
|
||||
selectedFilter: state.rooms[idx].selectedFilter,
|
||||
selectedPackages: state.rooms[idx].selectedPackages,
|
||||
}))
|
||||
const { appendRegularRates, ...actions } = room.actions
|
||||
const { appendRegularRates, addRoomFeatures, ...actions } = room.actions
|
||||
const roomNr = idx + 1
|
||||
|
||||
const redemptionSearch = searchParams.has("searchType")
|
||||
@@ -91,6 +93,40 @@ export default function RoomProvider({
|
||||
}
|
||||
}, [appendRegularRates, data, enabled, isFetched, isFetching])
|
||||
|
||||
const {
|
||||
data: roomFeaturesData,
|
||||
isFetched: isRoomFeaturesFetched,
|
||||
isFetching: isRoomFeaturesFetching,
|
||||
} = trpc.hotel.availability.roomFeatures.useQuery(
|
||||
{
|
||||
adults: room.bookingRoom.adults,
|
||||
childrenInRoom: room.bookingRoom.childrenInRoom,
|
||||
hotelId: booking.hotelId,
|
||||
startDate: booking.fromDate,
|
||||
endDate: booking.toDate,
|
||||
roomFeatureCodes: selectedPackages,
|
||||
roomIndex: idx, // Creates a unique query key for each room
|
||||
},
|
||||
{
|
||||
enabled: !!selectedPackages.length,
|
||||
}
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
if (
|
||||
isRoomFeaturesFetched &&
|
||||
!isRoomFeaturesFetching &&
|
||||
roomFeaturesData?.length
|
||||
) {
|
||||
addRoomFeatures(roomFeaturesData)
|
||||
}
|
||||
}, [
|
||||
addRoomFeatures,
|
||||
roomFeaturesData,
|
||||
isRoomFeaturesFetched,
|
||||
isRoomFeaturesFetching,
|
||||
])
|
||||
|
||||
return (
|
||||
<RoomContext.Provider
|
||||
value={{
|
||||
@@ -98,6 +134,9 @@ export default function RoomProvider({
|
||||
actions,
|
||||
isActiveRoom: activeRoom === idx,
|
||||
isFetchingAdditionalRate: isFetched ? false : isFetching,
|
||||
isFetchingRoomFeatures: isRoomFeaturesFetched
|
||||
? false
|
||||
: isRoomFeaturesFetching,
|
||||
isMainRoom: roomNr === 1,
|
||||
roomAvailability,
|
||||
roomNr,
|
||||
|
||||
Reference in New Issue
Block a user