Skip to content

Commit

Permalink
fix: comments addressed
Browse files Browse the repository at this point in the history
  • Loading branch information
Saksham Sharma authored and Saksham Sharma committed Aug 6, 2024
1 parent 056dde8 commit 2d918ec
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/Hooks/UtilityHooks.res
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 5 additions & 1 deletion src/Utilities/Utils.res
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/orca-loader/Elements.res
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,7 @@ let make = (
let gpayClicked =
evJson
->getOptionalJsonFromJson("GpayClicked")
->getBoolFromJson(false)
->getBoolFromOptionalJson(false)

let paymentDataRequest =
evJson
Expand Down
8 changes: 4 additions & 4 deletions src/orca-loader/Hyper.res
Original file line number Diff line number Diff line change
Expand Up @@ -317,15 +317,15 @@ let make = (publishableKey, options: option<JSON.t>, analyticsInfo: option<JSON.
postSubmitMessage(dict)

if isSdkButton {
if !(val->JSON.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)
Expand Down Expand Up @@ -500,7 +500,7 @@ let make = (publishableKey, options: option<JSON.t>, analyticsInfo: option<JSON.
~eventName=CONFIRM_CARD_PAYMENT,
)
let url = decodedData->getString("return_url", "/")
if val->JSON.Decode.bool->Option.getOr(false) && url !== "/" {
if val->getBoolFromJson(false) && url !== "/" {
Window.replace(url)
} else {
resolve(json)
Expand Down
5 changes: 3 additions & 2 deletions src/orca-loader/LoaderPaymentElement.res
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2d918ec

Please sign in to comment.