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
50 lines
1.4 KiB
TypeScript
50 lines
1.4 KiB
TypeScript
"use client"
|
|
|
|
import { useIntl } from "react-intl"
|
|
|
|
import { useBookingConfirmationStore } from "@/stores/booking-confirmation"
|
|
|
|
import SkeletonShimmer from "@/components/SkeletonShimmer"
|
|
import Body from "@/components/TempDesignSystem/Text/Body"
|
|
import Subtitle from "@/components/TempDesignSystem/Text/Subtitle"
|
|
import { formatPrice } from "@/utils/numberFormatting"
|
|
|
|
import styles from "./paymentDetails.module.css"
|
|
|
|
export default function PaymentDetails() {
|
|
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 (
|
|
<div className={styles.details}>
|
|
<Subtitle color="uiTextHighContrast" type="two">
|
|
{intl.formatMessage({ id: "Payment details" })}
|
|
</Subtitle>
|
|
<div className={styles.payment}>
|
|
{hasAllRoomsLoaded ? (
|
|
<Body color="uiTextHighContrast">
|
|
{intl.formatMessage(
|
|
{ id: "{amount} has been paid" },
|
|
{
|
|
amount: formatPrice(intl, grandTotal, currencyCode),
|
|
}
|
|
)}
|
|
</Body>
|
|
) : (
|
|
<SkeletonShimmer width={"100%"} />
|
|
)}
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|