Merged in fix/BOOK-457-select-rate-lowestroomprice- (pull request #3061)
* Fix(BOOK-457): Reduced lowestRoomPrice tracking call from multiple times to one * fix(BOOK-457): feat(SW-3590): Included RoomsLoadedEvent on select-rate page Approved-by: Linus Flood
This commit is contained in:
@@ -8,7 +8,7 @@ import { AlertTypeEnum } from "@scandic-hotels/common/constants/alert"
|
|||||||
import { Alert } from "@scandic-hotels/design-system/Alert"
|
import { Alert } from "@scandic-hotels/design-system/Alert"
|
||||||
|
|
||||||
import { useSelectRateContext } from "../../../contexts/SelectRate/SelectRateContext"
|
import { useSelectRateContext } from "../../../contexts/SelectRate/SelectRateContext"
|
||||||
import { trackLowestRoomPrice } from "../Tracking/tracking"
|
import { trackLowestRoomPrice, trackRoomsLoaded } from "../Tracking/tracking"
|
||||||
import { RateSummary } from "./RateSummary"
|
import { RateSummary } from "./RateSummary"
|
||||||
import Rooms from "./Rooms"
|
import Rooms from "./Rooms"
|
||||||
import { RoomsContainerSkeleton } from "./RoomsContainerSkeleton"
|
import { RoomsContainerSkeleton } from "./RoomsContainerSkeleton"
|
||||||
@@ -30,22 +30,36 @@ export function RoomsContainer({}: RoomsContainerProps) {
|
|||||||
getLowestRoomPrice,
|
getLowestRoomPrice,
|
||||||
} = useSelectRateContext()
|
} = useSelectRateContext()
|
||||||
|
|
||||||
|
const { price: lowestRoomPrice, currency: lowestRoomPriceCurrency } =
|
||||||
|
getLowestRoomPrice() ?? {}
|
||||||
|
const dataAvailable = availabilityData?.length
|
||||||
|
const { hotelId, fromDate, toDate } = inputData?.booking ?? {}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!availabilityData) return
|
if (!dataAvailable) return
|
||||||
|
|
||||||
const lowestRoomPrice = getLowestRoomPrice()
|
if (!hotelId || !fromDate || !toDate || !lowestRoomPrice) return
|
||||||
const booking = inputData?.booking
|
|
||||||
|
|
||||||
if (!booking || !lowestRoomPrice) return
|
|
||||||
|
|
||||||
trackLowestRoomPrice({
|
trackLowestRoomPrice({
|
||||||
hotelId: booking.hotelId,
|
hotelId: hotelId,
|
||||||
arrivalDate: booking?.fromDate,
|
arrivalDate: fromDate,
|
||||||
departureDate: booking?.toDate,
|
departureDate: toDate,
|
||||||
lowestPrice: lowestRoomPrice.price.toString(),
|
lowestPrice: lowestRoomPrice.toString(),
|
||||||
currency: lowestRoomPrice.currency,
|
currency: lowestRoomPriceCurrency,
|
||||||
})
|
})
|
||||||
}, [availabilityData, inputData, getLowestRoomPrice])
|
}, [
|
||||||
|
dataAvailable,
|
||||||
|
hotelId,
|
||||||
|
fromDate,
|
||||||
|
toDate,
|
||||||
|
lowestRoomPrice,
|
||||||
|
lowestRoomPriceCurrency,
|
||||||
|
])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (isFetching) return
|
||||||
|
trackRoomsLoaded()
|
||||||
|
}, [isFetching])
|
||||||
|
|
||||||
if (isFetching) {
|
if (isFetching) {
|
||||||
return <RoomsContainerSkeleton />
|
return <RoomsContainerSkeleton />
|
||||||
|
|||||||
@@ -105,3 +105,9 @@ export function trackLowestRoomPrice(event: LowestRoomPriceEvent) {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function trackRoomsLoaded() {
|
||||||
|
trackEvent({
|
||||||
|
event: "RoomsLoadedEvent",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user