Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: saved Payment Method stuck in loading state and Card Holder Name for every saved card #241

Merged
merged 1 commit into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Components/DynamicFields.res
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ let make = (
~paymentMethodType,
~setRequiredFieldsBody,
~isSavedCardFlow=false,
~savedCards=[]: array<PaymentType.customerMethods>,
~savedMethod=PaymentType.defaultCustomerMethods,
~cardProps=None,
~expiryProps=None,
~cvcProps=None,
Expand Down Expand Up @@ -46,8 +46,8 @@ let make = (
}, [requiredFieldsWithBillingDetails])

let isAllStoredCardsHaveName = React.useMemo1(() => {
PaymentType.getIsAllStoredCardsHaveName(savedCards)
}, [savedCards])
PaymentType.getIsStoredPaymentMethodHasName(savedMethod)
}, [savedMethod])

//<...>//
let fieldsArr = React.useMemo3(() => {
Expand Down
3 changes: 1 addition & 2 deletions src/Components/SavedCardItem.res
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ let make = (
~cvcProps,
~paymentType,
~list,
~savedMethods,
~setRequiredFieldsBody,
) => {
let {themeObj, config} = Recoil.useRecoilValueFromAtom(RecoilAtoms.configAtom)
Expand Down Expand Up @@ -162,7 +161,7 @@ let make = (
paymentMethodType
setRequiredFieldsBody
isSavedCardFlow=true
savedCards=savedMethods
savedMethod=paymentItem
/>
<Surcharge
list
Expand Down
1 change: 0 additions & 1 deletion src/Components/SavedMethods.res
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ let make = (
cvcProps
paymentType
list
savedMethods
setRequiredFieldsBody
/>
})
Expand Down
5 changes: 0 additions & 5 deletions src/PaymentElement.res
Original file line number Diff line number Diff line change
Expand Up @@ -388,11 +388,6 @@ let make = (
</ErrorBoundary>
}

React.useEffect(() => {
setShowFields(_ => !displaySavedPaymentMethods)
None
}, [displaySavedPaymentMethods])

let paymentLabel = if displaySavedPaymentMethods {
showFields
? optionAtomValue.paymentMethodsHeaderText
Expand Down
12 changes: 2 additions & 10 deletions src/Types/PaymentType.res
Original file line number Diff line number Diff line change
Expand Up @@ -974,14 +974,6 @@ let itemToObjMapper = (dict, logger) => {

type loadType = Loading | Loaded(JSON.t) | SemiLoaded | LoadError(JSON.t)

let getIsAllStoredCardsHaveName = (savedCards: array<customerMethods>) => {
savedCards
->Array.filter(savedCard => {
switch savedCard.card.cardHolderName {
| None
| Some("") => false
| _ => true
}
})
->Array.length === savedCards->Array.length
let getIsStoredPaymentMethodHasName = (savedMethod: customerMethods) => {
savedMethod.card.cardHolderName->Option.getOr("")->String.length > 0
}
Loading