Skip to content

Commit

Permalink
fix: re render issue of card nickname
Browse files Browse the repository at this point in the history
  • Loading branch information
PritishBudhiraja committed Dec 5, 2024
1 parent 659b815 commit e527b28
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
11 changes: 3 additions & 8 deletions src/Hooks/UtilityHooks.res
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,19 @@ let useHandlePostMessages = (~complete, ~empty, ~paymentType, ~savedMethod=false
}

let useIsCustomerAcceptanceRequired = (
~displaySavedPaymentMethodsCheckbox,
~options: PaymentType.options,
~isSaveCardsChecked,
~isGuestCustomer,
) => {
let paymentMethodListValue = Recoil.useRecoilValueFromAtom(PaymentUtils.paymentMethodListValue)

React.useMemo(() => {
if displaySavedPaymentMethodsCheckbox {
if options.displaySavedPaymentMethodsCheckbox {
isSaveCardsChecked || paymentMethodListValue.payment_type === SETUP_MANDATE
} else {
!(isGuestCustomer || paymentMethodListValue.payment_type === NORMAL)
}
}, (
isSaveCardsChecked,
paymentMethodListValue.payment_type,
isGuestCustomer,
displaySavedPaymentMethodsCheckbox,
))
}, (isSaveCardsChecked, paymentMethodListValue.payment_type, isGuestCustomer, options))
}

let useSendEventsToParent = eventsToSendToParent => {
Expand Down
5 changes: 2 additions & 3 deletions src/Payments/CardPayment.res
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ let make = (
cvcError,
setCvcError,
) = cvcProps
let {displaySavedPaymentMethodsCheckbox} = Recoil.useRecoilValueFromAtom(RecoilAtoms.optionAtom)
let intent = PaymentHelpers.usePaymentIntent(Some(loggerState), Card)
let showFields = Recoil.useRecoilValueFromAtom(RecoilAtoms.showCardFieldsAtom)
let setComplete = Recoil.useSetRecoilState(RecoilAtoms.fieldsComplete)
Expand Down Expand Up @@ -120,7 +119,7 @@ let make = (
)

let isCustomerAcceptanceRequired = useIsCustomerAcceptanceRequired(
~displaySavedPaymentMethodsCheckbox,
~options,
~isSaveCardsChecked,
~isGuestCustomer,
)
Expand Down Expand Up @@ -352,7 +351,7 @@ let make = (
<RenderIf condition={showFields || isBancontact}>
<Surcharge paymentMethod paymentMethodType cardBrand={cardBrand->CardUtils.getCardType} />
</RenderIf>
<RenderIf condition={displaySavedPaymentMethodsCheckbox && !isBancontact}>
<RenderIf condition={options.displaySavedPaymentMethodsCheckbox && !isBancontact}>
{switch (
paymentMethodListValue.mandate_payment,
options.terms.card,
Expand Down

0 comments on commit e527b28

Please sign in to comment.