@@ -216,11 +211,18 @@ export function formatCardNumber(cardNumber, digits = 8) {
return cardNumber.replace(formatCardNumberRegex, ' ').trim()
}
-export const getCardData: (productCode: string) => PaymentCardRawData = (
- productCode
-) => {
- const card = cardProducts.find(
- (item) => item.productCode === productCode
+export function getCardDesign(productCode: string): CustomCard {
+ return (
+ cardProducts.find((item) => item.productCode === productCode) ||
+ defaultCard(productCode)
)
- return card || defaultCard(productCode)
}
+
+// export const getCardData: (productCode: string) => PaymentCardRawData = (
+// productCode
+// ) => {
+// const card = cardProducts.find(
+// (item) => item.productCode === productCode
+// )
+// return card || defaultCard(productCode)
+// }
diff --git a/packages/dnb-eufemia/src/extensions/payment-card/icons/index.tsx b/packages/dnb-eufemia/src/extensions/payment-card/icons/index.tsx
index 3848b4829b3..3946a83f46b 100644
--- a/packages/dnb-eufemia/src/extensions/payment-card/icons/index.tsx
+++ b/packages/dnb-eufemia/src/extensions/payment-card/icons/index.tsx
@@ -29,20 +29,22 @@ import {
BankAxeptType,
CardStatus,
CardTypeDesign,
+ PaymentType,
+ CardProvider,
+ BankLogoType,
} from '../types'
type BankLogoProps = {
- logoType?: LogoType
+ type?: BankLogoType
color?: string
- height?: string
}
-function BankLogo({ logoType, color, height }: BankLogoProps) {
- switch (logoType) {
+function BankLogo({ type, color }: BankLogoProps) {
+ switch (type) {
case 'DNB':
return (
@@ -51,33 +53,29 @@ function BankLogo({ logoType, color, height }: BankLogoProps) {
case 'sbanken':
return (
)
+ default:
+ return null
}
}
type ProductLogoProps = {
- productType: ProductType
- cardDesign: CardDesign
+ type?: ProductType
+ // color?: string
}
-function ProductLogo({ productType, cardDesign }: ProductLogoProps) {
+function ProductLogo({ type }: ProductLogoProps) {
const classname = 'dnb-payment-card__card__product-type'
- switch (productType) {
- case 'Saga':
- switch (cardDesign) {
- case 'SagaGold':
- return
- case 'SagaPlatinum':
- return
- case 'None':
- default:
- return null
- }
+ switch (type) {
+ case 'SagaGold':
+ return
+ case 'SagaPlatinum':
+ return
case 'Pluss':
return
case 'Intro':
@@ -87,38 +85,30 @@ function ProductLogo({ productType, cardDesign }: ProductLogoProps) {
case 'Bedrift':
return
case 'PrivateBanking':
- return cardDesign !== 'None' ?
: null
- case 'None':
+ return
default:
return null
}
}
-type BankAxeptProps = {
- bankAxept: BankAxeptType
+type PaymentTypeProps = {
+ type: PaymentType
+ color: string
}
-const BankAxeptLogo = ({ bankAxept }: BankAxeptProps) => {
- const classname = 'dnb-payment-card__card__bank-axept'
-
- switch (bankAxept) {
- case 'BankAxeptWhite':
- return
- case 'BankAxeptBlack20':
- return
- case 'BankAxeptGray':
- return
- case 'BankAxeptGrayDark':
- return
- case 'BankAxeptBlack':
- return
- case 'BankAxeptGold':
- return
+const PaymentTypeLogo = ({ type, color }: PaymentTypeProps) => {
+ switch (type) {
+ case 'BankAxept':
+ return (
+
+ )
case 'Credit':
return (
-
+
)
- case 'None':
default:
return null
}
@@ -154,26 +144,43 @@ const StatusIcon = ({ status }: { status: CardStatus }) => {
}
const CardProviderLogo = ({
- cardTypeDesign,
+ type,
color,
}: {
- cardTypeDesign: CardTypeDesign
+ type: CardProvider
color?: string
}) => {
const id = 'dnb-payment-card__card__credit-type'
- switch (cardTypeDesign) {
- case 'VisaColored':
- return
- case 'VisaPlatinum':
- return
- case 'MastercardDefault':
+ switch (type) {
+ case 'Mastercard':
return
+
case 'MastercardDark':
return
- case 'None':
+
+ case 'Visa':
+ return
+
+ case 'VisaPlatinum':
+ return
+
+ default:
return null
}
+
+ // switch (cardTypeDesign) {
+ // case 'VisaColored':
+ // return
+ // case 'VisaPlatinum':
+ // return
+ // case 'MastercardDefault':
+ // return
+ // case 'MastercardDark':
+ // return
+ // case 'None':
+ // return null
+ // }
}
export {
@@ -181,5 +188,5 @@ export {
ProductLogo,
StatusIcon,
CardProviderLogo,
- BankAxeptLogo,
+ PaymentTypeLogo,
}
diff --git a/packages/dnb-eufemia/src/extensions/payment-card/stories/PaymentCard.stories.tsx b/packages/dnb-eufemia/src/extensions/payment-card/stories/PaymentCard.stories.tsx
index cf2add9aea9..24b3608fedd 100644
--- a/packages/dnb-eufemia/src/extensions/payment-card/stories/PaymentCard.stories.tsx
+++ b/packages/dnb-eufemia/src/extensions/payment-card/stories/PaymentCard.stories.tsx
@@ -16,7 +16,7 @@ import cardData from '../utils/cardProducts'
import { PaymentCardRawData } from '../types'
import { H2 } from '../../../elements'
-import PaymentCard, { getCardData, Designs } from '../'
+import PaymentCard, { getCardDesign, Designs } from '../'
export default {
title: 'Eufemia/Extensions/PaymentCard',
@@ -26,16 +26,16 @@ const CustomWrapper = styled(Wrapper)`
/* empty */
`
-const customData: PaymentCardRawData = {
- productCode: 'UNDEFINED',
- productName: 'DNB Custom Card',
- displayName: 'Custom card', // Only showed in compact variant
- // cardDesign: 'gold',
- cardDesign: Designs.gold,
- cardType: 'MastercardDefault',
- productType: 'Saga',
- bankAxept: 'BankAxeptWhite',
-}
+// const customData: PaymentCardRawData = {
+// productCode: 'UNDEFINED',
+// productName: 'DNB Custom Card',
+// displayName: 'Custom card', // Only showed in compact variant
+// // cardDesign: 'gold',
+// cardDesign: Designs.gold,
+// cardType: 'MastercardDefault',
+// productType: 'Saga',
+// bankAxept: 'BankAxeptWhite',
+// }
export const PaymentCards = () => (
@@ -43,7 +43,7 @@ export const PaymentCards = () => (
Test
@@ -96,22 +96,22 @@ export const PaymentCards = () => (
@@ -120,11 +120,11 @@ export const PaymentCards = () => (
All Cards
{cards.map((productCode) => {
- const cardData = getCardData(productCode)
+ const cardData = getCardDesign(productCode)
return (
- {cardData.cardDesign.name}({productCode})
+ {cardData.displayName}({productCode})