Skip to content

Commit

Permalink
fix: displaySavedPaymentMethods prop
Browse files Browse the repository at this point in the history
  • Loading branch information
Pritish Budhiraja committed Mar 12, 2024
1 parent b8b33a7 commit ab53eaf
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
16 changes: 12 additions & 4 deletions src/PaymentElement.res
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ let make = (
paymentMethodOrder,
layout,
customerPaymentMethods,
displaySavedPaymentMethods,
displaySavedPaymentMethodsCheckbox,
} = Recoil.useRecoilValueFromAtom(optionAtom)
let isApplePayReady = Recoil.useRecoilValueFromAtom(isApplePayReady)
Expand Down Expand Up @@ -369,13 +370,20 @@ let make = (
</ErrorBoundary>
}

let paymentLabel = showFields
? localeString.selectPaymentMethodLabel
: localeString.savedPaymentMethodsLabel
React.useEffect0(() => {
setShowFields(._ => !displaySavedPaymentMethods)
None
})

let paymentLabel = if displaySavedPaymentMethods {
showFields ? localeString.selectPaymentMethodLabel : localeString.savedPaymentMethodsLabel
} else {
localeString.selectPaymentMethodLabel
}

<>
<div className="text-2xl font-semibold text-[#151619] mb-6"> {React.string(paymentLabel)} </div>
<RenderIf condition={!showFields}>
<RenderIf condition={!showFields && displaySavedPaymentMethods}>
<SavedMethods
paymentToken setPaymentToken savedMethods loadSavedCards cvcProps paymentType list
/>
Expand Down
5 changes: 4 additions & 1 deletion src/Payments/CardPayment.res
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,10 @@ let make = (
<AnimatedCheckbox isChecked=isSaveCardsChecked setIsChecked=setIsSaveCardsChecked />
</div>
</RenderIf>
<RenderIf condition={savedMethods->Js.Array2.length > 0 && !isBancontact}>
<RenderIf
condition={options.displaySavedPaymentMethods &&
savedMethods->Js.Array2.length > 0 &&
!isBancontact}>
<div
className="Label flex flex-row gap-3 items-end cursor-pointer"
style={ReactDOMStyle.make(
Expand Down
4 changes: 1 addition & 3 deletions src/orca-loader/Elements.res
Original file line number Diff line number Diff line change
Expand Up @@ -712,9 +712,7 @@ let make = (
})
->ignore
fetchPaymentsList(mountedIframeRef)
if displaySavedPaymentMethods {
fetchCustomerDetails(mountedIframeRef)
}
fetchCustomerDetails(mountedIframeRef)
mountedIframeRef->Window.iframePostMessage(message)
}

Expand Down

0 comments on commit ab53eaf

Please sign in to comment.