Skip to content

Commit

Permalink
fix: paypal issue for Ideal Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Pritish Budhiraja committed Apr 15, 2024
1 parent bb31a17 commit d2b75a4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/Components/DropdownField.res
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ let make = (
themeObj.colorBackground
}, [themeObj])
React.useEffect0(() => {
if value === "" {
if value === "" || !(options->Array.includes(value)) {
setValue(_ => options->Array.get(0)->Option.getOr(""))
}
None
Expand Down
29 changes: 16 additions & 13 deletions src/Payments/PaymentMethodsRecord.res
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,20 @@ let getPaymentMethodsFieldTypeFromString = (str, isBancontact) => {
}
}

let getOptionsFromPaymentMethodFieldType = (dict, key) => {
let options = dict->Utils.getArrayValFromJsonDict(key, "options")
switch options->Array.get(0)->Option.getOr("") {
| "" => None
| "ALL" => AddressCountry(Country.country->Array.map(item => item.countryName))
| _ =>
AddressCountry(
Country.country
->Array.filter(item => options->Array.includes(item.isoAlpha2))
->Array.map(item => item.countryName),
)
}
}

let getPaymentMethodsFieldTypeFromDict = dict => {
let keysArr = dict->Dict.keysToArray
let key = keysArr->Array.get(0)->Option.getOr("")
Expand All @@ -531,19 +545,8 @@ let getPaymentMethodsFieldTypeFromDict = dict => {
let options = dict->Utils.getArrayValFromJsonDict("user_currency", "options")
Currency(options)
}
| "user_address_country" => {
let options = dict->Utils.getArrayValFromJsonDict("user_address_country", "options")
switch options->Array.get(0)->Option.getOr("") {
| "" => None
| "ALL" => AddressCountry(Country.country->Array.map(item => item.countryName))
| _ =>
AddressCountry(
Country.country
->Array.filter(item => options->Array.includes(item.isoAlpha2))
->Array.map(item => item.countryName),
)
}
}
| "user_country" => dict->getOptionsFromPaymentMethodFieldType("user_country")
| "user_address_country" => dict->getOptionsFromPaymentMethodFieldType("user_address_country")
| _ => None
}
}
Expand Down

0 comments on commit d2b75a4

Please sign in to comment.