From 2d918ecb78ff069ebfbf4e964bd7183127e50e2b Mon Sep 17 00:00:00 2001 From: Saksham Sharma Date: Tue, 6 Aug 2024 14:25:25 +0530 Subject: [PATCH] fix: comments addressed --- src/Hooks/UtilityHooks.res | 6 +++--- src/Utilities/Utils.res | 6 +++++- src/orca-loader/Elements.res | 2 +- src/orca-loader/Hyper.res | 8 ++++---- src/orca-loader/LoaderPaymentElement.res | 5 +++-- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/Hooks/UtilityHooks.res b/src/Hooks/UtilityHooks.res index fc1a6f787..722000f08 100644 --- a/src/Hooks/UtilityHooks.res +++ b/src/Hooks/UtilityHooks.res @@ -13,9 +13,9 @@ let useIsGuestCustomer = () => { let useHandlePostMessages = (~complete, ~empty, ~paymentType, ~savedMethod=false) => { open RecoilAtoms - let loggerState = Recoil.useRecoilValueFromAtom(RecoilAtoms.loggerAtom) - let setIsPayNowButtonDisable = RecoilAtoms.payNowButtonDisable->Recoil.useSetRecoilState - let {sdkHandleConfirmPayment} = optionAtom->Recoil.useRecoilValueFromAtom + let loggerState = Recoil.useRecoilValueFromAtom(loggerAtom) + let setIsPayNowButtonDisable = Recoil.useSetRecoilState(payNowButtonDisable) + let {sdkHandleConfirmPayment} = Recoil.useRecoilValueFromAtom(optionAtom) React.useEffect(() => { if !sdkHandleConfirmPayment.allowButtonBeforeValidation { diff --git a/src/Utilities/Utils.res b/src/Utilities/Utils.res index 4b2684fb7..0c29f89f1 100644 --- a/src/Utilities/Utils.res +++ b/src/Utilities/Utils.res @@ -918,10 +918,14 @@ let getStringFromOptionalJson = (json, default) => { json->Option.flatMap(JSON.Decode.string)->Option.getOr(default) } -let getBoolFromJson = (json, default) => { +let getBoolFromOptionalJson = (json, default) => { json->Option.flatMap(JSON.Decode.bool)->Option.getOr(default) } +let getBoolFromJson = (json, default) => { + json->JSON.Decode.bool->Option.getOr(default) +} + let getOptionalJson = (json, str) => { json ->JSON.Decode.object diff --git a/src/orca-loader/Elements.res b/src/orca-loader/Elements.res index acc9859ec..229d27ed9 100644 --- a/src/orca-loader/Elements.res +++ b/src/orca-loader/Elements.res @@ -877,7 +877,7 @@ let make = ( let gpayClicked = evJson ->getOptionalJsonFromJson("GpayClicked") - ->getBoolFromJson(false) + ->getBoolFromOptionalJson(false) let paymentDataRequest = evJson diff --git a/src/orca-loader/Hyper.res b/src/orca-loader/Hyper.res index abbe7caa2..4479412ca 100644 --- a/src/orca-loader/Hyper.res +++ b/src/orca-loader/Hyper.res @@ -317,15 +317,15 @@ let make = (publishableKey, options: option, analyticsInfo: optionJSON.Decode.bool->Option.getOr(false)) { + if !(val->getBoolFromJson(false)) { resolve1(json) } else { resolve1(data) Window.replace(returnUrl) } - } else if val->JSON.Decode.bool->Option.getOr(false) && redirect === "always" { + } else if val->getBoolFromJson(false) && redirect === "always" { Window.replace(returnUrl) - } else if !(val->JSON.Decode.bool->Option.getOr(false)) { + } else if !(val->getBoolFromJson(false)) { resolve1(json) } else { resolve1(data) @@ -500,7 +500,7 @@ let make = (publishableKey, options: option, analyticsInfo: optiongetString("return_url", "/") - if val->JSON.Decode.bool->Option.getOr(false) && url !== "/" { + if val->getBoolFromJson(false) && url !== "/" { Window.replace(url) } else { resolve(json) diff --git a/src/orca-loader/LoaderPaymentElement.res b/src/orca-loader/LoaderPaymentElement.res index 2ebf59448..7c6bdf2bc 100644 --- a/src/orca-loader/LoaderPaymentElement.res +++ b/src/orca-loader/LoaderPaymentElement.res @@ -195,7 +195,8 @@ let make = ( | None => () } - let isCopy = eventDataObject->getOptionalJsonFromJson("copy")->getBoolFromJson(false) + let isCopy = + eventDataObject->getOptionalJsonFromJson("copy")->getBoolFromOptionalJson(false) let text = eventDataObject->getOptionalJsonFromJson("copyDetails")->getStringFromOptionalJson("") if isCopy { @@ -235,7 +236,7 @@ let make = ( eventDataObject->getOptionalJsonFromJson("iframeId")->getStringFromOptionalJson("") if fullscreenIframe->Option.isSome { - fullscreen := fullscreenIframe->getBoolFromJson(false) + fullscreen := fullscreenIframe->getBoolFromOptionalJson(false) fullscreenParam := param->getStringFromOptionalJson("") fullscreenMetadata := metadata