"use client" import { useIntl } from "react-intl" import { dt } from "@/lib/dt" import { useEnterDetailsStore } from "@/stores/enter-details" import SignupPromoDesktop from "@/components/HotelReservation/SignupPromo/Desktop" import { ArrowRightIcon, ChevronDownSmallIcon } from "@/components/Icons" import Button from "@/components/TempDesignSystem/Button" import Divider from "@/components/TempDesignSystem/Divider" import Link from "@/components/TempDesignSystem/Link" import Popover from "@/components/TempDesignSystem/Popover" import Body from "@/components/TempDesignSystem/Text/Body" import Caption from "@/components/TempDesignSystem/Text/Caption" import Subtitle from "@/components/TempDesignSystem/Text/Subtitle" import useLang from "@/hooks/useLang" import styles from "./ui.module.css" import type { SummaryProps } from "@/types/components/hotelReservation/summary" import type { DetailsState } from "@/types/stores/enter-details" export function storeSelector(state: DetailsState) { return { bedType: state.bedType, booking: state.booking, breakfast: state.breakfast, join: state.guest.join, membershipNo: state.guest.membershipNo, packages: state.packages, roomRate: state.roomRate, roomPrice: state.roomPrice, toggleSummaryOpen: state.actions.toggleSummaryOpen, totalPrice: state.totalPrice, } } export default function SummaryUI({ cancellationText, isMember, rateDetails, roomType, }: SummaryProps) { const intl = useIntl() const lang = useLang() const { bedType, booking, breakfast, join, membershipNo, packages, roomPrice, roomRate, toggleSummaryOpen, totalPrice, } = useEnterDetailsStore(storeSelector) const adults = booking.rooms[0].adults const children = booking.rooms[0].children const memberPrice = roomRate.memberRate ? { currency: roomRate.memberRate.localPrice.currency, amount: roomRate.memberRate.localPrice.pricePerStay, } : null const showMemberPrice = !!(isMember || join || membershipNo) const diff = dt(booking.toDate).diff(booking.fromDate, "days") const nights = intl.formatMessage( { id: "booking.nights" }, { totalNights: diff } ) function handleToggleSummary() { if (toggleSummaryOpen) { toggleSummaryOpen() } } return (
{intl.formatMessage({ id: "Summary" })} {dt(booking.fromDate).locale(lang).format("ddd, D MMM")} {dt(booking.toDate).locale(lang).format("ddd, D MMM")} ({nights})
{roomType} {intl.formatNumber(roomPrice.local.price, { currency: roomPrice.local.currency, style: "currency", })}
{intl.formatMessage( { id: "booking.adults" }, { totalAdults: adults } )} {children?.length ? ( {intl.formatMessage( { id: "booking.children" }, { totalChildren: children.length } )} ) : null} {cancellationText} {intl.formatMessage({ id: "Rate details" })} } >
{packages ? packages.map((roomPackage) => (
{roomPackage.description}
{intl.formatNumber(parseInt(roomPackage.localPrice.price), { currency: roomPackage.localPrice.currency, style: "currency", })}
)) : null} {bedType ? (
{bedType.description} {intl.formatMessage({ id: "Based on availability" })}
{intl.formatNumber(0, { currency: roomPrice.local.currency, style: "currency", })}
) : null} {breakfast === false ? (
{intl.formatMessage({ id: "No breakfast" })} {intl.formatNumber(0, { currency: roomPrice.local.currency, style: "currency", })}
) : null} {breakfast ? (
{intl.formatMessage({ id: "Breakfast buffet" })} {intl.formatNumber(parseInt(breakfast.localPrice.totalPrice), { currency: breakfast.localPrice.currency, style: "currency", })}
) : null}
{intl.formatMessage( { id: "Total price (incl VAT)" }, { b: (str) => {str} } )} {intl.formatMessage({ id: "Price details" })}
{intl.formatNumber(totalPrice.local.price, { currency: totalPrice.local.currency, style: "currency", })} {totalPrice.requested && ( {intl.formatMessage({ id: "Approx." })}{" "} {intl.formatNumber(totalPrice.requested.price, { currency: totalPrice.requested.currency, style: "currency", })} )}
{!showMemberPrice && memberPrice ? ( ) : null}
) }