Skip to content

Commit

Permalink
Changes for multiple currency value
Browse files Browse the repository at this point in the history
  • Loading branch information
Riddhi Agrawal committed Nov 28, 2023
1 parent a11170a commit 5b2dbb7
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/screens/HyperSwitch/SDKPayment/SDKPage.res
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module SDKConfifiguarationFields = {
let dropDownOptions = HomeUtils.countries->Js.Array2.map((item): SelectBox.dropdownOption => {
{
label: `${item.countryName} (${item.currency})`,
value: item.currency,
value: `${item.countryName}-${item.currency}`,
}
})

Expand Down Expand Up @@ -44,7 +44,8 @@ module SDKConfifiguarationFields = {
(),
)
let selectCurrencyField = FormRenderer.makeFieldInfo(
~name="Currency",
~label="Currency",
~name="currency",
~placeholder="",
~customInput=InputFields.selectInput(
~options=dropDownOptions,
Expand All @@ -69,6 +70,7 @@ module SDKConfifiguarationFields = {
<FormRenderer.FieldRenderer field=selectCurrencyField fieldWrapperClass="!w-full" />
<FormRenderer.FieldRenderer field=enterAmountField fieldWrapperClass="!w-full" />
<FormRenderer.SubmitButton text="Show preview" />
<FormValuesSpy />
</>
}
}
Expand All @@ -87,7 +89,7 @@ let make = () => {

let initialDict =
[
("currency", "USD"->Js.Json.string),
("currency", "United States-USD"->Js.Json.string),
("amount", "100"->Js.Json.string),
("profile_id", defaultBusinessProfile.profile_id->Js.Json.string),
]->Js.Dict.fromArray
Expand Down Expand Up @@ -121,7 +123,15 @@ let make = () => {
open LogicUtils
let valueDict = values->getDictFromJsonObject
setKey(_ => Js.Date.now()->Js.Float.toString)
setCurrency(_ => valueDict->getString("currency", "USD"))

let currencyValue =
valueDict
->getString("currency", "United States-USD")
->Js.String2.split("-")
->Belt.Array.get(1)
->Belt.Option.getWithDefault("USD")
->Js.String2.trim
setCurrency(_ => currencyValue)
setAmount(_ =>
valueDict->getString("amount", "")->Belt.Int.fromString->Belt.Option.getWithDefault(100) * 100
)
Expand Down

0 comments on commit 5b2dbb7

Please sign in to comment.