From 83259397ae8f9a188939f775167deaa204f526d4 Mon Sep 17 00:00:00 2001 From: Praful Koppalkar Date: Wed, 4 Oct 2023 19:05:08 +0530 Subject: [PATCH 1/3] - added support to have customNames - bugfix dropdown names --- src/Components/Accordion.res | 14 ++++++++--- src/PaymentOptions.res | 34 ++++++++++++++++++++------- src/Payments/PaymentMethodsRecord.res | 6 +++++ src/TabCard.res | 10 ++++++-- src/Types/PaymentType.res | 20 ++++++++++++++++ src/Utilities/PaymentUtils.res | 14 +++++++++++ 6 files changed, 84 insertions(+), 14 deletions(-) diff --git a/src/Components/Accordion.res b/src/Components/Accordion.res index 1fe4dda1a..162e39ff0 100644 --- a/src/Components/Accordion.res +++ b/src/Components/Accordion.res @@ -7,8 +7,8 @@ let make = ( ~borderBottom: bool, ~borderRadiusStyle, ) => { - let {themeObj} = Recoil.useRecoilValueFromAtom(configAtom) - let {layout} = Recoil.useRecoilValueFromAtom(optionAtom) + let {themeObj, localeString} = Recoil.useRecoilValueFromAtom(configAtom) + let {layout, customMethodNames} = Recoil.useRecoilValueFromAtom(optionAtom) let layoutClass = CardUtils.getLayoutClass(layout) let (selectedOption, setSelectedOption) = Recoil.useRecoilState(selectedOptionAtom) let ( @@ -53,7 +53,15 @@ let make = ( }}
- {React.string(paymentOption.displayName)} + {React.string( + paymentOption.paymentMethodName === "card" + ? localeString.card + : PaymentUtils.getDisplayName( + customMethodNames, + paymentOption.paymentMethodName, + paymentOption.displayName, + ), + )}
diff --git a/src/PaymentOptions.res b/src/PaymentOptions.res index 518daa8ca..72107d3fb 100644 --- a/src/PaymentOptions.res +++ b/src/PaymentOptions.res @@ -49,8 +49,8 @@ let make = ( ~checkoutEle: React.element, ~cardShimmerCount: int, ) => { - let {themeObj} = Recoil.useRecoilValueFromAtom(configAtom) - let {readOnly} = Recoil.useRecoilValueFromAtom(optionAtom) + let {themeObj, localeString} = Recoil.useRecoilValueFromAtom(configAtom) + let {readOnly, customMethodNames} = Recoil.useRecoilValueFromAtom(optionAtom) let payOptionsRef = React.useRef(Js.Nullable.null) let selectRef = React.useRef(Js.Nullable.null) let (winW, winH) = Utils.useWindowSize() @@ -75,9 +75,9 @@ let make = ( let dropDownOptionsDetails = dropDownOptions->PaymentMethodsRecord.getPaymentDetails let selectedPaymentOption = - PaymentDetails.details - ->Js.Array2.find(item => item.type_ == selectedOption) - ->Belt.Option.getWithDefault(PaymentDetails.defaultPaymentDetails) + PaymentMethodsRecord.paymentMethodsFields + ->Js.Array2.find(item => item.paymentMethodName == selectedOption) + ->Belt.Option.getWithDefault(PaymentMethodsRecord.defaultPaymentMethodFields)
ReactDOM.Ref.domRef} @@ -101,7 +101,7 @@ let make = (