fix(SW-3616): Handle EuroBonus point type everywhere * Add tests to formatPrice * formatPrice * More work replacing config with api points type * More work replacing config with api points type * More fixing with currency * maybe actually fixed it * Fix MyStay * Clean up * Fix comments * Merge branch 'master' into fix/refactor-currency-display * Fix calculateTotalPrice for EB points + SF points + cash Approved-by: Joakim Jäderberg
71 lines
1.8 KiB
TypeScript
71 lines
1.8 KiB
TypeScript
import { cx } from "class-variance-authority"
|
|
import { useIntl } from "react-intl"
|
|
|
|
import { formatPrice } from "@scandic-hotels/common/utils/numberFormatting"
|
|
import { Typography } from "@scandic-hotels/design-system/Typography"
|
|
|
|
import styles from "./row.module.css"
|
|
|
|
import type { Price } from "../../../../types/price"
|
|
|
|
interface RowProps {
|
|
allPricesIsDiscounted: boolean
|
|
label: string
|
|
price: Price
|
|
}
|
|
|
|
export default function LargeRow({
|
|
allPricesIsDiscounted,
|
|
label,
|
|
price,
|
|
}: RowProps) {
|
|
const intl = useIntl()
|
|
|
|
const totalPrice = formatPrice(
|
|
intl,
|
|
price.local.price,
|
|
price.local.currency,
|
|
price.local.additionalPrice,
|
|
price.local.additionalPriceCurrency,
|
|
price.local.pointsType
|
|
)
|
|
const regularPrice = price.local.regularPrice
|
|
? formatPrice(
|
|
intl,
|
|
price.local.regularPrice,
|
|
price.local.currency,
|
|
price.local.additionalPrice,
|
|
price.local.additionalPriceCurrency,
|
|
price.local.pointsType
|
|
)
|
|
: null
|
|
|
|
const isDiscounted =
|
|
allPricesIsDiscounted ||
|
|
(price.local.regularPrice !== undefined &&
|
|
price.local.regularPrice > price.local.price)
|
|
return (
|
|
<Typography variant="Body/Paragraph/mdBold">
|
|
<tr className={styles.row}>
|
|
<td>
|
|
<span>{label}</span>
|
|
</td>
|
|
<td className={styles.price}>
|
|
{isDiscounted && regularPrice ? (
|
|
<>
|
|
<Typography variant="Body/Paragraph/mdRegular">
|
|
<p>
|
|
<s className={styles.strikeThroughRate}>{regularPrice}</s>
|
|
</p>
|
|
</Typography>
|
|
</>
|
|
) : null}
|
|
<span className={cx({ [styles.discounted]: isDiscounted })}>
|
|
{totalPrice}
|
|
</span>
|
|
</td>
|
|
</tr>
|
|
</Typography>
|
|
)
|
|
}
|