Merged in fix/SW-3442-tracking-event-lowestroomprice- (pull request #2797)
fix(SW-3442): Fixed lowest price tracking and other lint issues * fix(SW-3442): Fixed lowest price tracking and other lint issues Approved-by: Joakim Jäderberg
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
"use client"
|
||||
|
||||
import { TRPCClientError } from "@trpc/client"
|
||||
import { useEffect } from "react"
|
||||
import { useIntl } from "react-intl"
|
||||
|
||||
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 { RateSummary } from "./RateSummary"
|
||||
import Rooms from "./Rooms"
|
||||
import { RoomsContainerSkeleton } from "./RoomsContainerSkeleton"
|
||||
@@ -23,10 +25,26 @@ export function RoomsContainer({}: RoomsContainerProps) {
|
||||
const intl = useIntl()
|
||||
|
||||
const {
|
||||
availability: { error, isFetching, isError },
|
||||
input: { hasError: hasInputError, errorCode },
|
||||
availability: { error, isFetching, isError, data: availabilityData },
|
||||
input: { hasError: hasInputError, errorCode, data: inputData },
|
||||
getLowestRoomPrice,
|
||||
} = useSelectRateContext()
|
||||
|
||||
useEffect(() => {
|
||||
if (availabilityData) {
|
||||
const lowestRoomPrice = getLowestRoomPrice()
|
||||
const booking = inputData?.booking!
|
||||
|
||||
trackLowestRoomPrice({
|
||||
hotelId: booking.hotelId,
|
||||
arrivalDate: booking?.fromDate,
|
||||
departureDate: booking?.toDate,
|
||||
lowestPrice: lowestRoomPrice.price.toString(),
|
||||
currency: lowestRoomPrice.currency,
|
||||
})
|
||||
}
|
||||
}, [availabilityData, inputData, getLowestRoomPrice])
|
||||
|
||||
if (isFetching) {
|
||||
return <RoomsContainerSkeleton />
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user