feat: SW-1356 Reward night bookingflow * feat: SW-1356 Reward night bookingflow * feat: SW-1356 Removed extra param booking call * feat: SW-1356 Optimized as review comments * feat: SW-1356 Schema validation updates * feat: SW-1356 Fix after rebase * feat: SW-1356 Optimised price.redemptions check * feat: SW-1356 Updated Props naming Approved-by: Arvid Norlin
48 lines
1.3 KiB
TypeScript
48 lines
1.3 KiB
TypeScript
"use client"
|
|
|
|
import { useRatesStore } from "@/stores/select-rate"
|
|
|
|
import { RoomContext } from "@/contexts/SelectRate/Room"
|
|
|
|
import type { RoomProviderProps } from "@/types/providers/select-rate/room"
|
|
|
|
export default function RoomProvider({
|
|
children,
|
|
idx,
|
|
room,
|
|
}: RoomProviderProps) {
|
|
const activeRoom = useRatesStore((state) => state.activeRoom)
|
|
const closeSection = useRatesStore((state) => state.actions.closeSection(idx))
|
|
const modifyRate = useRatesStore((state) => state.actions.modifyRate(idx))
|
|
const roomAvailability = useRatesStore(
|
|
(state) => state.roomsAvailability?.[idx]
|
|
)
|
|
const selectFilter = useRatesStore((state) => state.actions.selectFilter(idx))
|
|
const selectRate = useRatesStore((state) => state.actions.selectRate(idx))
|
|
const selectRateRedemption = useRatesStore((state) =>
|
|
state.actions.selectRateRedemption(idx)
|
|
)
|
|
const roomNr = idx + 1
|
|
return (
|
|
<RoomContext.Provider
|
|
value={{
|
|
...room,
|
|
actions: {
|
|
closeSection,
|
|
modifyRate,
|
|
selectFilter,
|
|
selectRate,
|
|
selectRateRedemption,
|
|
},
|
|
isActiveRoom: activeRoom === idx,
|
|
isMainRoom: roomNr === 1,
|
|
roomAvailability,
|
|
roomNr,
|
|
totalRooms: room.rooms.length,
|
|
}}
|
|
>
|
|
{children}
|
|
</RoomContext.Provider>
|
|
)
|
|
}
|