feat(SW-3225): Move ParkingInformation to design-system * Inline ParkingInformation types to remove trpc dependency * Move ParkingInformation to design-system * Move numberFormatting to common package * Add deps to external * Fix imports and i18n script * Add common as dependency * Merge branch 'master' into feat/sw-3225-move-parking-information-to-booking-flow Approved-by: Linus Flood
60 lines
1.4 KiB
TypeScript
60 lines
1.4 KiB
TypeScript
"use client"
|
|
import { useIntl } from "react-intl"
|
|
|
|
import { formatPrice } from "@scandic-hotels/common/utils/numberFormatting"
|
|
|
|
import BoldRow from "../Bold"
|
|
import RegularRow from "../Regular"
|
|
import BedTypeRow from "./BedType"
|
|
import PackagesRow from "./Packages"
|
|
|
|
import type { SharedPriceRowProps } from "./price"
|
|
|
|
export interface VoucherPriceType {
|
|
voucher?: {
|
|
numberOfVouchers: number
|
|
}
|
|
}
|
|
|
|
interface VoucherPriceProps extends SharedPriceRowProps {
|
|
currency: string
|
|
nights: number
|
|
price: VoucherPriceType["voucher"]
|
|
}
|
|
|
|
export default function VoucherPrice({
|
|
bedType,
|
|
currency,
|
|
nights,
|
|
packages,
|
|
price,
|
|
}: VoucherPriceProps) {
|
|
const intl = useIntl()
|
|
|
|
if (!price) {
|
|
return null
|
|
}
|
|
|
|
const voucherCurrency = intl.formatMessage({ defaultMessage: "Voucher" })
|
|
|
|
const averagePriceTitle = intl.formatMessage({
|
|
defaultMessage: "Average price per night",
|
|
})
|
|
|
|
const averagePricePerNight = `${price.numberOfVouchers / nights} ${voucherCurrency}`
|
|
|
|
return (
|
|
<>
|
|
<BoldRow
|
|
label={intl.formatMessage({ defaultMessage: "Room charge" })}
|
|
value={formatPrice(intl, price.numberOfVouchers, voucherCurrency)}
|
|
/>
|
|
{nights > 1 ? (
|
|
<RegularRow label={averagePriceTitle} value={averagePricePerNight} />
|
|
) : null}
|
|
<BedTypeRow bedType={bedType} currency={currency} />
|
|
<PackagesRow packages={packages} />
|
|
</>
|
|
)
|
|
}
|