Feat/SW-711 update children params * feat(SW-711): add new child params for availability * feat(SW-711): fix children schema * feat(SW-711): fix optional values * feat(SW-711): add children as parameter iff not undefined * feat(SW-711): add bedType enum * feat(SW-711): remove optional number type * feat(SW-711): fix wrong slash * feat(SW-711): remove optional Approved-by: Hrishikesh Vaipurkar
113 lines
3.9 KiB
TypeScript
113 lines
3.9 KiB
TypeScript
import { differenceInCalendarDays } from "date-fns"
|
|
import { useIntl } from "react-intl"
|
|
|
|
import Button from "@/components/TempDesignSystem/Button"
|
|
import Body from "@/components/TempDesignSystem/Text/Body"
|
|
import Caption from "@/components/TempDesignSystem/Text/Caption"
|
|
import Footnote from "@/components/TempDesignSystem/Text/Footnote"
|
|
import Subtitle from "@/components/TempDesignSystem/Text/Subtitle"
|
|
|
|
import styles from "./rateSummary.module.css"
|
|
|
|
import type { RateSummaryProps } from "@/types/components/hotelReservation/selectRate/rateSummary"
|
|
import { RoomPackageCodeEnum } from "@/types/components/hotelReservation/selectRate/roomFilter"
|
|
|
|
export default function RateSummary({
|
|
rateSummary,
|
|
isUserLoggedIn,
|
|
packages,
|
|
roomsAvailability,
|
|
}: RateSummaryProps) {
|
|
const intl = useIntl()
|
|
const {
|
|
member,
|
|
public: publicRate,
|
|
features,
|
|
roomType,
|
|
priceName,
|
|
} = rateSummary
|
|
const priceToShow = isUserLoggedIn ? member : publicRate
|
|
|
|
const isPetRoomSelected = features.some(
|
|
(feature) => feature.code === RoomPackageCodeEnum.PET_ROOM
|
|
)
|
|
|
|
const petRoomPackage = packages.find(
|
|
(pkg) => pkg.code === RoomPackageCodeEnum.PET_ROOM
|
|
)
|
|
|
|
const petRoomPrice = petRoomPackage?.calculatedPrice ?? null
|
|
const petRoomCurrency = petRoomPackage?.currency ?? null
|
|
|
|
const checkInDate = new Date(roomsAvailability.checkInDate)
|
|
const checkOutDate = new Date(roomsAvailability.checkOutDate)
|
|
const nights = differenceInCalendarDays(checkOutDate, checkInDate)
|
|
|
|
return (
|
|
<div className={styles.summary}>
|
|
<div className={styles.summaryText}>
|
|
<Subtitle color="uiTextHighContrast">{roomType}</Subtitle>
|
|
<Body color="uiTextMediumContrast">{priceName}</Body>
|
|
</div>
|
|
<div className={styles.summaryPrice}>
|
|
<div className={styles.summaryPriceTextDesktop}>
|
|
<Subtitle color={isUserLoggedIn ? "red" : "uiTextHighContrast"}>
|
|
{priceToShow?.localPrice.pricePerStay}{" "}
|
|
{priceToShow?.localPrice.currency}
|
|
</Subtitle>
|
|
<Body color="uiTextMediumContrast">
|
|
{intl.formatMessage({ id: "Approx." })}{" "}
|
|
{priceToShow?.requestedPrice?.pricePerStay}{" "}
|
|
{priceToShow?.requestedPrice?.currency}
|
|
</Body>
|
|
</div>
|
|
<div className={styles.summaryPriceTextMobile}>
|
|
<Caption color="uiTextHighContrast">
|
|
{intl.formatMessage({ id: "Total price" })}
|
|
</Caption>
|
|
<Subtitle color={isUserLoggedIn ? "red" : "uiTextHighContrast"}>
|
|
{priceToShow?.localPrice.pricePerStay}{" "}
|
|
{priceToShow?.localPrice.currency}
|
|
</Subtitle>
|
|
<Footnote
|
|
color="uiTextMediumContrast"
|
|
className={styles.summaryPriceTextMobile}
|
|
>
|
|
{intl.formatMessage(
|
|
{ id: "booking.nights" },
|
|
{ totalNights: nights }
|
|
)}
|
|
,{" "}
|
|
{intl.formatMessage(
|
|
{ id: "booking.adults" },
|
|
{ totalAdults: roomsAvailability.occupancy?.adults }
|
|
)}
|
|
{roomsAvailability.occupancy?.children?.length && (
|
|
<>
|
|
,{" "}
|
|
{intl.formatMessage(
|
|
{ id: "booking.children" },
|
|
{ totalChildren: roomsAvailability.occupancy.children.length }
|
|
)}
|
|
</>
|
|
)}
|
|
</Footnote>
|
|
</div>
|
|
{isPetRoomSelected && (
|
|
<div className={styles.petInfo}>
|
|
<Body color="uiTextHighContrast" textTransform="bold">
|
|
+ {petRoomPrice} {petRoomCurrency}
|
|
</Body>
|
|
<Body color="uiTextMediumContrast">
|
|
{intl.formatMessage({ id: "Pet charge" })}
|
|
</Body>
|
|
</div>
|
|
)}
|
|
<Button type="submit" theme="base" className={styles.continueButton}>
|
|
{intl.formatMessage({ id: "Continue" })}
|
|
</Button>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|