feat(SW-718) updates after PR comments
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
import RoomFilter from "../RoomFilter"
|
||||
import RoomList from "../RoomList"
|
||||
import { useSearchParams } from "next/navigation"
|
||||
import { useMemo } from "react"
|
||||
|
||||
import RoomTypeFilter from "../RoomTypeFilter"
|
||||
import RoomTypeList from "../RoomTypeList"
|
||||
|
||||
import type { FilterValues } from "@/types/components/hotelReservation/selectRate/roomFilter"
|
||||
import type { RoomSelectionPanelProps } from "@/types/components/hotelReservation/selectRate/roomSelection"
|
||||
|
||||
export function RoomSelectionPanel({
|
||||
@@ -13,15 +17,27 @@ export function RoomSelectionPanel({
|
||||
defaultPackages,
|
||||
roomListIndex,
|
||||
}: RoomSelectionPanelProps) {
|
||||
const searchParams = useSearchParams()
|
||||
|
||||
const initialFilterValues = useMemo(() => {
|
||||
const packagesFromSearchParams =
|
||||
searchParams.get(`room[${roomListIndex}].packages`)?.split(",") ?? []
|
||||
|
||||
return defaultPackages.reduce<FilterValues>((acc, option) => {
|
||||
acc[option.code] = packagesFromSearchParams.includes(option.code)
|
||||
return acc
|
||||
}, {})
|
||||
}, [defaultPackages, searchParams, roomListIndex])
|
||||
|
||||
return (
|
||||
<>
|
||||
<RoomFilter
|
||||
<RoomTypeFilter
|
||||
numberOfRooms={rooms.roomConfigurations.length}
|
||||
onFilter={handleFilter}
|
||||
filterOptions={defaultPackages}
|
||||
roomListIndex={roomListIndex}
|
||||
initialFilterValues={initialFilterValues}
|
||||
/>
|
||||
<RoomList
|
||||
<RoomTypeList
|
||||
roomsAvailability={rooms}
|
||||
roomCategories={roomCategories}
|
||||
availablePackages={availablePackages}
|
||||
|
||||
Reference in New Issue
Block a user