Skip to content

Commit

Permalink
chore: comments addressed
Browse files Browse the repository at this point in the history
  • Loading branch information
PritishBudhiraja committed Sep 3, 2024
1 parent ca29826 commit 2999f22
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/Payments/PreMountLoader.res
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ module PreMountLoaderForElements = {
)

let messageHandler = (ev: Window.event) => {
let json = ev.data->Utils.safeParse
let dict = json->Utils.getDictFromJson
if dict->Dict.get("sendPaymentMethodsResponse")->Option.isSome {
open Utils
let dict = ev.data->safeParse->getDictFromJson
if dict->isKeyPresentInDict("sendPaymentMethodsResponse") {
paymentMethodsPromise->sendPromiseData("payment_methods")
} else if dict->Dict.get("sendCustomerPaymentMethodsResponse")->Option.isSome {
} else if dict->isKeyPresentInDict("sendCustomerPaymentMethodsResponse") {
customerPaymentMethodsPromise->sendPromiseData("customer_payment_methods")
} else if dict->Dict.get("sendSessionTokensResponse")->Option.isSome {
} else if dict->isKeyPresentInDict("sendSessionTokensResponse") {
sessionTokensPromise->sendPromiseData("session_tokens")
}
}
Expand All @@ -88,9 +88,9 @@ module PreMountLoaderForPMMElements = {
)

let messageHandler = (ev: Window.event) => {
let json = ev.data->Utils.safeParse
let dict = json->Utils.getDictFromJson
if dict->Dict.get("sendSavedPaymentMethodsResponse")->Option.isSome {
open Utils
let dict = ev.data->safeParse->getDictFromJson
if dict->isKeyPresentInDict("sendSavedPaymentMethodsResponse") {
savedPaymentMethodsPromise->sendPromiseData("saved_payment_methods")
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/Utilities/Utils.res
Original file line number Diff line number Diff line change
Expand Up @@ -1372,3 +1372,5 @@ let getFirstAndLastNameFromFullName = fullName => {

(firstName, lastNameJson)
}

let isKeyPresentInDict = (dict, key) => dict->Dict.get(key)->Option.isSome

0 comments on commit 2999f22

Please sign in to comment.