Merged in feat/SW-2680-tracking-fixes (pull request #2373)
fix(SW-2680): Added new properties used for tracking * fix(SW-2680): Added new properties used for tracking Approved-by: Michael Zetterberg
This commit is contained in:
@@ -110,6 +110,7 @@ export function mapToPrice(rooms: (Room | null)[], nights: number) {
|
|||||||
bedType: {
|
bedType: {
|
||||||
description: room.bedDescription,
|
description: room.bedDescription,
|
||||||
roomTypeCode: room.roomTypeCode || "",
|
roomTypeCode: room.roomTypeCode || "",
|
||||||
|
type: room.bedType,
|
||||||
},
|
},
|
||||||
breakfast,
|
breakfast,
|
||||||
breakfastIncluded: room.rateDefinition.breakfastIncluded,
|
breakfastIncluded: room.rateDefinition.breakfastIncluded,
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ export function getTracking(
|
|||||||
.join("|"),
|
.join("|"),
|
||||||
arrivalDate: format(arrivalDate, "yyyy-MM-dd"),
|
arrivalDate: format(arrivalDate, "yyyy-MM-dd"),
|
||||||
bedType: rooms
|
bedType: rooms
|
||||||
.map((r) => r.bedDescription)
|
.map((r) => r.bedType)
|
||||||
.join(",")
|
.join(",")
|
||||||
.toLowerCase(),
|
.toLowerCase(),
|
||||||
bnr: rooms.map((r) => r.confirmationNumber).join(","),
|
bnr: rooms.map((r) => r.confirmationNumber).join(","),
|
||||||
@@ -139,13 +139,10 @@ export function getTracking(
|
|||||||
noOfRooms,
|
noOfRooms,
|
||||||
rateCode: rooms.map((r) => r.rateDefinition.rateCode).join(","),
|
rateCode: rooms.map((r) => r.rateDefinition.rateCode).join(","),
|
||||||
rateCodeCancellationRule: rooms
|
rateCodeCancellationRule: rooms
|
||||||
.map((r) => r.rateDefinition.cancellationText)
|
.map((r) => r.rateDefinition.cancellationRule)
|
||||||
.join(",")
|
|
||||||
.toLowerCase(),
|
|
||||||
rateCodeName: rooms
|
|
||||||
.map((r) => r.rateDefinition.title)
|
|
||||||
.join(",")
|
.join(",")
|
||||||
.toLowerCase(),
|
.toLowerCase(),
|
||||||
|
rateCodeName: rooms.map(constructRateCodeName).join(","),
|
||||||
//rateCodeType: , //TODO: Add when available in API. "regular, promotion, corporate etx",
|
//rateCodeType: , //TODO: Add when available in API. "regular, promotion, corporate etx",
|
||||||
region: hotel?.address.city,
|
region: hotel?.address.city,
|
||||||
revenueCurrencyCode: [...new Set(rooms.map((r) => r.currencyCode))].join(
|
revenueCurrencyCode: [...new Set(rooms.map((r) => r.currencyCode))].join(
|
||||||
@@ -189,3 +186,25 @@ export function getTracking(
|
|||||||
ancillaries,
|
ancillaries,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function constructRateCodeName(room: Room) {
|
||||||
|
if (room.cheques) {
|
||||||
|
return "corporate cheque"
|
||||||
|
} else if (room.vouchers) {
|
||||||
|
return "voucher"
|
||||||
|
} else if (room.roomPoints) {
|
||||||
|
return "redemption"
|
||||||
|
}
|
||||||
|
|
||||||
|
const rate = getRate(room.rateDefinition.cancellationRule)
|
||||||
|
|
||||||
|
const bookingCodeStr = room.bookingCode ? room.bookingCode.toUpperCase() : ""
|
||||||
|
|
||||||
|
const breakfastIncludedStr = room.breakfastIncluded
|
||||||
|
? "incl. breakfast"
|
||||||
|
: "excl. breakfast"
|
||||||
|
|
||||||
|
return [bookingCodeStr, rate, breakfastIncludedStr]
|
||||||
|
.filter(Boolean)
|
||||||
|
.join(" - ")
|
||||||
|
}
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ export function mapRoomState(
|
|||||||
return {
|
return {
|
||||||
adults: booking.adults,
|
adults: booking.adults,
|
||||||
bedDescription: room.bedType.description,
|
bedDescription: room.bedType.description,
|
||||||
|
bedType: room.bedType.mainBed.type,
|
||||||
bookingCode: booking.bookingCode,
|
bookingCode: booking.bookingCode,
|
||||||
breakfast,
|
breakfast,
|
||||||
breakfastIncluded,
|
breakfastIncluded,
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ export default function BedType() {
|
|||||||
const bedType = {
|
const bedType = {
|
||||||
description: matchingRoom.description,
|
description: matchingRoom.description,
|
||||||
roomTypeCode: matchingRoom.value,
|
roomTypeCode: matchingRoom.value,
|
||||||
|
type: matchingRoom.type,
|
||||||
}
|
}
|
||||||
updateBedType(bedType)
|
updateBedType(bedType)
|
||||||
trackBedSelection(bedType.description)
|
trackBedSelection(bedType.description)
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
import { z } from "zod"
|
import { z } from "zod"
|
||||||
|
|
||||||
export const bedTypeSchema = z.object({
|
export const bedTypeSchema = z.object({
|
||||||
bedType: z.object({ description: z.string(), roomTypeCode: z.string() }),
|
bedType: z.object({
|
||||||
|
description: z.string(),
|
||||||
|
roomTypeCode: z.string(),
|
||||||
|
type: z.string(),
|
||||||
|
}),
|
||||||
})
|
})
|
||||||
export const bedTypeFormSchema = z.object({
|
export const bedTypeFormSchema = z.object({
|
||||||
bedType: z.string(),
|
bedType: z.string(),
|
||||||
|
|||||||
@@ -9,7 +9,10 @@ import type { Lang } from "@scandic-hotels/common/constants/language"
|
|||||||
|
|
||||||
import { ChildBedMapEnum } from "@/types/components/bookingWidget/enums"
|
import { ChildBedMapEnum } from "@/types/components/bookingWidget/enums"
|
||||||
import type { BreakfastPackages } from "@/types/components/hotelReservation/breakfast"
|
import type { BreakfastPackages } from "@/types/components/hotelReservation/breakfast"
|
||||||
import type { DetailsBooking } from "@/types/components/hotelReservation/enterDetails/details"
|
import type {
|
||||||
|
DetailsBooking,
|
||||||
|
RoomRate,
|
||||||
|
} from "@/types/components/hotelReservation/enterDetails/details"
|
||||||
import { RoomPackageCodeEnum } from "@/types/components/hotelReservation/selectRate/roomFilter"
|
import { RoomPackageCodeEnum } from "@/types/components/hotelReservation/selectRate/roomFilter"
|
||||||
import {
|
import {
|
||||||
TrackingChannelEnum,
|
TrackingChannelEnum,
|
||||||
@@ -69,7 +72,7 @@ export function getTracking(
|
|||||||
analyticsRateCode: rooms.map((room) => room.rate).join("|"),
|
analyticsRateCode: rooms.map((room) => room.rate).join("|"),
|
||||||
arrivalDate: format(arrivalDate, "yyyy-MM-dd"),
|
arrivalDate: format(arrivalDate, "yyyy-MM-dd"),
|
||||||
bedType: storedRooms
|
bedType: storedRooms
|
||||||
.map((r) => (r.room.bedType ? r.room.bedType.description : ""))
|
.map((r) => (r.room.bedType ? r.room.bedType.type : ""))
|
||||||
.join("|"),
|
.join("|"),
|
||||||
// Comma separated booking code values in "code,code,n/a" format for multiroom and "code" or "n/a" for singleroom
|
// Comma separated booking code values in "code,code,n/a" format for multiroom and "code" or "n/a" for singleroom
|
||||||
// n/a is used whenever code is Not applicable as defined by Tracking team
|
// n/a is used whenever code is Not applicable as defined by Tracking team
|
||||||
@@ -158,9 +161,17 @@ export function getTracking(
|
|||||||
.join("|"),
|
.join("|"),
|
||||||
|
|
||||||
rateCodeCancellationRule: rooms
|
rateCodeCancellationRule: rooms
|
||||||
.map((room) => room.cancellationText.toLowerCase())
|
.map((room) => room.cancellationRule)
|
||||||
|
.join(","),
|
||||||
|
rateCodeName: rooms
|
||||||
|
.map((room) =>
|
||||||
|
constructRateCodeName(
|
||||||
|
room.roomRate,
|
||||||
|
room.breakfastIncluded,
|
||||||
|
booking.bookingCode
|
||||||
|
)
|
||||||
|
)
|
||||||
.join(","),
|
.join(","),
|
||||||
rateCodeName: rooms.map((room) => room.rateDefinitionTitle).join(","),
|
|
||||||
rateCodeType: rooms.map((room) => room.rateType.toLowerCase()).join(","),
|
rateCodeType: rooms.map((room) => room.rateType.toLowerCase()).join(","),
|
||||||
region: hotel?.address.city,
|
region: hotel?.address.city,
|
||||||
revenueCurrencyCode: [
|
revenueCurrencyCode: [
|
||||||
@@ -310,7 +321,7 @@ function calcTotalRoomPrice(rooms: RoomState[], isMember: boolean) {
|
|||||||
if ("redemption" in room.roomRate) {
|
if ("redemption" in room.roomRate) {
|
||||||
return room.roomRate.redemption.localPrice?.additionalPricePerStay ?? 0
|
return room.roomRate.redemption.localPrice?.additionalPricePerStay ?? 0
|
||||||
} else if (
|
} else if (
|
||||||
"corporateCheck" in room.roomRate ||
|
"corporateCheque" in room.roomRate ||
|
||||||
"voucher" in room.roomRate
|
"voucher" in room.roomRate
|
||||||
) {
|
) {
|
||||||
return 0
|
return 0
|
||||||
@@ -324,3 +335,27 @@ function calcTotalRoomPrice(rooms: RoomState[], isMember: boolean) {
|
|||||||
return total
|
return total
|
||||||
}, 0)
|
}, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function constructRateCodeName(
|
||||||
|
roomRate: RoomRate,
|
||||||
|
breakfastIncluded: boolean,
|
||||||
|
bookingCode?: string
|
||||||
|
) {
|
||||||
|
if ("corporateCheque" in roomRate) {
|
||||||
|
return "corporate cheque"
|
||||||
|
} else if ("voucher" in roomRate) {
|
||||||
|
return "voucher"
|
||||||
|
} else if ("redemption" in roomRate) {
|
||||||
|
return "redemption"
|
||||||
|
}
|
||||||
|
|
||||||
|
const bookingCodeStr = bookingCode ? bookingCode.toUpperCase() : ""
|
||||||
|
|
||||||
|
const breakfastIncludedStr = breakfastIncluded
|
||||||
|
? "incl. breakfast"
|
||||||
|
: "excl. breakfast"
|
||||||
|
|
||||||
|
return [bookingCodeStr, roomRate.rate, breakfastIncludedStr]
|
||||||
|
.filter(Boolean)
|
||||||
|
.join(" - ")
|
||||||
|
}
|
||||||
|
|||||||
@@ -139,6 +139,7 @@ export function mapRoomDetails({
|
|||||||
bedType: {
|
bedType: {
|
||||||
description: room?.bedType.mainBed.description ?? "",
|
description: room?.bedType.mainBed.description ?? "",
|
||||||
roomTypeCode: room?.bedType.code ?? "",
|
roomTypeCode: room?.bedType.code ?? "",
|
||||||
|
type: room?.bedType.mainBed.type ?? "",
|
||||||
},
|
},
|
||||||
breakfast,
|
breakfast,
|
||||||
breakfastChildren,
|
breakfastChildren,
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ export default function EnterDetailsProvider({
|
|||||||
isAvailable: room.isAvailable,
|
isAvailable: room.isAvailable,
|
||||||
breakfastIncluded: room.breakfastIncluded,
|
breakfastIncluded: room.breakfastIncluded,
|
||||||
cancellationText: room.cancellationText,
|
cancellationText: room.cancellationText,
|
||||||
|
cancellationRule: room.cancellationRule,
|
||||||
rateDetails: room.rateDetails,
|
rateDetails: room.rateDetails,
|
||||||
memberRateDetails: room.memberRateDetails,
|
memberRateDetails: room.memberRateDetails,
|
||||||
rateTitle: room.rateTitle,
|
rateTitle: room.rateTitle,
|
||||||
@@ -60,6 +61,7 @@ export default function EnterDetailsProvider({
|
|||||||
? {
|
? {
|
||||||
roomTypeCode: room.bedTypes[0].value,
|
roomTypeCode: room.bedTypes[0].value,
|
||||||
description: room.bedTypes[0].description,
|
description: room.bedTypes[0].description,
|
||||||
|
type: room.bedTypes[0].type,
|
||||||
}
|
}
|
||||||
: undefined,
|
: undefined,
|
||||||
mustBeGuaranteed: room.mustBeGuaranteed,
|
mustBeGuaranteed: room.mustBeGuaranteed,
|
||||||
@@ -118,6 +120,7 @@ export default function EnterDetailsProvider({
|
|||||||
currentRoom.room.bedType = {
|
currentRoom.room.bedType = {
|
||||||
description: sameBed.description,
|
description: sameBed.description,
|
||||||
roomTypeCode: sameBed.value,
|
roomTypeCode: sameBed.value,
|
||||||
|
type: sameBed.type,
|
||||||
}
|
}
|
||||||
currentRoom.steps[StepEnum.selectBed].isValid = true
|
currentRoom.steps[StepEnum.selectBed].isValid = true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -231,6 +231,7 @@ export const hotelQueryRouter = router({
|
|||||||
bedTypes,
|
bedTypes,
|
||||||
breakfastIncluded: rateDefinition.breakfastIncluded,
|
breakfastIncluded: rateDefinition.breakfastIncluded,
|
||||||
cancellationText: rateDefinition.cancellationText,
|
cancellationText: rateDefinition.cancellationText,
|
||||||
|
cancellationRule: rateDefinition.cancellationRule,
|
||||||
isAvailable: selectedRoom.status === AvailabilityEnum.Available,
|
isAvailable: selectedRoom.status === AvailabilityEnum.Available,
|
||||||
isFlexRate: product.rate === RateEnum.flex,
|
isFlexRate: product.rate === RateEnum.flex,
|
||||||
memberMustBeGuaranteed: memberRateDefinition?.mustBeGuaranteed,
|
memberMustBeGuaranteed: memberRateDefinition?.mustBeGuaranteed,
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import type { Package } from "@/types/requests/packages"
|
|||||||
export interface Room {
|
export interface Room {
|
||||||
bedTypes: BedTypeSelection[]
|
bedTypes: BedTypeSelection[]
|
||||||
breakfastIncluded: boolean
|
breakfastIncluded: boolean
|
||||||
cancellationRule?: string
|
cancellationRule: string
|
||||||
cancellationText: string
|
cancellationText: string
|
||||||
mustBeGuaranteed: boolean
|
mustBeGuaranteed: boolean
|
||||||
memberMustBeGuaranteed: boolean | undefined
|
memberMustBeGuaranteed: boolean | undefined
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ export interface ChildBedPreference {
|
|||||||
export interface Room {
|
export interface Room {
|
||||||
adults: number
|
adults: number
|
||||||
bedDescription: string
|
bedDescription: string
|
||||||
|
bedType: string
|
||||||
bookingCode: string | null
|
bookingCode: string | null
|
||||||
breakfast: PackageSchema | false | undefined
|
breakfast: PackageSchema | false | undefined
|
||||||
breakfastIncluded: boolean
|
breakfastIncluded: boolean
|
||||||
|
|||||||
Reference in New Issue
Block a user