From 726dc0630a1d040e61f4bdecad6cef14f97a46d4 Mon Sep 17 00:00:00 2001 From: sakksham7 <130480324+sakksham7@users.noreply.github.com> Date: Thu, 22 Aug 2024 11:32:51 +0530 Subject: [PATCH] refactor: sdk pay now always enabled (#567) Co-authored-by: Saksham Sharma Co-authored-by: Pritish Budhiraja --- src/Components/PayNowButton.res | 6 +----- src/Hooks/UtilityHooks.res | 6 ------ src/TabCard.res | 3 --- src/Types/PaymentType.res | 3 --- src/Utilities/RecoilAtoms.res | 1 - 5 files changed, 1 insertion(+), 18 deletions(-) diff --git a/src/Components/PayNowButton.res b/src/Components/PayNowButton.res index 5c043baff..eb2207f50 100644 --- a/src/Components/PayNowButton.res +++ b/src/Components/PayNowButton.res @@ -14,17 +14,13 @@ let make = () => { open RecoilAtoms open Utils let (showLoader, setShowLoader) = React.useState(() => false) + let (isPayNowButtonDisable, setIsPayNowButtonDisable) = React.useState(() => false) let {themeObj, localeString} = configAtom->Recoil.useRecoilValueFromAtom let {sdkHandleConfirmPayment} = optionAtom->Recoil.useRecoilValueFromAtom - let (isPayNowButtonDisable, setIsPayNowButtonDisable) = payNowButtonDisable->Recoil.useRecoilState let confirmPayload = sdkHandleConfirmPayment->PaymentBody.confirmPayloadForSDKButton let buttonText = sdkHandleConfirmPayment.buttonText->Option.getOr(localeString.payNowButton) - React.useEffect1(() => { - setIsPayNowButtonDisable(_ => !sdkHandleConfirmPayment.allowButtonBeforeValidation) - None - }, [sdkHandleConfirmPayment.allowButtonBeforeValidation]) let handleMessage = (event: Types.event) => { let json = event.data->Identity.anyTypeToJson->getStringFromJson("")->safeParse diff --git a/src/Hooks/UtilityHooks.res b/src/Hooks/UtilityHooks.res index 722000f08..09a4ef605 100644 --- a/src/Hooks/UtilityHooks.res +++ b/src/Hooks/UtilityHooks.res @@ -14,14 +14,8 @@ let useHandlePostMessages = (~complete, ~empty, ~paymentType, ~savedMethod=false open RecoilAtoms let loggerState = Recoil.useRecoilValueFromAtom(loggerAtom) - let setIsPayNowButtonDisable = Recoil.useSetRecoilState(payNowButtonDisable) - let {sdkHandleConfirmPayment} = Recoil.useRecoilValueFromAtom(optionAtom) React.useEffect(() => { - if !sdkHandleConfirmPayment.allowButtonBeforeValidation { - let isCompletelyFilled = complete && paymentType !== "" - setIsPayNowButtonDisable(_ => !isCompletelyFilled) - } Utils.handlePostMessageEvents(~complete, ~empty, ~paymentType, ~loggerState, ~savedMethod) None }, (complete, empty, paymentType)) diff --git a/src/TabCard.res b/src/TabCard.res index 4d1dd7217..f9bf64793 100644 --- a/src/TabCard.res +++ b/src/TabCard.res @@ -4,8 +4,6 @@ let make = (~paymentOption: PaymentMethodsRecord.paymentFieldsInfo, ~isActive: b let {themeObj, localeString} = Recoil.useRecoilValueFromAtom(configAtom) let {readOnly, customMethodNames} = Recoil.useRecoilValueFromAtom(optionAtom) let setSelectedOption = Recoil.useSetRecoilState(selectedOptionAtom) - let {sdkHandleConfirmPayment} = optionAtom->Recoil.useRecoilValueFromAtom - let setIsPayNowButtonDisable = Recoil.useSetRecoilState(payNowButtonDisable) let (tabClass, tabLabelClass, tabIconClass) = React.useMemo( () => isActive ? ("Tab--selected", "TabLabel--selected", "TabIcon--selected") : ("", "", ""), [isActive], @@ -17,7 +15,6 @@ let make = (~paymentOption: PaymentMethodsRecord.paymentFieldsInfo, ~isActive: b paymentOption.icon, ) let onClick = _ => { - setIsPayNowButtonDisable(_ => !sdkHandleConfirmPayment.allowButtonBeforeValidation) setSelectedOption(_ => paymentOption.paymentMethodName) }