Merged in chore/SW-2878-extract-booking-confirmation-pag (pull request #2779)
Chore/SW-2878 extract booking confirmation pag * chore(SW-2878): Moved booking confirmation page to booking-flow package * chore(SW-2878): Fixed promo styles as per design * chore(SW-2878): Kept tiny duplicate function to avoid export from booking-flow package Approved-by: Anton Gunnarsson
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
import { type IntlShape } from "react-intl"
|
||||
|
||||
import { CurrencyEnum } from "@scandic-hotels/common/constants/currency"
|
||||
import { formatPrice } from "@scandic-hotels/common/utils/numberFormatting"
|
||||
import { BreakfastPackageEnum } from "@scandic-hotels/trpc/enums/breakfast"
|
||||
|
||||
import type {
|
||||
BookingConfirmationSchema,
|
||||
PackageSchema,
|
||||
} from "@scandic-hotels/trpc/types/bookingConfirmation"
|
||||
|
||||
import type { BookingConfirmationRoom } from "../../types/components/bookingConfirmation/bookingConfirmation"
|
||||
|
||||
export function mapRoomState(
|
||||
booking: BookingConfirmationSchema,
|
||||
room: BookingConfirmationRoom,
|
||||
intl: IntlShape
|
||||
) {
|
||||
const breakfastPackage = booking.packages.find(
|
||||
(pkg) => pkg.code === BreakfastPackageEnum.REGULAR_BREAKFAST
|
||||
)
|
||||
const breakfastIncluded =
|
||||
booking.packages.some(
|
||||
(pkg) => pkg.code === BreakfastPackageEnum.FREE_MEMBER_BREAKFAST
|
||||
) || booking.rateDefinition.breakfastIncluded
|
||||
|
||||
let breakfast: false | undefined | PackageSchema
|
||||
if (breakfastPackage) {
|
||||
breakfast = breakfastPackage
|
||||
} else if (!breakfastIncluded) {
|
||||
breakfast = false
|
||||
}
|
||||
|
||||
let formattedRoomCost = formatPrice(
|
||||
intl,
|
||||
booking.roomPrice,
|
||||
booking.currencyCode
|
||||
)
|
||||
if (booking.roomPoints) {
|
||||
formattedRoomCost = formatPrice(
|
||||
intl,
|
||||
booking.roomPoints,
|
||||
CurrencyEnum.POINTS,
|
||||
booking.roomPrice,
|
||||
booking.currencyCode
|
||||
)
|
||||
} else if (booking.cheques) {
|
||||
formattedRoomCost = formatPrice(
|
||||
intl,
|
||||
booking.cheques,
|
||||
CurrencyEnum.CC,
|
||||
booking.roomPrice,
|
||||
booking.currencyCode
|
||||
)
|
||||
} else if (booking.vouchers) {
|
||||
formattedRoomCost = formatPrice(
|
||||
intl,
|
||||
booking.vouchers,
|
||||
CurrencyEnum.Voucher
|
||||
)
|
||||
}
|
||||
|
||||
return {
|
||||
adults: booking.adults,
|
||||
bedDescription: room.bedType.description,
|
||||
bedType: room.bedType.mainBed.type,
|
||||
bookingCode: booking.bookingCode,
|
||||
breakfast,
|
||||
breakfastIncluded,
|
||||
cheques: booking.cheques,
|
||||
childrenAges: booking.childrenAges,
|
||||
childBedPreferences: booking.childBedPreferences,
|
||||
confirmationNumber: booking.confirmationNumber,
|
||||
currencyCode: booking.currencyCode,
|
||||
formattedRoomCost,
|
||||
fromDate: booking.checkInDate,
|
||||
name: room.name,
|
||||
packages: booking.packages,
|
||||
rateDefinition: booking.rateDefinition,
|
||||
rateCodeType: booking.bookingType,
|
||||
refId: booking.refId,
|
||||
roomFeatures: booking.packages.filter((p) => p.type === "RoomFeature"),
|
||||
roomPoints: booking.roomPoints,
|
||||
roomPrice: booking.roomPrice,
|
||||
roomTypeCode: booking.roomTypeCode,
|
||||
toDate: booking.checkOutDate,
|
||||
totalPrice: booking.totalPrice,
|
||||
totalPriceExVat: booking.totalPriceExVat,
|
||||
vatAmount: booking.vatAmount,
|
||||
vouchers: booking.vouchers,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user