From fff1a546f887111bb60138d8d00ab8e752b1822e Mon Sep 17 00:00:00 2001 From: Praful Koppalkar <126236898+prafulkoppalkar@users.noreply.github.com> Date: Tue, 14 Nov 2023 11:31:42 +0530 Subject: [PATCH] feat: HS-162: Added Custom CashToCode svg (#16) --- public/icons/orca.svg | 6 ++++++ src/Components/Accordion.res | 18 ++++++++---------- src/PaymentOptions.res | 29 ++++++++++++++++++----------- src/TabCard.res | 18 ++++++++---------- src/Utilities/PaymentUtils.res | 21 ++++++++++++++++++--- 5 files changed, 58 insertions(+), 34 deletions(-) diff --git a/public/icons/orca.svg b/public/icons/orca.svg index 66c5162e0..55031a0df 100644 --- a/public/icons/orca.svg +++ b/public/icons/orca.svg @@ -1098,4 +1098,10 @@ License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL + + + + + + \ No newline at end of file diff --git a/src/Components/Accordion.res b/src/Components/Accordion.res index 7299251b7..1b35b0d07 100644 --- a/src/Components/Accordion.res +++ b/src/Components/Accordion.res @@ -28,6 +28,12 @@ let make = ( : ("", "", "", false), [isActive], ) + let (displayName, icon) = PaymentUtils.getDisplayNameAndIcon( + customMethodNames, + paymentOption.paymentMethodName, + paymentOption.displayName, + paymentOption.icon, + )
- {switch paymentOption.icon { + {switch icon { | Some(ele) => ele | None => React.string("") }}
- {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/PaymentOptions.res b/src/PaymentOptions.res index 0843023fa..a6873afcd 100644 --- a/src/PaymentOptions.res +++ b/src/PaymentOptions.res @@ -103,7 +103,6 @@ let make = ( let displayIcon = ele => { ele } -
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, + ) } 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) } }