ReactDOM.Ref.domRef}
@@ -161,11 +160,15 @@ let make = (
{React.string(
selectedPaymentOption.displayName === "Card"
? localeString.card
- : PaymentUtils.getDisplayName(
- customMethodNames,
- selectedPaymentOption.paymentMethodName,
- selectedPaymentOption.displayName,
- ),
+ : {
+ let (name, _) = PaymentUtils.getDisplayNameAndIcon(
+ customMethodNames,
+ selectedPaymentOption.paymentMethodName,
+ selectedPaymentOption.displayName,
+ selectedPaymentOption.icon,
+ )
+ name
+ },
)}
{dropDownOptionsDetails
@@ -177,11 +180,15 @@ let make = (
{React.string(
item.displayName === "card"
? localeString.card
- : PaymentUtils.getDisplayName(
- customMethodNames,
- item.paymentMethodName,
- item.displayName,
- ),
+ : {
+ let (name, _) = PaymentUtils.getDisplayNameAndIcon(
+ customMethodNames,
+ item.paymentMethodName,
+ item.displayName,
+ item.icon,
+ )
+ name
+ },
)}
})
diff --git a/src/TabCard.res b/src/TabCard.res
index d34213241..61b97937e 100644
--- a/src/TabCard.res
+++ b/src/TabCard.res
@@ -8,6 +8,12 @@ let make = (~paymentOption: PaymentMethodsRecord.paymentFieldsInfo, ~isActive: b
() => isActive ? ("Tab--selected", "TabLabel--selected", "TabIcon--selected") : ("", "", ""),
[isActive],
)
+ let (displayName, icon) = PaymentUtils.getDisplayNameAndIcon(
+ customMethodNames,
+ paymentOption.paymentMethodName,
+ paymentOption.displayName,
+ paymentOption.icon,
+ )
setSelectedOption(._ => paymentOption.paymentMethodName)}>
- {switch paymentOption.icon {
+ {switch icon {
| Some(ele) => ele
| None =>
}}
- {React.string(
- paymentOption.paymentMethodName === "card"
- ? localeString.card
- : PaymentUtils.getDisplayName(
- customMethodNames,
- paymentOption.paymentMethodName,
- paymentOption.displayName,
- ),
- )}
+ {React.string(paymentOption.paymentMethodName === "card" ? localeString.card : displayName)}
}
diff --git a/src/Utilities/PaymentUtils.res b/src/Utilities/PaymentUtils.res
index b9acf14ad..f8530a0f0 100644
--- a/src/Utilities/PaymentUtils.res
+++ b/src/Utilities/PaymentUtils.res
@@ -173,10 +173,11 @@ let getPaymentDetails = (arr: array
) => {
->ignore
finalArr
}
-let getDisplayName = (
+let getDisplayNameAndIcon = (
customNames: PaymentType.customMethodNames,
paymentMethodName,
defaultName,
+ defaultIcon,
) => {
let customNameObj =
customNames
@@ -185,7 +186,21 @@ let getDisplayName = (
})
->Belt.Array.get(0)
switch customNameObj {
- | Some(val) => val.paymentMethodName === "classic" ? val.aliasName : defaultName
- | None => defaultName
+ | Some(val) =>
+ val.paymentMethodName === "classic"
+ ? {
+ let id = val.aliasName->Js.String2.split(" ")
+ (
+ val.aliasName,
+ Some(
+ PaymentMethodsRecord.icon(
+ id->Belt.Array.get(0)->Belt.Option.getWithDefault(""),
+ ~size=19,
+ ),
+ ),
+ )
+ }
+ : (defaultName, defaultIcon)
+ | None => (defaultName, defaultIcon)
}
}