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

refactor: sdk pay now always enabled #567

Merged
merged 7 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 0 additions & 4 deletions src/Components/PayNowButton.res
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ let make = () => {
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
Expand Down
6 changes: 0 additions & 6 deletions src/Hooks/UtilityHooks.res
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
3 changes: 0 additions & 3 deletions src/TabCard.res
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand All @@ -17,7 +15,6 @@ let make = (~paymentOption: PaymentMethodsRecord.paymentFieldsInfo, ~isActive: b
paymentOption.icon,
)
let onClick = _ => {
setIsPayNowButtonDisable(_ => !sdkHandleConfirmPayment.allowButtonBeforeValidation)
setSelectedOption(_ => paymentOption.paymentMethodName)
}
<button
Expand Down
2 changes: 1 addition & 1 deletion src/Utilities/RecoilAtoms.res
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ let paymentTokenAtom = Recoil.atom(
let showCardFieldsAtom = Recoil.atom("showCardFields", false)
let phoneJson = Recoil.atom("phoneJson", Loading)
let cardBrand = Recoil.atom("cardBrand", "")
let payNowButtonDisable = Recoil.atom("payNowButtonDisable", true)
let payNowButtonDisable = Recoil.atom("payNowButtonDisable", false)
PritishBudhiraja marked this conversation as resolved.
Show resolved Hide resolved
let paymentMethodCollectOptionAtom = Recoil.atom(
"paymentMethodCollectOptions",
PaymentMethodCollectUtils.defaultPaymentMethodCollectOptions,
Expand Down
Loading