Merged in fix/SW-2668-tracking-room-details-missing (pull request #2015)
fix(SW-2668): added search term and room details to tracking * fix(SW-2668): added search term and room details to tracking * fix: change to optional type Approved-by: Christian Andolf Approved-by: Matilda Landström
This commit is contained in:
@@ -156,7 +156,6 @@ export default async function DetailsPage({
|
|||||||
<EnterDetailsTrackingWrapper
|
<EnterDetailsTrackingWrapper
|
||||||
booking={booking}
|
booking={booking}
|
||||||
hotel={hotel}
|
hotel={hotel}
|
||||||
city={searchParams.city}
|
|
||||||
isMember={!!user}
|
isMember={!!user}
|
||||||
lang={lang}
|
lang={lang}
|
||||||
rooms={rooms}
|
rooms={rooms}
|
||||||
|
|||||||
@@ -13,10 +13,10 @@ import { Typography } from "@scandic-hotels/design-system/Typography"
|
|||||||
import { type AutoCompleteLocation } from "@/server/routers/autocomplete/schema"
|
import { type AutoCompleteLocation } from "@/server/routers/autocomplete/schema"
|
||||||
|
|
||||||
import SkeletonShimmer from "@/components/SkeletonShimmer"
|
import SkeletonShimmer from "@/components/SkeletonShimmer"
|
||||||
|
import { useSearchHistory } from "@/hooks/useSearchHistory"
|
||||||
|
|
||||||
import { Input } from "../Input"
|
import { Input } from "../Input"
|
||||||
import SearchList from "./SearchList"
|
import SearchList from "./SearchList"
|
||||||
import { useSearchHistory } from "./useSearchHistory"
|
|
||||||
|
|
||||||
import styles from "./search.module.css"
|
import styles from "./search.module.css"
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { useBookingConfirmationStore } from "@/stores/booking-confirmation"
|
|||||||
|
|
||||||
import TrackingSDK from "@/components/TrackingSDK"
|
import TrackingSDK from "@/components/TrackingSDK"
|
||||||
import useLang from "@/hooks/useLang"
|
import useLang from "@/hooks/useLang"
|
||||||
|
import { useSearchHistory } from "@/hooks/useSearchHistory"
|
||||||
|
|
||||||
import { getTracking } from "./tracking"
|
import { getTracking } from "./tracking"
|
||||||
|
|
||||||
@@ -33,6 +34,9 @@ export default function Tracking({
|
|||||||
sessionStorage.setItem("loadedBookingConfirmationRefId", refId)
|
sessionStorage.setItem("loadedBookingConfirmationRefId", refId)
|
||||||
}, [refId])
|
}, [refId])
|
||||||
|
|
||||||
|
const searchHistory = useSearchHistory()
|
||||||
|
const searchTerm = searchHistory.searchHistory[0]?.name
|
||||||
|
|
||||||
if (!bookingRooms.every(Boolean)) {
|
if (!bookingRooms.every(Boolean)) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
@@ -44,7 +48,8 @@ export default function Tracking({
|
|||||||
lang,
|
lang,
|
||||||
bookingConfirmation.booking,
|
bookingConfirmation.booking,
|
||||||
bookingConfirmation.hotel,
|
bookingConfirmation.hotel,
|
||||||
rooms
|
rooms,
|
||||||
|
searchTerm
|
||||||
)
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -58,7 +58,8 @@ export function getTracking(
|
|||||||
lang: Lang,
|
lang: Lang,
|
||||||
booking: BookingConfirmation["booking"],
|
booking: BookingConfirmation["booking"],
|
||||||
hotel: BookingConfirmation["hotel"],
|
hotel: BookingConfirmation["hotel"],
|
||||||
rooms: Room[]
|
rooms: Room[],
|
||||||
|
searchTerm?: string
|
||||||
) {
|
) {
|
||||||
const arrivalDate = new Date(booking.checkInDate)
|
const arrivalDate = new Date(booking.checkInDate)
|
||||||
const departureDate = new Date(booking.checkOutDate)
|
const departureDate = new Date(booking.checkOutDate)
|
||||||
@@ -150,6 +151,7 @@ export function getTracking(
|
|||||||
points: booking.roomPoints > 0 ? booking.roomPoints : undefined,
|
points: booking.roomPoints > 0 ? booking.roomPoints : undefined,
|
||||||
roomPrice: rooms.reduce((total, room) => total + room.roomPrice, 0),
|
roomPrice: rooms.reduce((total, room) => total + room.roomPrice, 0),
|
||||||
roomTypeCode: rooms.map((r) => r.roomTypeCode ?? "").join(","),
|
roomTypeCode: rooms.map((r) => r.roomTypeCode ?? "").join(","),
|
||||||
|
searchTerm,
|
||||||
searchType: "hotel",
|
searchType: "hotel",
|
||||||
specialRoomType: rooms
|
specialRoomType: rooms
|
||||||
.map((room) => getSpecialRoomType(room.packages))
|
.map((room) => getSpecialRoomType(room.packages))
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
import { useEnterDetailsStore } from "@/stores/enter-details"
|
import { useEnterDetailsStore } from "@/stores/enter-details"
|
||||||
|
|
||||||
import TrackingSDK from "@/components/TrackingSDK"
|
import TrackingSDK from "@/components/TrackingSDK"
|
||||||
|
import { useSearchHistory } from "@/hooks/useSearchHistory"
|
||||||
|
|
||||||
import { getTracking } from "./tracking"
|
import { getTracking } from "./tracking"
|
||||||
|
|
||||||
@@ -16,7 +17,6 @@ interface TrackingWrapperProps {
|
|||||||
booking: SelectHotelParams<SelectRateSearchParams>
|
booking: SelectHotelParams<SelectRateSearchParams>
|
||||||
hotel: Hotel
|
hotel: Hotel
|
||||||
rooms: Room[]
|
rooms: Room[]
|
||||||
city: string | undefined
|
|
||||||
isMember: boolean
|
isMember: boolean
|
||||||
lang: Lang
|
lang: Lang
|
||||||
}
|
}
|
||||||
@@ -25,7 +25,6 @@ export default function EnterDetailsTrackingWrapper({
|
|||||||
booking,
|
booking,
|
||||||
hotel,
|
hotel,
|
||||||
rooms,
|
rooms,
|
||||||
city,
|
|
||||||
isMember,
|
isMember,
|
||||||
lang,
|
lang,
|
||||||
}: TrackingWrapperProps) {
|
}: TrackingWrapperProps) {
|
||||||
@@ -34,15 +33,18 @@ export default function EnterDetailsTrackingWrapper({
|
|||||||
breakfastPackages: state.breakfastPackages,
|
breakfastPackages: state.breakfastPackages,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
const searchHistory = useSearchHistory()
|
||||||
|
const searchTerm = searchHistory.searchHistory[0]?.name
|
||||||
|
|
||||||
const { hotelsTrackingData, pageTrackingData, ancillaries } = getTracking(
|
const { hotelsTrackingData, pageTrackingData, ancillaries } = getTracking(
|
||||||
booking,
|
booking,
|
||||||
hotel,
|
hotel,
|
||||||
rooms,
|
rooms,
|
||||||
city,
|
|
||||||
isMember,
|
isMember,
|
||||||
lang,
|
lang,
|
||||||
storedRooms,
|
storedRooms,
|
||||||
breakfastPackages
|
breakfastPackages,
|
||||||
|
searchTerm
|
||||||
)
|
)
|
||||||
return (
|
return (
|
||||||
<TrackingSDK
|
<TrackingSDK
|
||||||
|
|||||||
@@ -31,11 +31,11 @@ export function getTracking(
|
|||||||
booking: SelectHotelParams<SelectRateSearchParams>,
|
booking: SelectHotelParams<SelectRateSearchParams>,
|
||||||
hotel: Hotel,
|
hotel: Hotel,
|
||||||
rooms: Room[],
|
rooms: Room[],
|
||||||
city: string | undefined,
|
|
||||||
isMember: boolean,
|
isMember: boolean,
|
||||||
lang: Lang,
|
lang: Lang,
|
||||||
storedRooms: RoomState[],
|
storedRooms: RoomState[],
|
||||||
breakfastPackages: BreakfastPackages
|
breakfastPackages: BreakfastPackages,
|
||||||
|
searchTerm?: string
|
||||||
) {
|
) {
|
||||||
const arrivalDate = new Date(booking.fromDate)
|
const arrivalDate = new Date(booking.fromDate)
|
||||||
const departureDate = new Date(booking.toDate)
|
const departureDate = new Date(booking.toDate)
|
||||||
@@ -185,12 +185,14 @@ export function getTracking(
|
|||||||
rewardNightAvailability:
|
rewardNightAvailability:
|
||||||
booking.searchType === REDEMPTION ? "true" : "false",
|
booking.searchType === REDEMPTION ? "true" : "false",
|
||||||
roomPrice: calcTotalRoomPrice(storedRooms, isMember),
|
roomPrice: calcTotalRoomPrice(storedRooms, isMember),
|
||||||
|
roomTypeCode: rooms.map((room) => room.roomTypeCode).join("|"),
|
||||||
|
roomTypeName: rooms.map((room) => room.roomType).join("|"),
|
||||||
totalPrice: calcTotalPrice(storedRooms, isMember),
|
totalPrice: calcTotalPrice(storedRooms, isMember),
|
||||||
points:
|
points:
|
||||||
// @ts-expect-error - redemption object doesn't exist error
|
// @ts-expect-error - redemption object doesn't exist error
|
||||||
rooms.find((room) => "redemption" in room.roomRate)?.roomRate.redemption
|
rooms.find((room) => "redemption" in room.roomRate)?.roomRate.redemption
|
||||||
.localPrice.pointsPerStay ?? "n/a",
|
.localPrice.pointsPerStay ?? "n/a",
|
||||||
searchTerm: city,
|
searchTerm,
|
||||||
searchType: "hotel",
|
searchType: "hotel",
|
||||||
specialRoomType: rooms
|
specialRoomType: rooms
|
||||||
.map((room) => getSpecialRoomType(room.packages))
|
.map((room) => getSpecialRoomType(room.packages))
|
||||||
|
|||||||
Reference in New Issue
Block a user