Merged in fix/SW-2440-breakfast-tracking (pull request #1947)
Fix/SW-2440 breakfast tracking * fix(SW-2440): fix confirmation ancillaries tracking * fix(SW-2440): add breakfast ancillary when preselected Approved-by: Bianca Widstam
This commit is contained in:
@@ -16,6 +16,7 @@ import {
|
||||
type TrackingSDKPageData,
|
||||
} from "@/types/components/tracking"
|
||||
import { CurrencyEnum } from "@/types/enums/currency"
|
||||
import { PackageTypeEnum } from "@/types/enums/packages"
|
||||
import type { Hotel } from "@/types/hotel"
|
||||
import type { Room } from "@/types/providers/details/room"
|
||||
import type { RoomState } from "@/types/stores/enter-details"
|
||||
@@ -196,7 +197,7 @@ export function getTracking(
|
||||
.join(","),
|
||||
}
|
||||
const roomsWithPetRoom = rooms.filter(hasPetRoom)
|
||||
const ancillaries: TrackingSDKAncillaries = roomsWithPetRoom
|
||||
const petRoomAncillaries: TrackingSDKAncillaries = roomsWithPetRoom
|
||||
.slice(0, 1) // should only be one item
|
||||
.map((room) => {
|
||||
return room.packages
|
||||
@@ -213,6 +214,25 @@ export function getTracking(
|
||||
}))[0]
|
||||
})
|
||||
|
||||
const breakfastAncillaries: TrackingSDKAncillaries = storedRooms
|
||||
.map((room) => {
|
||||
return { breakfast: room.room.breakfast, adults: room.room.adults }
|
||||
})
|
||||
.filter(hasBreakfast)
|
||||
.map(({ breakfast, adults }) => {
|
||||
return {
|
||||
hotelId: hotel.operaId,
|
||||
productId: breakfast.code,
|
||||
productUnits: adults,
|
||||
productPoints: 0,
|
||||
productPrice: breakfast.localPrice.totalPrice,
|
||||
productType: "food",
|
||||
productName: breakfast.description,
|
||||
productCategory: breakfast.packageType,
|
||||
}
|
||||
})
|
||||
const ancillaries = petRoomAncillaries.concat(breakfastAncillaries)
|
||||
|
||||
return {
|
||||
hotelsTrackingData,
|
||||
pageTrackingData,
|
||||
@@ -247,6 +267,21 @@ function hasPetRoom(
|
||||
return room.packages.some((p) => p.code === RoomPackageCodeEnum.PET_ROOM)
|
||||
}
|
||||
|
||||
type RoomEntry = {
|
||||
breakfast?: BreakfastPackages[number] | false
|
||||
adults: number
|
||||
}
|
||||
|
||||
function hasBreakfast(entry: RoomEntry): entry is RoomEntry & {
|
||||
breakfast: BreakfastPackages[number]
|
||||
adults: number
|
||||
} {
|
||||
return (
|
||||
entry.breakfast !== false &&
|
||||
entry.breakfast?.packageType === PackageTypeEnum.BreakfastAdult
|
||||
)
|
||||
}
|
||||
|
||||
function calcTotalPrice(rooms: Room[], isMember: boolean) {
|
||||
const totalRoomPrice = calcTotalRoomPrice(rooms, isMember)
|
||||
const totalPackageSum = rooms.reduce((total, room) => {
|
||||
|
||||
Reference in New Issue
Block a user