"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 { Button } from "@scandic-hotels/design-system/Button" import { Divider } from "@scandic-hotels/design-system/Divider" import { IconButton } from "@scandic-hotels/design-system/IconButton" import { Typography } from "@scandic-hotels/design-system/Typography" import { getRoomFeatureDescription } from "../../../../utils/getRoomFeatureDescription" import styles from "./priceChangeSummary.module.css" import type { RoomState } from "../../../../stores/enter-details/types" 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({ id: "common.priceDetails", defaultMessage: "Price details", })}

{rooms.map(({ room }, idx) => { const roomNumber = idx + 1 const newPrice = roomPrices[idx].newPrice return (

{rooms.length > 1 ? intl.formatMessage( { id: "booking.roomIndex", defaultMessage: "Room {roomIndex}", }, { roomIndex: roomNumber } ) : intl.formatMessage({ id: "common.room", defaultMessage: "Room", })}

{room.roomType}

{intl.formatMessage({ id: "priceDetails.roomCharge", 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({ id: "enterDetails.priceChangeDialog.breakfastCharge", defaultMessage: "Breakfast charge", })}

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

)} {room.roomFeatures?.map((feature) => (

{getRoomFeatureDescription( feature.code, feature.description, intl )}

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

))}
) })}

{intl.formatMessage({ id: "common.total", defaultMessage: "Total", })}

{intl.formatMessage({ id: "booking.priceIncludingVat", defaultMessage: "Price including VAT", })}

{formatPrice( intl, newTotalPrice.price, newTotalPrice.currency )}

)}
) }