Merged in feat/enter-details-tracking (pull request #1185)
Feat/enter details tracking * feat: fixed bug in enter details tracking * Sidepeek events, lowestroomPrice and analyticsRateCode * Cleanup and fixed bug * Fixed analyticsratecode * Merge master * merge master * Removed console logs * Added ancillaries tracking to enter details * Added ancillary on confirmation page * Removed console log * Merge branch 'master' into feat/enter-details-tracking * Refactor searchparams * Hard code values for breakfast ancillary Approved-by: Joakim Jäderberg
This commit is contained in:
@@ -16,6 +16,7 @@ import {
|
||||
type TrackingSDKPageData,
|
||||
type TrackingSDKPaymentInfo,
|
||||
} from "@/types/components/tracking"
|
||||
import { BreakfastPackageEnum } from "@/types/enums/breakfast"
|
||||
|
||||
export default async function BookingConfirmation({
|
||||
confirmationNumber,
|
||||
@@ -27,6 +28,21 @@ export default async function BookingConfirmation({
|
||||
const arrivalDate = new Date(booking.checkInDate)
|
||||
const departureDate = new Date(booking.checkOutDate)
|
||||
|
||||
const breakfastPkgSelected = booking.packages.find(
|
||||
(pkg) => pkg.code === BreakfastPackageEnum.REGULAR_BREAKFAST
|
||||
)
|
||||
|
||||
const breakfastAncillary = breakfastPkgSelected && {
|
||||
hotelid: hotel.operaId,
|
||||
productName: "BreakfastAdult",
|
||||
productCategory: "", // TODO: Add category
|
||||
productId: breakfastPkgSelected.code ?? "",
|
||||
productPrice: +breakfastPkgSelected.unitPrice,
|
||||
productUnits: booking.adults,
|
||||
productPoints: 0,
|
||||
productType: "food",
|
||||
}
|
||||
|
||||
const initialPageTrackingData: TrackingSDKPageData = {
|
||||
pageId: "booking-confirmation",
|
||||
domainLanguage: lang,
|
||||
@@ -70,6 +86,7 @@ export default async function BookingConfirmation({
|
||||
roomTypeCode: booking.roomTypeCode ?? undefined,
|
||||
roomPrice: booking.roomPrice,
|
||||
bnr: booking.confirmationNumber ?? undefined,
|
||||
ancillaries: breakfastAncillary ? [breakfastAncillary] : [],
|
||||
}
|
||||
|
||||
const paymentInfo: TrackingSDKPaymentInfo = {
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
"use client"
|
||||
|
||||
import { useSearchParams } from "next/navigation"
|
||||
import { useCallback, useEffect, useMemo, useState } from "react"
|
||||
import { useIntl } from "react-intl"
|
||||
|
||||
import { trackLowestRoomPrice } from "@/utils/tracking"
|
||||
|
||||
import RoomFilter from "../RoomFilter"
|
||||
import RoomSelection from "../RoomSelection"
|
||||
import { filterDuplicateRoomTypesByLowestPrice } from "./utils"
|
||||
@@ -28,6 +31,12 @@ export default function Rooms({
|
||||
hotelType,
|
||||
isUserLoggedIn,
|
||||
}: SelectRateProps) {
|
||||
const searchParams = useSearchParams()
|
||||
|
||||
const hotelId = searchParams.get("hotel")
|
||||
const arrivalDate = searchParams.get("fromDate")
|
||||
const departureDate = searchParams.get("toDate")
|
||||
|
||||
const intl = useIntl()
|
||||
|
||||
const visibleRooms: RoomConfiguration[] = useMemo(() => {
|
||||
@@ -177,6 +186,32 @@ export default function Rooms({
|
||||
setSelectedRate(undefined)
|
||||
}, [rateSummary, selectedRate])
|
||||
|
||||
useEffect(() => {
|
||||
const pricesWithCurrencies = rooms.roomConfigurations.flatMap((room) =>
|
||||
room.products.map((product) => ({
|
||||
price: product.productType.public.localPrice.pricePerNight,
|
||||
currency: product.productType.public.localPrice.currency,
|
||||
}))
|
||||
)
|
||||
|
||||
const cheapestPrice = pricesWithCurrencies.reduce(
|
||||
(minPrice, { price }) => Math.min(minPrice, price),
|
||||
Infinity
|
||||
)
|
||||
|
||||
const currency = pricesWithCurrencies.find(
|
||||
({ price }) => price === cheapestPrice
|
||||
)?.currency
|
||||
|
||||
trackLowestRoomPrice({
|
||||
hotelId,
|
||||
arrivalDate,
|
||||
departureDate,
|
||||
lowestPrice: cheapestPrice,
|
||||
currency: currency,
|
||||
})
|
||||
}, [arrivalDate, departureDate, hotelId, rooms.roomConfigurations])
|
||||
|
||||
return (
|
||||
<div className={styles.content}>
|
||||
<RoomFilter
|
||||
|
||||
@@ -27,8 +27,8 @@ export default async function TrackingSDK({
|
||||
<RouterTransition
|
||||
pageData={pageData}
|
||||
userData={userTrackingData}
|
||||
// hotelInfo={hotelInfo}
|
||||
//paymentInfo={paymentInfo}
|
||||
hotelInfo={hotelInfo}
|
||||
paymentInfo={paymentInfo}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user