fix: make sure calculations in booking flow are correct
This commit is contained in:
committed by
Michael Zetterberg
parent
3e0f503314
commit
a222ecfc5c
@@ -42,6 +42,15 @@ export default function RoomProvider({
|
||||
const dontShowRegularRates =
|
||||
hasRedemptionRates || hasCorporateChequeOrVoucherRates
|
||||
|
||||
// Since input would be the same on single room as already
|
||||
// done in useRoomsAvailability hook, data is already present
|
||||
// and thus runs the appendRegularRates updater resulting in
|
||||
// duplicate data
|
||||
const enabled = !!(
|
||||
booking.bookingCode &&
|
||||
selectedFilter === BookingCodeFilterEnum.All &&
|
||||
!dontShowRegularRates
|
||||
)
|
||||
// Extra query needed to fetch regular rates upon user
|
||||
// selecting to view all rates.
|
||||
// TODO: Setup route to handle singular availability call
|
||||
@@ -58,22 +67,18 @@ export default function RoomProvider({
|
||||
roomStayStartDate: booking.fromDate,
|
||||
},
|
||||
{
|
||||
enabled: !!(
|
||||
booking.bookingCode &&
|
||||
selectedFilter === BookingCodeFilterEnum.All &&
|
||||
!dontShowRegularRates
|
||||
),
|
||||
enabled,
|
||||
}
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
if (isFetched && !isFetching && data?.length) {
|
||||
if (isFetched && !isFetching && data?.length && enabled) {
|
||||
const regularRates = data[0]
|
||||
if ("roomConfigurations" in regularRates) {
|
||||
appendRegularRates(regularRates.roomConfigurations)
|
||||
}
|
||||
}
|
||||
}, [appendRegularRates, data, isFetched, isFetching])
|
||||
}, [appendRegularRates, data, enabled, isFetched, isFetching])
|
||||
|
||||
return (
|
||||
<RoomContext.Provider
|
||||
|
||||
Reference in New Issue
Block a user