Files
web/packages/design-system/lib/components/Form/PaymentOption/PaymentOption.tsx
Joakim Jäderberg 6fa301f8e7 Merged in SW-3396-move-my-saved-cards-to-design-system (pull request #2762)
SW-3396 move my saved cards to design system

* Move PaymentOption, PaymentOptionsGroup, PaymentIcons and MySavedCards (renamed SelectPaymentMethod) to design-system

* Remove unused svg payment icons

* cleanu

* cleanup

* trackUpdatePaymentMethod: remove hotelId argument that was never passed


Approved-by: Anton Gunnarsson
2025-09-04 13:01:36 +00:00

54 lines
1.5 KiB
TypeScript

import { cx } from 'class-variance-authority'
import { Label, Radio } from 'react-aria-components'
import styles from './paymentOption.module.css'
import type { PaymentMethodEnum } from '@scandic-hotels/common/constants/paymentMethod'
import { PaymentMethodIcon } from '../../Payment/PaymentMethodIcon'
import { Typography } from '../../Typography'
export type PaymentOptionProps = {
value: PaymentMethodEnum
label: string
cardNumber?: string
}
export function PaymentOption({
value,
label,
cardNumber,
}: PaymentOptionProps) {
return (
<Radio
value={value}
className={({ isFocusVisible }) =>
cx(styles.paymentOption, { [styles.focused]: isFocusVisible })
}
>
{({ isSelected }) => (
<>
<div className={styles.titleContainer}>
<span
className={cx(styles.radio, { [styles.selected]: isSelected })}
aria-hidden
/>
<Typography variant="Body/Paragraph/mdRegular">
<Label>{label}</Label>
</Typography>
</div>
{cardNumber ? (
<>
<Typography variant={'Body/Supporting text (caption)/smRegular'}>
{/* eslint-disable-next-line formatjs/no-literal-string-in-jsx */}
<span> {cardNumber}</span>
</Typography>
</>
) : (
<PaymentMethodIcon paymentMethod={value} alt={label} />
)}
</>
)}
</Radio>
)
}