"use client" import { useIntl } from "react-intl" import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon" import { Typography } from "@scandic-hotels/design-system/Typography" import { CancellationRuleEnum, ChildBedTypeEnum } from "@/constants/booking" import { useBookingConfirmationStore } from "@/stores/booking-confirmation" import Modal from "@/components/Modal" import Button from "@/components/TempDesignSystem/Button" import Link from "@/components/TempDesignSystem/Link" import { formatPrice } from "@/utils/numberFormatting" import RoomSkeletonLoader from "./RoomSkeletonLoader" import styles from "./room.module.css" import type { BookingConfirmationReceiptRoomProps } from "@/types/components/hotelReservation/bookingConfirmation/receipt" export default function ReceiptRoom({ roomIndex, }: BookingConfirmationReceiptRoomProps) { const intl = useIntl() const { room, currencyCode, isVatCurrency } = useBookingConfirmationStore( (state) => ({ room: state.rooms[roomIndex], currencyCode: state.currencyCode, isVatCurrency: state.isVatCurrency, }) ) if (!room) { return } const breakfastIncluded = room.breakfastIncluded || room.rateDefinition.breakfastIncluded const childBedCrib = room.childBedPreferences.find( (c) => c.bedType === ChildBedTypeEnum.Crib ) const childBedExtraBed = room.childBedPreferences.find( (c) => c.bedType === ChildBedTypeEnum.ExtraBed ) const adultsMsg = intl.formatMessage( { defaultMessage: "{totalAdults, plural, one {# adult} other {# adults}}", }, { totalAdults: room.adults } ) const guestsParts = [adultsMsg] if (room.childrenAges?.length) { const childrenMsg = intl.formatMessage( { defaultMessage: "{totalChildren, plural, one {# child} other {# children}}", }, { totalChildren: room.childrenAges.length } ) guestsParts.push(childrenMsg) } return (

{room.name}

{room.rateDefinition.isMemberRate ? (

{room.formattedRoomCost}

) : (

{room.formattedRoomCost}

)}

{guestsParts.join(", ")}

{room.rateDefinition.cancellationText}

{intl.formatMessage({ defaultMessage: "Reservation policy", })} } title={ (isVatCurrency ? room.rateDefinition.cancellationText : room.rateDefinition.title) || "" } subtitle={ room.rateDefinition.cancellationRule === CancellationRuleEnum.CancellableBefore6PM ? intl.formatMessage({ defaultMessage: "Pay later", }) : intl.formatMessage({ defaultMessage: "Pay now", }) } >
{room.rateDefinition.generalTerms?.map((info) => ( {info} ))}
{room.roomFeatures ? room.roomFeatures.map((feature) => (

{feature.description}

{formatPrice(intl, feature.totalPrice, feature.currency)}

)) : null}

{room.bedDescription}

{formatPrice(intl, 0, currencyCode)}

{childBedCrib ? (

{intl.formatMessage( { defaultMessage: "Crib (child) × {count}", }, { count: childBedCrib.quantity } )}

{intl.formatMessage({ defaultMessage: "Based on availability", })}

{formatPrice(intl, 0, currencyCode)}

) : null} {childBedExtraBed ? (

{intl.formatMessage( { defaultMessage: "Extra bed (child) × {count}", }, { count: childBedExtraBed.quantity, } )}

{formatPrice(intl, 0, currencyCode)}

) : null} {room.breakfast || breakfastIncluded ? (

{intl.formatMessage({ defaultMessage: "Breakfast buffet", })}

{breakfastIncluded ? (

{intl.formatMessage({ defaultMessage: "Included", })}

) : null} {room.breakfast && !breakfastIncluded ? (

{formatPrice( intl, room.breakfast.totalPrice, room.breakfast.currency )}

) : null}
) : null}
) }