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 { useSelectRateContext } from "../../../contexts/SelectRate/SelectRateContext"
|
||||
import { trackLowestRoomPrice } from "../Tracking/tracking"
|
||||
import { trackLowestRoomPrice, trackRoomsLoaded } from "../Tracking/tracking"
|
||||
import { RateSummary } from "./RateSummary"
|
||||
import Rooms from "./Rooms"
|
||||
import { RoomsContainerSkeleton } from "./RoomsContainerSkeleton"
|
||||
@@ -30,22 +30,36 @@ export function RoomsContainer({}: RoomsContainerProps) {
|
||||
getLowestRoomPrice,
|
||||
} = useSelectRateContext()
|
||||
|
||||
const { price: lowestRoomPrice, currency: lowestRoomPriceCurrency } =
|
||||
getLowestRoomPrice() ?? {}
|
||||
const dataAvailable = availabilityData?.length
|
||||
const { hotelId, fromDate, toDate } = inputData?.booking ?? {}
|
||||
|
||||
useEffect(() => {
|
||||
if (!availabilityData) return
|
||||
if (!dataAvailable) return
|
||||
|
||||
const lowestRoomPrice = getLowestRoomPrice()
|
||||
const booking = inputData?.booking
|
||||
|
||||
if (!booking || !lowestRoomPrice) return
|
||||
if (!hotelId || !fromDate || !toDate || !lowestRoomPrice) return
|
||||
|
||||
trackLowestRoomPrice({
|
||||
hotelId: booking.hotelId,
|
||||
arrivalDate: booking?.fromDate,
|
||||
departureDate: booking?.toDate,
|
||||
lowestPrice: lowestRoomPrice.price.toString(),
|
||||
currency: lowestRoomPrice.currency,
|
||||
hotelId: hotelId,
|
||||
arrivalDate: fromDate,
|
||||
departureDate: toDate,
|
||||
lowestPrice: lowestRoomPrice.toString(),
|
||||
currency: lowestRoomPriceCurrency,
|
||||
})
|
||||
}, [availabilityData, inputData, getLowestRoomPrice])
|
||||
}, [
|
||||
dataAvailable,
|
||||
hotelId,
|
||||
fromDate,
|
||||
toDate,
|
||||
lowestRoomPrice,
|
||||
lowestRoomPriceCurrency,
|
||||
])
|
||||
|
||||
useEffect(() => {
|
||||
if (isFetching) return
|
||||
trackRoomsLoaded()
|
||||
}, [isFetching])
|
||||
|
||||
if (isFetching) {
|
||||
return <RoomsContainerSkeleton />
|
||||
|
||||
@@ -105,3 +105,9 @@ export function trackLowestRoomPrice(event: LowestRoomPriceEvent) {
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export function trackRoomsLoaded() {
|
||||
trackEvent({
|
||||
event: "RoomsLoadedEvent",
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user