feat: SW-2079 Show points in confirmation page * feat: SW-2079 Show points in confirmation page * feat: SW-2079 Optimized code * feat: SW-2079 Updated Body to Typography * feat: SW-2079 Multi-room total cost display * feat: SW-2079 Add reward nights condition rate title * feat: SW-2079 Removed extra checks * feat: SW-2079 Optimmized formatPrice function * feat: SW-2079 Typo fix Approved-by: Christian Andolf
62 lines
1.9 KiB
TypeScript
62 lines
1.9 KiB
TypeScript
import { formatPrice } from "@/utils/numberFormatting"
|
|
|
|
import type { IntlShape } from "react-intl"
|
|
|
|
import type { BookingConfirmationRoom } from "@/types/components/hotelReservation/bookingConfirmation/bookingConfirmation"
|
|
import { BreakfastPackageEnum } from "@/types/enums/breakfast"
|
|
import { CurrencyEnum } from "@/types/enums/currency"
|
|
import type { BookingConfirmationSchema } from "@/types/trpc/routers/booking/confirmation"
|
|
|
|
export function mapRoomState(
|
|
booking: BookingConfirmationSchema,
|
|
room: BookingConfirmationRoom,
|
|
intl: IntlShape
|
|
) {
|
|
const breakfast = booking.packages.find(
|
|
(pkg) => pkg.code === BreakfastPackageEnum.REGULAR_BREAKFAST
|
|
)
|
|
const breakfastIncluded = booking.packages.some(
|
|
(pkg) => pkg.code === BreakfastPackageEnum.FREE_MEMBER_BREAKFAST
|
|
)
|
|
|
|
let formattedTotalCost = formatPrice(
|
|
intl,
|
|
booking.totalPrice,
|
|
booking.currencyCode
|
|
)
|
|
if (booking.roomPoints) {
|
|
formattedTotalCost = formatPrice(
|
|
intl,
|
|
booking.roomPoints,
|
|
CurrencyEnum.POINTS,
|
|
booking.totalPrice,
|
|
booking.currencyCode
|
|
)
|
|
}
|
|
|
|
return {
|
|
adults: booking.adults,
|
|
bedDescription: room.bedType.description,
|
|
breakfast,
|
|
breakfastIncluded,
|
|
children: booking.childrenAges.length,
|
|
childrenAges: booking.childrenAges,
|
|
childBedPreferences: booking.childBedPreferences,
|
|
confirmationNumber: booking.confirmationNumber,
|
|
currencyCode: booking.currencyCode,
|
|
formattedTotalCost,
|
|
fromDate: booking.checkInDate,
|
|
name: room.name,
|
|
packages: booking.packages,
|
|
rateDefinition: booking.rateDefinition,
|
|
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,
|
|
}
|
|
}
|