Merged in fix/refactor-currency-display (pull request #3434)

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
This commit is contained in:
Anton Gunnarsson
2026-01-15 09:32:17 +00:00
parent c61ddaf94d
commit 16fbdb7ae0
59 changed files with 729 additions and 282 deletions

View File

@@ -1,6 +1,8 @@
import type { Meta, StoryObj } from "@storybook/nextjs-vite"
import PointsRateCard from "."
import { CurrencyEnum } from "@scandic-hotels/common/constants/currency"
import { PointType } from "@scandic-hotels/common/constants/pointType"
const meta: Meta<typeof PointsRateCard> = {
title: "Product Components/RateCard/Points",
@@ -36,25 +38,25 @@ export const Default: Story = {
bannerText: "Reward night ∙ Breakfast included",
rates: [
{
points: "20000",
currency: "PTS",
points: 20000,
currency: CurrencyEnum.POINTS,
rateCode: "REDNIGHT7",
},
{
points: "15000",
currency: "PTS",
points: 15000,
currency: CurrencyEnum.POINTS,
additionalPrice: {
price: "250",
currency: "EUR",
currency: CurrencyEnum.EUR,
},
rateCode: "REDNIGHT7A",
},
{
points: "10000",
currency: "PTS",
points: 10000,
currency: CurrencyEnum.POINTS,
additionalPrice: {
price: "500",
currency: "EUR",
currency: CurrencyEnum.EUR,
},
rateCode: "REDNIGHT7B",
},
@@ -77,27 +79,27 @@ export const WithDisabledRates: Story = {
bannerText: "Reward night ∙ Breakfast included",
rates: [
{
points: "20000",
currency: "PTS",
points: 20000,
currency: CurrencyEnum.POINTS,
isDisabled: true,
rateCode: "REDNIGHT7",
},
{
points: "15000",
currency: "PTS",
points: 15000,
currency: CurrencyEnum.POINTS,
isDisabled: true,
additionalPrice: {
price: "250",
currency: "EUR",
currency: CurrencyEnum.EUR,
},
rateCode: "REDNIGHT7A",
},
{
points: "10000",
currency: "PTS",
points: 10000,
currency: CurrencyEnum.POINTS,
additionalPrice: {
price: "500",
currency: "EUR",
currency: CurrencyEnum.EUR,
},
rateCode: "REDNIGHT7B",
},
@@ -120,25 +122,25 @@ export const NotEnoughPoints: Story = {
bannerText: "Reward night ∙ Breakfast included",
rates: [
{
points: "20000",
currency: "PTS",
points: 20000,
currency: CurrencyEnum.POINTS,
rateCode: "REDNIGHT7",
},
{
points: "15000",
currency: "PTS",
points: 15000,
currency: CurrencyEnum.POINTS,
additionalPrice: {
price: "250",
currency: "EUR",
currency: CurrencyEnum.EUR,
},
rateCode: "REDNIGHT7A",
},
{
points: "10000",
currency: "PTS",
points: 10000,
currency: CurrencyEnum.POINTS,
additionalPrice: {
price: "500",
currency: "EUR",
currency: CurrencyEnum.EUR,
},
rateCode: "REDNIGHT7B",
},
@@ -155,3 +157,47 @@ export const NotEnoughPoints: Story = {
],
},
}
export const WithEuroBonusPoints: Story = {
args: {
rateTitle: "FREE CANCELLATION",
paymentTerm: "PAY LATER",
bannerText: "Reward night ∙ Breakfast included",
rates: [
{
points: 20000,
currency: CurrencyEnum.POINTS,
rateCode: "REDNIGHT7",
pointsType: PointType.EUROBONUS,
},
{
points: 15000,
currency: CurrencyEnum.POINTS,
additionalPrice: {
price: "250",
currency: CurrencyEnum.EUR,
},
rateCode: "REDNIGHT7A",
pointsType: PointType.EUROBONUS,
},
{
points: 10000,
currency: CurrencyEnum.POINTS,
additionalPrice: {
price: "500",
currency: CurrencyEnum.EUR,
},
rateCode: "REDNIGHT7B",
pointsType: PointType.EUROBONUS,
},
],
selectedRate: undefined,
onRateSelect: (value) => console.log(value),
rateTermDetails: [
{
title: "Rate definition 1",
terms: ["term 1", "term 2", "term 3"],
},
],
},
}

View File

@@ -10,6 +10,7 @@ import Modal from "../Modal"
import styles from "../rate-card.module.css"
import { variants } from "../variants"
import { MaterialIcon } from "../../Icons/MaterialIcon"
import { getCurrencyText } from "../../currency-utils"
interface PointsRateCardProps {
rateTitle: string
@@ -120,7 +121,7 @@ export default function PointsRateCard({
<Typography variant="Body/Supporting text (caption)/smBold">
<span>
{/* eslint-disable-next-line formatjs/no-literal-string-in-jsx */}
{`${rate.currency} ${rate.additionalPrice ? " + " : ""}`}
{`${getCurrencyText(intl, rate.currency, rate.points, rate.pointsType)} ${rate.additionalPrice ? " + " : ""}`}
</span>
</Typography>
</p>

View File

@@ -1,3 +1,5 @@
import { PointType } from "@scandic-hotels/common/constants/pointType"
export type Rate = {
label?: string
price: string
@@ -6,7 +8,8 @@ export type Rate = {
export type RatePointsOption = {
rateCode: string
points: string
points: number
pointsType?: PointType | null
currency: string
isDisabled?: boolean
additionalPrice?: AdditionalPrice