diff --git a/apps/scandic-web/app/[lang]/(live)/(public)/hotelreservation/(standard)/details/tracking.ts b/apps/scandic-web/app/[lang]/(live)/(public)/hotelreservation/(standard)/details/tracking.ts index dbc557495..e57b3632d 100644 --- a/apps/scandic-web/app/[lang]/(live)/(public)/hotelreservation/(standard)/details/tracking.ts +++ b/apps/scandic-web/app/[lang]/(live)/(public)/hotelreservation/(standard)/details/tracking.ts @@ -45,6 +45,17 @@ export function getTracking( .join("|"), analyticsRateCode: rooms.map((room) => room.rate).join("|"), arrivalDate: format(arrivalDate, "yyyy-MM-dd"), + // 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 + bookingCode: rooms + .map((room) => room.roomRate.bookingCode ?? "n/a") + .join(", "), + // Similar to booking code, comma separated room based values. + bookingCodeAvailability: booking.bookingCode + ? rooms + .map((room) => (room.roomRate.bookingCode ? "true" : "false")) + .join(", ") + : undefined, bookingTypeofDay: isWeekend(arrivalDate) ? "weekend" : "weekday", breakfastOption: rooms .map(() => (offersBreakfast ? "breakfast buffet" : "no breakfast")) diff --git a/apps/scandic-web/components/HotelReservation/BookingConfirmation/Tracking/tracking.ts b/apps/scandic-web/components/HotelReservation/BookingConfirmation/Tracking/tracking.ts index 0c5a9cdba..20881b4ba 100644 --- a/apps/scandic-web/components/HotelReservation/BookingConfirmation/Tracking/tracking.ts +++ b/apps/scandic-web/components/HotelReservation/BookingConfirmation/Tracking/tracking.ts @@ -103,6 +103,10 @@ export function getTracking( .join(",") .toLowerCase(), bnr: rooms.map((r) => r.confirmationNumber).join(","), + bookingCode: rooms.map((room) => room.bookingCode ?? "n/a").join(", "), + bookingCodeAvailability: booking.bookingCode + ? rooms.map((room) => (room.bookingCode ? "true" : "false")).join(", ") + : undefined, bookingTypeofDay: isWeekend(arrivalDate) ? "weekend" : "weekday", breakfastOption: rooms .map((r) => { diff --git a/apps/scandic-web/components/HotelReservation/BookingConfirmation/utils.ts b/apps/scandic-web/components/HotelReservation/BookingConfirmation/utils.ts index 68b5b6cc1..2e8428983 100644 --- a/apps/scandic-web/components/HotelReservation/BookingConfirmation/utils.ts +++ b/apps/scandic-web/components/HotelReservation/BookingConfirmation/utils.ts @@ -51,6 +51,7 @@ export function mapRoomState( return { adults: booking.adults, bedDescription: room.bedType.description, + bookingCode: booking.bookingCode, breakfast, breakfastIncluded, cheques: booking.cheques, diff --git a/apps/scandic-web/components/HotelReservation/SelectHotel/SelectHotelMap/SelectHotelMapContainer.tsx b/apps/scandic-web/components/HotelReservation/SelectHotel/SelectHotelMap/SelectHotelMapContainer.tsx index a4aa483aa..65ad59bc5 100644 --- a/apps/scandic-web/components/HotelReservation/SelectHotel/SelectHotelMap/SelectHotelMapContainer.tsx +++ b/apps/scandic-web/components/HotelReservation/SelectHotel/SelectHotelMap/SelectHotelMapContainer.tsx @@ -15,6 +15,7 @@ import SelectHotelMap from "." import type { SelectHotelMapContainerProps } from "@/types/components/hotelReservation/selectHotel/map" import type { SelectHotelSearchParams } from "@/types/components/hotelReservation/selectHotel/selectHotelSearchParams" +import { RateTypeEnum } from "@/types/enums/rateType" export async function SelectHotelMapContainer({ searchParams, @@ -73,6 +74,14 @@ export async function SelectHotelMapContainer({ const arrivalDate = new Date(selectHotelParams.fromDate) const departureDate = new Date(selectHotelParams.toDate) + const isBookingCodeRateAvailable = bookingCode + ? hotels?.some( + (hotel) => + hotel.availability.productType?.public?.rateType !== + RateTypeEnum.Regular + ) + : false + const { hotelsTrackingData, pageTrackingData } = getTracking( lang, !!isAlternativeFor, @@ -86,7 +95,9 @@ export async function SelectHotelMapContainer({ noOfRooms, hotels?.[0]?.hotel.address.country, hotels?.[0]?.hotel.address.city, - selectHotelParams.city + selectHotelParams.city, + bookingCode, + isBookingCodeRateAvailable ) return ( @@ -99,6 +110,7 @@ export async function SelectHotelMapContainer({ filterList={filterList} cityCoordinates={cityCoordinates} bookingCode={bookingCode ?? ""} + isBookingCodeRateAvailable={isBookingCodeRateAvailable} /> diff --git a/apps/scandic-web/components/HotelReservation/SelectHotel/SelectHotelMap/SelectHotelMapContent/index.tsx b/apps/scandic-web/components/HotelReservation/SelectHotel/SelectHotelMap/SelectHotelMapContent/index.tsx index e26ed78ea..a2c50d363 100644 --- a/apps/scandic-web/components/HotelReservation/SelectHotel/SelectHotelMap/SelectHotelMapContent/index.tsx +++ b/apps/scandic-web/components/HotelReservation/SelectHotel/SelectHotelMap/SelectHotelMapContent/index.tsx @@ -41,6 +41,7 @@ export default function SelectHotelContent({ hotels, filterList, bookingCode, + isBookingCodeRateAvailable, }: Omit) { const lang = useLang() const intl = useIntl() @@ -140,6 +141,16 @@ export default function SelectHotelContent({ ) + const isRegularRateAvailable = bookingCode + ? hotels.some( + (hotel) => + hotel.availability.productType?.public?.rateType === + RateTypeEnum.Regular || + hotel.availability.productType?.member?.rateType === + RateTypeEnum.Regular + ) + : false + return (
@@ -160,7 +171,11 @@ export default function SelectHotelContent({ filters={filterList} setShowSkeleton={setShowSkeleton} /> - {bookingCode ? : null} + {bookingCode && + isBookingCodeRateAvailable && + isRegularRateAvailable ? ( + + ) : null}
{showSkeleton ? ( diff --git a/apps/scandic-web/components/HotelReservation/SelectHotel/SelectHotelMap/index.tsx b/apps/scandic-web/components/HotelReservation/SelectHotel/SelectHotelMap/index.tsx index 9c315f6e2..3ed9f2e8d 100644 --- a/apps/scandic-web/components/HotelReservation/SelectHotel/SelectHotelMap/index.tsx +++ b/apps/scandic-web/components/HotelReservation/SelectHotel/SelectHotelMap/index.tsx @@ -14,6 +14,7 @@ export default function SelectHotelMap({ filterList, cityCoordinates, bookingCode, + isBookingCodeRateAvailable, }: SelectHotelMapProps) { return ( @@ -24,6 +25,7 @@ export default function SelectHotelMap({ hotels={hotels} filterList={filterList} bookingCode={bookingCode} + isBookingCodeRateAvailable={isBookingCodeRateAvailable} /> ) diff --git a/apps/scandic-web/components/HotelReservation/SelectHotel/SelectHotelMap/tracking.ts b/apps/scandic-web/components/HotelReservation/SelectHotel/SelectHotelMap/tracking.ts index e955bd77f..83f61cb46 100644 --- a/apps/scandic-web/components/HotelReservation/SelectHotel/SelectHotelMap/tracking.ts +++ b/apps/scandic-web/components/HotelReservation/SelectHotel/SelectHotelMap/tracking.ts @@ -22,7 +22,9 @@ export function getTracking( noOfRooms: number, country: string | undefined, hotelCity: string | undefined, - paramCity: string | undefined + paramCity: string | undefined, + bookingCode?: string, + isBookingCodeRateAvailable?: boolean ) { const pageTrackingData: TrackingSDKPageData = { channel: TrackingChannelEnum["hotelreservation"], @@ -44,6 +46,8 @@ export function getTracking( .join("|"), arrivalDate: format(arrivalDate, "yyyy-MM-dd"), availableResults: hotelsResult, + bookingCode: bookingCode ? bookingCode : "n/a", + bookingCodeAvailability: isBookingCodeRateAvailable ? "true" : "false", bookingTypeofDay: isWeekend(arrivalDate) ? "weekend" : "weekday", childBedPreference: childrenInRoom ?.map((c) => c?.map((k) => ChildBedMapEnum[k.bed]).join(",") ?? "-") diff --git a/apps/scandic-web/components/HotelReservation/SelectHotel/index.tsx b/apps/scandic-web/components/HotelReservation/SelectHotel/index.tsx index 578ba9d7e..42d172ddd 100644 --- a/apps/scandic-web/components/HotelReservation/SelectHotel/index.tsx +++ b/apps/scandic-web/components/HotelReservation/SelectHotel/index.tsx @@ -119,6 +119,28 @@ export default async function SelectHotel({ const isAllUnavailable = !hotels.length + const suspenseKey = stringify(searchParams) + + const isFullPriceHotelAvailable = bookingCode + ? hotels?.some( + (hotel) => + hotel.availability.productType?.public?.rateType === + RateTypeEnum.Regular || + hotel.availability.productType?.member?.rateType === + RateTypeEnum.Regular + ) + : false + + const isBookingCodeRateAvailable = bookingCode + ? hotels?.some( + (hotel) => + hotel.availability.productType?.public?.rateType !== + RateTypeEnum.Regular || + hotel.availability.productType?.member?.rateType !== + RateTypeEnum.Regular + ) + : false + const { hotelsTrackingData, pageTrackingData } = getTracking( params.lang, !!isAlternativeFor, @@ -126,35 +148,16 @@ export default async function SelectHotel({ departureDate, adultsInRoom, childrenInRoom, - hotels.length, + hotels?.length ?? 0, selectHotelParams.hotelId, noOfRooms, hotels?.[0]?.hotel.address.country, hotels?.[0]?.hotel.address.city, - selectHotelParams.city + selectHotelParams.city, + bookingCode, + isBookingCodeRateAvailable ? "true" : "false" ) - const suspenseKey = stringify(searchParams) - - let isFullPriceHotelAvailable - let isBookingCodeRateAvaliable - if (bookingCode) { - isFullPriceHotelAvailable = hotels?.find( - (hotel) => - hotel.availability.productType?.public?.rateType === - RateTypeEnum.Regular || - hotel.availability.productType?.member?.rateType === - RateTypeEnum.Regular - ) - isBookingCodeRateAvaliable = hotels?.find( - (hotel) => - hotel.availability.productType?.public?.rateType !== - RateTypeEnum.Regular || - hotel.availability.productType?.member?.rateType !== - RateTypeEnum.Regular - ) - } - // Special rates (corporate cheque, voucher and reward nights) will not have regular rate hotels availability const isSpecialRate = hotels?.some( (hotel) => @@ -189,7 +192,7 @@ export default async function SelectHotel({
- {isBookingCodeRateAvaliable && + {isBookingCodeRateAvailable && isFullPriceHotelAvailable && !isSpecialRate ? ( diff --git a/apps/scandic-web/components/HotelReservation/SelectHotel/tracking.ts b/apps/scandic-web/components/HotelReservation/SelectHotel/tracking.ts index 9f0a9a8a4..9a60af56d 100644 --- a/apps/scandic-web/components/HotelReservation/SelectHotel/tracking.ts +++ b/apps/scandic-web/components/HotelReservation/SelectHotel/tracking.ts @@ -21,7 +21,9 @@ export function getTracking( noOfRooms: number, country: string | undefined, hotelCity: string | undefined, - paramCity: string | undefined + paramCity: string | undefined, + bookingCode?: string, + isBookingCodeRateAvailable?: string ) { const pageTrackingData: TrackingSDKPageData = { channel: TrackingChannelEnum["hotelreservation"], @@ -57,6 +59,10 @@ export function getTracking( region: hotelCity, searchTerm: isAlternativeFor ? hotelId : (paramCity as string), searchType: "destination", + bookingCode: bookingCode ?? "n/a", + bookingCodeAvailability: bookingCode + ? isBookingCodeRateAvailable + : undefined, } return { diff --git a/apps/scandic-web/components/HotelReservation/SelectRate/index.tsx b/apps/scandic-web/components/HotelReservation/SelectRate/index.tsx index 3c4a330f7..7d9dc4e1d 100644 --- a/apps/scandic-web/components/HotelReservation/SelectRate/index.tsx +++ b/apps/scandic-web/components/HotelReservation/SelectRate/index.tsx @@ -28,8 +28,14 @@ export default async function SelectRatePage({ if (!searchDetails?.hotel) { return notFound() } - const { adultsInRoom, childrenInRoom, hotel, noOfRooms, selectHotelParams } = - searchDetails + const { + adultsInRoom, + childrenInRoom, + hotel, + noOfRooms, + selectHotelParams, + bookingCode, + } = searchDetails const hotelData = await getHotel({ hotelId: hotel.id, @@ -63,7 +69,8 @@ export default async function SelectRatePage({ noOfRooms, hotelData.hotel.address.country, hotelData.hotel.address.city, - selectHotelParams.city + selectHotelParams.city, + bookingCode ) const booking = convertSearchParamsToObj(searchParams) diff --git a/apps/scandic-web/components/HotelReservation/SelectRate/tracking.ts b/apps/scandic-web/components/HotelReservation/SelectRate/tracking.ts index 7999fb8eb..e2519719d 100644 --- a/apps/scandic-web/components/HotelReservation/SelectRate/tracking.ts +++ b/apps/scandic-web/components/HotelReservation/SelectRate/tracking.ts @@ -20,7 +20,8 @@ export function getTracking( noOfRooms: number, country: string | undefined, hotelCity: string | undefined, - paramCity: string | undefined + paramCity: string | undefined, + bookingCode?: string ) { const pageTrackingData: TrackingSDKPageData = { channel: TrackingChannelEnum.hotelreservation, @@ -52,6 +53,7 @@ export function getTracking( region: hotelCity, searchTerm: paramCity ?? hotelName, searchType: "hotel", + bookingCode: bookingCode ?? "n/a", } return { diff --git a/apps/scandic-web/types/components/hotelReservation/selectHotel/map.ts b/apps/scandic-web/types/components/hotelReservation/selectHotel/map.ts index 56d4665b4..5cbbc3fe1 100644 --- a/apps/scandic-web/types/components/hotelReservation/selectHotel/map.ts +++ b/apps/scandic-web/types/components/hotelReservation/selectHotel/map.ts @@ -22,6 +22,7 @@ export interface SelectHotelMapProps { filterList: CategorizedFilters cityCoordinates: Coordinates bookingCode: string | undefined + isBookingCodeRateAvailable?: boolean } type ImageSizes = z.infer["imageSizes"] diff --git a/apps/scandic-web/types/components/tracking.ts b/apps/scandic-web/types/components/tracking.ts index 418df9b69..c69711bae 100644 --- a/apps/scandic-web/types/components/tracking.ts +++ b/apps/scandic-web/types/components/tracking.ts @@ -63,8 +63,8 @@ export type TrackingSDKHotelInfo = { bnr?: string // Booking number breakfastOption?: string // "no breakfast" or "breakfast buffet" //bonuscheque?: boolean - //bookingCode?: string - //bookingCodeAvailability?: boolean + bookingCode?: string + bookingCodeAvailability?: string bookingTypeofDay?: "weekend" | "weekday" childBedPreference?: string country?: string // Country of the hotel diff --git a/apps/scandic-web/types/stores/booking-confirmation.ts b/apps/scandic-web/types/stores/booking-confirmation.ts index ebe1d46d1..91bd8f898 100644 --- a/apps/scandic-web/types/stores/booking-confirmation.ts +++ b/apps/scandic-web/types/stores/booking-confirmation.ts @@ -12,6 +12,7 @@ export interface ChildBedPreference { export interface Room { adults: number bedDescription: string + bookingCode: string | null breakfast?: PackageSchema breakfastIncluded: boolean cheques: number