Files
web/packages/design-system/lib/components/RateCard/Points/Points.stories.tsx
Anton Gunnarsson 16fbdb7ae0 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
2026-01-15 09:32:17 +00:00

204 lines
4.8 KiB
TypeScript

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",
component: PointsRateCard,
decorators: [
(Story) => (
<div style={{ maxWidth: "400px" }}>
<Story />
</div>
),
],
argTypes: {
rateTitle: { control: "text" },
paymentTerm: { control: "text" },
bannerText: { control: "text" },
rates: { control: "object" },
selectedRate: { control: "text" },
onRateSelect: { action: "onRateSelect" },
isNotEnoughPoints: { control: "boolean" },
notEnoughPointsText: { control: "text" },
rateTermDetails: { control: "object" },
},
}
export default meta
type Story = StoryObj<typeof PointsRateCard>
export const Default: Story = {
args: {
rateTitle: "FREE CANCELLATION",
paymentTerm: "PAY LATER",
bannerText: "Reward night ∙ Breakfast included",
rates: [
{
points: 20000,
currency: CurrencyEnum.POINTS,
rateCode: "REDNIGHT7",
},
{
points: 15000,
currency: CurrencyEnum.POINTS,
additionalPrice: {
price: "250",
currency: CurrencyEnum.EUR,
},
rateCode: "REDNIGHT7A",
},
{
points: 10000,
currency: CurrencyEnum.POINTS,
additionalPrice: {
price: "500",
currency: CurrencyEnum.EUR,
},
rateCode: "REDNIGHT7B",
},
],
selectedRate: undefined,
onRateSelect: (value) => console.log(value),
rateTermDetails: [
{
title: "Rate definition 1",
terms: ["term 1", "term 2", "term 3"],
},
],
},
}
export const WithDisabledRates: Story = {
args: {
rateTitle: "FREE CANCELLATION",
paymentTerm: "PAY LATER",
bannerText: "Reward night ∙ Breakfast included",
rates: [
{
points: 20000,
currency: CurrencyEnum.POINTS,
isDisabled: true,
rateCode: "REDNIGHT7",
},
{
points: 15000,
currency: CurrencyEnum.POINTS,
isDisabled: true,
additionalPrice: {
price: "250",
currency: CurrencyEnum.EUR,
},
rateCode: "REDNIGHT7A",
},
{
points: 10000,
currency: CurrencyEnum.POINTS,
additionalPrice: {
price: "500",
currency: CurrencyEnum.EUR,
},
rateCode: "REDNIGHT7B",
},
],
selectedRate: "2",
onRateSelect: (value) => console.log(value),
rateTermDetails: [
{
title: "Rate definition 1",
terms: ["term 1", "term 2", "term 3"],
},
],
},
}
export const NotEnoughPoints: Story = {
args: {
rateTitle: "FREE CANCELLATION",
paymentTerm: "PAY LATER",
bannerText: "Reward night ∙ Breakfast included",
rates: [
{
points: 20000,
currency: CurrencyEnum.POINTS,
rateCode: "REDNIGHT7",
},
{
points: 15000,
currency: CurrencyEnum.POINTS,
additionalPrice: {
price: "250",
currency: CurrencyEnum.EUR,
},
rateCode: "REDNIGHT7A",
},
{
points: 10000,
currency: CurrencyEnum.POINTS,
additionalPrice: {
price: "500",
currency: CurrencyEnum.EUR,
},
rateCode: "REDNIGHT7B",
},
],
selectedRate: undefined,
isNotEnoughPoints: true,
notEnoughPointsText: "Not enough points",
onRateSelect: (value) => console.log(value),
rateTermDetails: [
{
title: "Rate definition 1",
terms: ["term 1", "term 2", "term 3"],
},
],
},
}
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"],
},
],
},
}