diff --git a/src/Components/DynamicFields.res b/src/Components/DynamicFields.res index bafd1a6e8..343b2896d 100644 --- a/src/Components/DynamicFields.res +++ b/src/Components/DynamicFields.res @@ -7,7 +7,7 @@ let make = ( ~paymentMethodType, ~setRequiredFieldsBody, ~isSavedCardFlow=false, - ~savedCards=[]: array, + ~savedMethod=PaymentType.defaultCustomerMethods, ~cardProps=None, ~expiryProps=None, ~cvcProps=None, @@ -46,8 +46,8 @@ let make = ( }, [requiredFieldsWithBillingDetails]) let isAllStoredCardsHaveName = React.useMemo1(() => { - PaymentType.getIsAllStoredCardsHaveName(savedCards) - }, [savedCards]) + PaymentType.getIsStoredPaymentMethodHasName(savedMethod) + }, [savedMethod]) //<...>// let fieldsArr = React.useMemo3(() => { diff --git a/src/Components/SavedCardItem.res b/src/Components/SavedCardItem.res index 9dff89ff1..88cb94861 100644 --- a/src/Components/SavedCardItem.res +++ b/src/Components/SavedCardItem.res @@ -9,7 +9,6 @@ let make = ( ~cvcProps, ~paymentType, ~list, - ~savedMethods, ~setRequiredFieldsBody, ) => { let {themeObj, config} = Recoil.useRecoilValueFromAtom(RecoilAtoms.configAtom) @@ -162,7 +161,7 @@ let make = ( paymentMethodType setRequiredFieldsBody isSavedCardFlow=true - savedCards=savedMethods + savedMethod=paymentItem /> }) diff --git a/src/PaymentElement.res b/src/PaymentElement.res index 2a2a87a4d..b38b99f62 100644 --- a/src/PaymentElement.res +++ b/src/PaymentElement.res @@ -388,11 +388,6 @@ let make = ( } - React.useEffect(() => { - setShowFields(_ => !displaySavedPaymentMethods) - None - }, [displaySavedPaymentMethods]) - let paymentLabel = if displaySavedPaymentMethods { showFields ? optionAtomValue.paymentMethodsHeaderText diff --git a/src/Types/PaymentType.res b/src/Types/PaymentType.res index 7b031ebf1..98fc092a7 100644 --- a/src/Types/PaymentType.res +++ b/src/Types/PaymentType.res @@ -974,14 +974,6 @@ let itemToObjMapper = (dict, logger) => { type loadType = Loading | Loaded(JSON.t) | SemiLoaded | LoadError(JSON.t) -let getIsAllStoredCardsHaveName = (savedCards: array) => { - 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 }