Feat/SW-1813 * feat(SW-1652): handle linkedReservations fetching * feat: add linkedReservation retry functionality * chore: align naming * feat(SW-1813): Add booking confirmation PriceDetailsModal Approved-by: Simon.Emanuelsson
56 lines
1.6 KiB
TypeScript
56 lines
1.6 KiB
TypeScript
"use client"
|
|
|
|
import { useIntl } from "react-intl"
|
|
|
|
import { useBookingConfirmationStore } from "@/stores/booking-confirmation"
|
|
|
|
import SkeletonShimmer from "@/components/SkeletonShimmer"
|
|
import Divider from "@/components/TempDesignSystem/Divider"
|
|
import Body from "@/components/TempDesignSystem/Text/Body"
|
|
import { formatPrice } from "@/utils/numberFormatting"
|
|
|
|
import PriceDetailsModal from "../../PriceDetailsModal"
|
|
|
|
import styles from "./totalPrice.module.css"
|
|
|
|
export default function TotalPrice() {
|
|
const intl = useIntl()
|
|
const { rooms, currencyCode } = useBookingConfirmationStore((state) => ({
|
|
rooms: state.rooms,
|
|
currencyCode: state.currencyCode,
|
|
}))
|
|
|
|
const hasAllRoomsLoaded = rooms.every((room) => room)
|
|
const grandTotal = rooms.reduce((acc, room) => {
|
|
const reservationTotalPrice = room?.totalPrice || 0
|
|
return acc + reservationTotalPrice
|
|
}, 0)
|
|
|
|
return (
|
|
<>
|
|
<Divider color="primaryLightSubtle" />
|
|
<div className={styles.price}>
|
|
<div className={styles.entry}>
|
|
<Body textTransform="bold">
|
|
{intl.formatMessage({ id: "Total price" })}
|
|
</Body>
|
|
{hasAllRoomsLoaded ? (
|
|
<Body textTransform="bold">
|
|
{formatPrice(intl, grandTotal, currencyCode)}
|
|
</Body>
|
|
) : (
|
|
<SkeletonShimmer width={"25%"} />
|
|
)}
|
|
</div>
|
|
{hasAllRoomsLoaded ? (
|
|
<PriceDetailsModal />
|
|
) : (
|
|
<div className={styles.priceDetailsLoader}>
|
|
<SkeletonShimmer width={"100%"} />
|
|
</div>
|
|
)}
|
|
</div>
|
|
</>
|
|
)
|
|
}
|