"use client" import { Fragment, useState } from "react" import { Dialog, DialogTrigger, Modal, ModalOverlay, } from "react-aria-components" import { useIntl } from "react-intl" import { formatPrice } from "@scandic-hotels/common/utils/numberFormatting" import Body from "@scandic-hotels/design-system/Body" import Caption from "@scandic-hotels/design-system/Caption" import { Divider } from "@scandic-hotels/design-system/Divider" import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon" import { OldDSButton as Button } from "@scandic-hotels/design-system/OldDSButton" import Subtitle from "@scandic-hotels/design-system/Subtitle" import { getFeatureDescription } from "@/components/HotelReservation/utils/getRoomFeatureDescription" import styles from "./priceChangeSummary.module.css" import type { RoomState } from "@/types/stores/enter-details" interface PriceChangeSummaryProps { rooms: RoomState[] roomPrices: { prevPrice: number; newPrice?: number }[] newTotalPrice: { price: number; currency: string } onAccept: () => void onCancel: () => void } export default function PriceChangeSummary({ rooms, roomPrices, newTotalPrice, onAccept, onCancel, }: PriceChangeSummaryProps) { const intl = useIntl() const [isOpen, toggleOpen] = useState(false) return ( {({ close }) => (
{intl.formatMessage({ defaultMessage: "Price details", })}
{rooms.map(({ room }, idx) => { const roomNumber = idx + 1 const newPrice = roomPrices[idx].newPrice return (
{rooms.length > 1 ? intl.formatMessage( { defaultMessage: "Room {roomIndex}", }, { roomIndex: roomNumber } ) : intl.formatMessage({ defaultMessage: "Room", })} {room.roomType}
{intl.formatMessage({ defaultMessage: "Room charge", })} {newPrice ? (
{formatPrice( intl, room.roomPrice.perStay.local.price, room.roomPrice.perStay.local.currency )} {formatPrice( intl, newPrice, room.roomPrice.perStay.local.currency )}
) : ( {formatPrice( intl, room.roomPrice.perStay.local.price, room.roomPrice.perStay.local.currency )} )}
{room.breakfast && (
{intl.formatMessage({ defaultMessage: "Breakfast charge", })} {formatPrice( intl, Number( room.breakfast.localPrice.totalPrice ), room.breakfast.localPrice.currency )}
)} {room.roomFeatures?.map((feature) => (
{getFeatureDescription( feature.code, feature.description, intl )} {formatPrice( intl, Number(feature.localPrice.totalPrice), feature.localPrice.currency )}
))}
) })}
{intl.formatMessage({ defaultMessage: "Total", })}
{intl.formatMessage({ defaultMessage: "Price including VAT", })} {formatPrice( intl, newTotalPrice.price, newTotalPrice.currency )}
)}
) }