Feat/SW-1652 confirmation page * feat(SW-1652): handle linkedReservations fetching * fix: add missing translations * feat: add linkedReservation retry functionality * chore: align naming Approved-by: Simon.Emanuelsson
62 lines
1.8 KiB
TypeScript
62 lines
1.8 KiB
TypeScript
"use client"
|
|
|
|
import { useIntl } from "react-intl"
|
|
|
|
import { useBookingConfirmationStore } from "@/stores/booking-confirmation"
|
|
|
|
import { CreditCardAddIcon } from "@/components/Icons"
|
|
import SkeletonShimmer from "@/components/SkeletonShimmer"
|
|
import Button from "@/components/TempDesignSystem/Button"
|
|
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 = useBookingConfirmationStore((state) => state.rooms)
|
|
const currencyCode = useBookingConfirmationStore(
|
|
(state) => 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>
|
|
<Button
|
|
className={styles.btn}
|
|
intent="text"
|
|
size="small"
|
|
theme="base"
|
|
variant="icon"
|
|
wrapping
|
|
>
|
|
<CreditCardAddIcon />
|
|
{intl.formatMessage({ id: "Save card to profile" })}
|
|
</Button>
|
|
</div>
|
|
)
|
|
}
|