Feat/book 425 optimize campaign rate card * feat(BOOK-425): design updates to RateCard * feat(BOOK-425): design updates to campaign BookingCodeChip * feat(BOOK-425): fixed breakfast message & booking code chips on select rate and enter detailss * feat(BOOK-425): fixed booking code chip on Booking Confirmation page * fixed draft comments * fixed more comments * feat(BOOK-425): removed fixed height from RateCard banner * fixed another variable comment * fixed more pr comments * fixed more pr comments * updated ratecard campaign standard rate title color * removed deconstructed props Approved-by: Bianca Widstam Approved-by: Erik Tiekstra
85 lines
2.0 KiB
TypeScript
85 lines
2.0 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 { CurrencyEnum } from "@scandic-hotels/common/constants/currency"
|
|
|
|
import type { SharedPriceRowProps } from "./price"
|
|
|
|
export interface RegularPriceType {
|
|
regular?: {
|
|
currency: CurrencyEnum
|
|
pricePerNight: number
|
|
pricePerStay: number
|
|
regularPricePerStay: number
|
|
}
|
|
}
|
|
|
|
interface RegularPriceProps extends SharedPriceRowProps {
|
|
isMemberRate: boolean
|
|
isCampaignRate?: boolean
|
|
price: RegularPriceType["regular"]
|
|
}
|
|
|
|
export default function RegularPrice({
|
|
bedType,
|
|
isMemberRate,
|
|
isCampaignRate,
|
|
nights,
|
|
packages,
|
|
price,
|
|
}: RegularPriceProps) {
|
|
const intl = useIntl()
|
|
|
|
if (!price) {
|
|
return null
|
|
}
|
|
|
|
const averagePriceTitle = intl.formatMessage({
|
|
id: "priceDetails.averagePricePerNight",
|
|
defaultMessage: "Average price per night",
|
|
})
|
|
|
|
const avgeragePricePerNight = formatPrice(
|
|
intl,
|
|
price.pricePerNight,
|
|
price.currency
|
|
)
|
|
|
|
const roomCharge = formatPrice(intl, price.pricePerStay, price.currency)
|
|
|
|
const regularPriceIsHigherThanPrice =
|
|
price.regularPricePerStay > price.pricePerStay
|
|
let regularCharge = undefined
|
|
if (regularPriceIsHigherThanPrice) {
|
|
regularCharge = formatPrice(intl, price.regularPricePerStay, price.currency)
|
|
}
|
|
const isDiscounted =
|
|
isMemberRate || isCampaignRate || regularPriceIsHigherThanPrice
|
|
|
|
return (
|
|
<>
|
|
<BoldRow
|
|
label={intl.formatMessage({
|
|
id: "priceDetails.roomCharge",
|
|
defaultMessage: "Room charge",
|
|
})}
|
|
value={roomCharge}
|
|
regularValue={regularCharge}
|
|
isDiscounted={isDiscounted}
|
|
/>
|
|
{nights > 1 ? (
|
|
<RegularRow label={averagePriceTitle} value={avgeragePricePerNight} />
|
|
) : null}
|
|
<BedTypeRow bedType={bedType} currency={price.currency} />
|
|
<PackagesRow packages={packages} />
|
|
</>
|
|
)
|
|
}
|