= "%identity"
-external asJson: 'a => ReactEvent.Form.t = "%identity"
module RadioSection = {
open ConnectorTypes
@@ -26,7 +25,7 @@ module RadioSection = {
| ActionType => paymentMethodTypeInfo.action = option
}
- setConfigJson(frmConfigs->asJson)
+ setConfigJson(frmConfigs->Identity.anyTypeToReactEvent)
}
@@ -147,7 +146,7 @@ module CheckBoxRenderer = {
_ => {
frmConfigInfo.payment_methods = []
setIsOpen(_ => !isOpen)
- setConfigJson(frmConfigs->asJson)
+ setConfigJson(frmConfigs->Identity.anyTypeToReactEvent)
}
},
},
@@ -166,7 +165,7 @@ module CheckBoxRenderer = {
switch connectorPaymentMethods {
| Some(paymentMethods) => {
frmConfigInfo.payment_methods = paymentMethods->generateFRMPaymentMethodsConfig
- setConfigJson(frmConfigs->asJson)
+ setConfigJson(frmConfigs->Identity.anyTypeToReactEvent)
}
| _ => ()
}
@@ -176,7 +175,7 @@ module CheckBoxRenderer = {
showConfitmation()
} else {
frmConfigInfo.payment_methods = []
- setConfigJson(frmConfigs->asJson)
+ setConfigJson(frmConfigs->Identity.anyTypeToReactEvent)
setIsOpen(_ => !isOpen)
}
}
@@ -188,7 +187,7 @@ module CheckBoxRenderer = {
switch connectorPaymentMethods {
| Some(paymentMethods) => {
frmConfigInfo.payment_methods = paymentMethods->generateFRMPaymentMethodsConfig
- setConfigJson(frmConfigs->asJson)
+ setConfigJson(frmConfigs->Identity.anyTypeToReactEvent)
}
| _ => ()
}
@@ -298,7 +297,7 @@ module PaymentMethodsRenderer = {
})
setConnectorConfig(_ => connectorsConfig)
- setConfigJson(updateFRMConfig->asJson)
+ setConfigJson(updateFRMConfig->Identity.anyTypeToReactEvent)
setPageState(_ => Success)
} catch {
| _ => setPageState(_ => Error("Failed to fetch"))
diff --git a/src/screens/HyperSwitch/Home/HomeUtils.res b/src/screens/HyperSwitch/Home/HomeUtils.res
index c4eb737dd..6a8e17293 100644
--- a/src/screens/HyperSwitch/Home/HomeUtils.res
+++ b/src/screens/HyperSwitch/Home/HomeUtils.res
@@ -1,4 +1,3 @@
-external formEventToStr: ReactEvent.Form.t => string = "%identity"
open CardUtils
open PageUtils
open HSwitchUtils
diff --git a/src/screens/HyperSwitch/RoutingRevamp/AddRuleGateway.res b/src/screens/HyperSwitch/RoutingRevamp/AddRuleGateway.res
index 63effeb51..c662025a3 100644
--- a/src/screens/HyperSwitch/RoutingRevamp/AddRuleGateway.res
+++ b/src/screens/HyperSwitch/RoutingRevamp/AddRuleGateway.res
@@ -1,7 +1,4 @@
-external arrToReactEvent: array => ReactEvent.Form.t = "%identity"
-external toReactEvent: 'a => ReactEvent.Form.t = "%identity"
external formEventToStrArr: ReactEvent.Form.t => array = "%identity"
-external formEventToStr: ReactEvent.Form.t => string = "%identity"
external toJson: 'a => Js.Json.t = "%identity"
external anyToEnum: 'a => AdvancedRoutingTypes.connectorSelectionData = "%identity"
@@ -22,7 +19,7 @@ let make = (~id, ~gatewayOptions, ~isFirst=false, ~isExpanded=false) => {
} else {
"priority"
}
- gateWaysType.onChange(typeString->toReactEvent)
+ gateWaysType.onChange(typeString->Identity.anyTypeToReactEvent)
None
}, [isDistributeInput.value])
@@ -42,7 +39,7 @@ let make = (~id, ~gatewayOptions, ~isFirst=false, ~isExpanded=false) => {
let newSelectedOptions = ev->formEventToStrArr
if newSelectedOptions->Js.Array2.length === 0 {
- gateWaysInput.onChange([]->toReactEvent)
+ gateWaysInput.onChange([]->Identity.anyTypeToReactEvent)
} else {
let gatewaysArr = newSelectedOptions->Js.Array2.map(item => {
open AdvancedRoutingTypes
@@ -67,7 +64,7 @@ let make = (~id, ~gatewayOptions, ~isFirst=false, ~isExpanded=false) => {
}->toJson
}
})
- gateWaysInput.onChange(gatewaysArr->toReactEvent)
+ gateWaysInput.onChange(gatewaysArr->Identity.anyTypeToReactEvent)
}
},
onFocus: _ev => (),
@@ -106,7 +103,7 @@ let make = (~id, ~gatewayOptions, ~isFirst=false, ~isExpanded=false) => {
| VolumeObject(obj) => obj.connector->toJson
}
})
- gateWaysInput.onChange(gatewaysArr->toReactEvent)
+ gateWaysInput.onChange(gatewaysArr->Identity.anyTypeToReactEvent)
}
let updatePercentage = (item: AdvancedRoutingTypes.connectorSelectionData, value) => {
@@ -134,7 +131,7 @@ let make = (~id, ~gatewayOptions, ~isFirst=false, ~isExpanded=false) => {
}->toJson
}
})
- gateWaysInput.onChange(newList->toReactEvent)
+ gateWaysInput.onChange(newList->Identity.anyTypeToReactEvent)
}
}
@@ -145,7 +142,7 @@ let make = (~id, ~gatewayOptions, ~isFirst=false, ~isExpanded=false) => {
AdvancedRoutingUtils.getConnectorStringFromConnectorSelectionData(i).merchant_connector_id
)
->Array.filterWithIndex((_, i) => i !== index)
- ->toReactEvent,
+ ->Identity.anyTypeToReactEvent,
)
}
@@ -234,7 +231,7 @@ let make = (~id, ~gatewayOptions, ~isFirst=false, ~isExpanded=false) => {
{
- isDistributeInput.onChange(v->toReactEvent)
+ isDistributeInput.onChange(v->Identity.anyTypeToReactEvent)
onClickDistribute(v)
}}
isDisabled=false
diff --git a/src/screens/HyperSwitch/RoutingRevamp/AdvancedRouting.res b/src/screens/HyperSwitch/RoutingRevamp/AdvancedRouting.res
index 3ce8c81c7..7c93e1a4e 100644
--- a/src/screens/HyperSwitch/RoutingRevamp/AdvancedRouting.res
+++ b/src/screens/HyperSwitch/RoutingRevamp/AdvancedRouting.res
@@ -3,7 +3,6 @@ open AdvancedRoutingTypes
open AdvancedRoutingUtils
open LogicUtils
-external toForm: string => ReactEvent.Form.t = "%identity"
external toJson: 'a => Js.Json.t = "%identity"
external arrToFormEvent: array<'a> => ReactEvent.Form.t = "%identity"
external toWasm: Js.Dict.t => RoutingTypes.wasmModule = "%identity"
@@ -124,7 +123,7 @@ module Wrapper = {
}
React.useEffect0(() => {
- name.onChange(heading->Js.String2.toLowerCase->titleToSnake->toForm)
+ name.onChange(heading->Js.String2.toLowerCase->titleToSnake->Identity.stringToFormReactEvent)
let gatewayArrPresent = gateWaysInput.value->getArrayFromJson([])->Js.Array2.length > 0
diff --git a/src/screens/HyperSwitch/RoutingRevamp/AdvancedRoutingUIUtils.res b/src/screens/HyperSwitch/RoutingRevamp/AdvancedRoutingUIUtils.res
index 28e1d3092..2b5db95f3 100644
--- a/src/screens/HyperSwitch/RoutingRevamp/AdvancedRoutingUIUtils.res
+++ b/src/screens/HyperSwitch/RoutingRevamp/AdvancedRoutingUIUtils.res
@@ -3,9 +3,7 @@ open AdvancedRoutingUtils
open FormRenderer
external arrToFormEvent: array<'a> => ReactEvent.Form.t = "%identity"
-external toForm: 'a => ReactEvent.Form.t = "%identity"
external strToFormEvent: Js.String.t => ReactEvent.Form.t = "%identity"
-external formEventToStr: ReactEvent.Form.t => string = "%identity"
external formEventToStrArr: ReactEvent.Form.t => array = "%identity"
module LogicalOps = {
@@ -55,8 +53,8 @@ module OperatorInp = {
name: "string",
onBlur: _ev => (),
onChange: ev => {
- let value = ev->formEventToStr
- operator.onChange(value->toForm)
+ let value = ev->Identity.formReactEventToString
+ operator.onChange(value->Identity.anyTypeToReactEvent)
},
onFocus: _ev => (),
value: operator.value,
@@ -74,7 +72,7 @@ module OperatorInp = {
setOpVals(_ => operatorVals)
if operator.value->Js.Json.decodeString->Belt.Option.isNone {
- operator.onChange(operatorVals[0]->toForm)
+ operator.onChange(operatorVals[0]->Identity.anyTypeToReactEvent)
}
None
}, (field.value, valInp.value))
@@ -139,7 +137,7 @@ module ValueInp = {
| NOT_CONTAINS => "enum_variant_array"
| _ => "number"
}
- }->toForm,
+ }->Identity.anyTypeToReactEvent,
)
None
}, [valueField.value])
@@ -149,7 +147,7 @@ module ValueInp = {
onBlur: _ev => (),
onChange: ev => {
let value = ev->formEventToStrArr
- valueField.onChange(value->toForm)
+ valueField.onChange(value->Identity.anyTypeToReactEvent)
},
onFocus: _ev => (),
value: valueField.value,
@@ -209,12 +207,12 @@ module MetadataInp = {
})
let finalVal = Js.Array2.joinWith(arrStr, ",")->Js.Json.string
- valueField.onChange(finalVal->toForm)
+ valueField.onChange(finalVal->Identity.anyTypeToReactEvent)
},
onChange: ev => {
let target = ReactEvent.Form.target(ev)
let value = target["value"]
- valueField.onChange(value->toForm)
+ valueField.onChange(value->Identity.anyTypeToReactEvent)
},
onFocus: _ev => (),
value: valueField.value,
@@ -295,11 +293,11 @@ module FieldInp = {
name: "string",
onBlur: _ev => (),
onChange: ev => {
- let value = ev->formEventToStr
+ let value = ev->Identity.formReactEventToString
onChangeMethod(value)
- field.onChange(value->toForm)
- op.onChange(""->toForm)
- val.onChange(""->toForm)
+ field.onChange(value->Identity.anyTypeToReactEvent)
+ op.onChange(""->Identity.anyTypeToReactEvent)
+ val.onChange(""->Identity.anyTypeToReactEvent)
},
onFocus: _ev => (),
value: field.value,
diff --git a/src/screens/HyperSwitch/RoutingRevamp/BasicDetailsForm.res b/src/screens/HyperSwitch/RoutingRevamp/BasicDetailsForm.res
index 647bc5b71..ab7949efb 100644
--- a/src/screens/HyperSwitch/RoutingRevamp/BasicDetailsForm.res
+++ b/src/screens/HyperSwitch/RoutingRevamp/BasicDetailsForm.res
@@ -2,9 +2,6 @@ open FormRenderer
open LogicUtils
open AdvancedRoutingTypes
-external fromFormEvent: ReactEvent.Form.t => 'a = "%identity"
-external formEventToStr: ReactEvent.Form.t => string = "%identity"
-
let configurationNameInput = makeFieldInfo(
~label="Configuration Name",
~name="name",
@@ -43,7 +40,7 @@ module BusinessProfileInp = {
value: profile->Js.Json.string,
onChange: {
ev => {
- setProfile(_ => ev->formEventToStr)
+ setProfile(_ => ev->Identity.formReactEventToString)
input.onChange(ev)
}
},
diff --git a/src/screens/HyperSwitch/SDKPayment/SDKPage.res b/src/screens/HyperSwitch/SDKPayment/SDKPage.res
index 2e37537e2..fe9300e49 100644
--- a/src/screens/HyperSwitch/SDKPayment/SDKPage.res
+++ b/src/screens/HyperSwitch/SDKPayment/SDKPage.res
@@ -1,6 +1,5 @@
let h3Leading2Style = HSwitchUtils.getTextClass(~textVariant=H3, ~h3TextVariant=Leading_2, ())
external toJson: 'a => Js.Json.t = "%identity"
-external formEventToStr: ReactEvent.Form.t => string = "%identity"
external strToFormEvent: Js.String.t => ReactEvent.Form.t = "%identity"
module SDKConfiguarationFields = {
@@ -55,7 +54,8 @@ module SDKConfiguarationFields = {
value: (initialValues.amount / 100)->string_of_int->Js.Json.string,
onChange: {
ev => {
- let eventValueToInt = ev->formEventToStr->LogicUtils.getIntFromString(0)
+ let eventValueToInt =
+ ev->Identity.formReactEventToString->LogicUtils.getIntFromString(0)
let valInCents = (eventValueToInt * 100)->string_of_int->strToFormEvent
input.onChange(valInCents)
}
diff --git a/src/screens/HyperSwitch/SelfServe/HSwitchSandboxOnboarding/UserOnboardingUIUtils.res b/src/screens/HyperSwitch/SelfServe/HSwitchSandboxOnboarding/UserOnboardingUIUtils.res
index e54d0211f..d07bd6a18 100644
--- a/src/screens/HyperSwitch/SelfServe/HSwitchSandboxOnboarding/UserOnboardingUIUtils.res
+++ b/src/screens/HyperSwitch/SelfServe/HSwitchSandboxOnboarding/UserOnboardingUIUtils.res
@@ -1,4 +1,3 @@
-external formEventToStr: ReactEvent.Form.t => string = "%identity"
open UserOnboardingTypes
open UserOnboardingUtils
@@ -284,7 +283,7 @@ module BackendFrontendPlatformLangDropDown = {
name: "Platform Selecr",
onBlur: _ev => (),
onChange: ev => {
- let val = ev->formEventToStr->getPlatform
+ let val = ev->Identity.formReactEventToString->getPlatform
setPlatform(_ => val)
hyperswitchMixPanel(~pageName=urlHead, ~contextName, ~actionName={(val :> string)}, ())
},
@@ -300,7 +299,7 @@ module BackendFrontendPlatformLangDropDown = {
name: "BackEnd",
onBlur: _ev => (),
onChange: ev => {
- let val = ev->formEventToStr->getLangauge
+ let val = ev->Identity.formReactEventToString->getLangauge
setBackEndLang(_ => val)
hyperswitchMixPanel(~pageName=urlHead, ~contextName, ~actionName={(val :> string)}, ())
},
@@ -312,7 +311,7 @@ module BackendFrontendPlatformLangDropDown = {
name: "FrontEnd",
onBlur: _ev => (),
onChange: ev => {
- let val = ev->formEventToStr->getLangauge
+ let val = ev->Identity.formReactEventToString->getLangauge
setFrontEndLang(_ => val)
hyperswitchMixPanel(~pageName=urlHead, ~contextName, ~actionName={(val :> string)}, ())
},
diff --git a/src/screens/analyticsScreens/AnalyticsCommonComponents.res b/src/screens/analyticsScreens/AnalyticsCommonComponents.res
index bde445c44..8e20b3751 100644
--- a/src/screens/analyticsScreens/AnalyticsCommonComponents.res
+++ b/src/screens/analyticsScreens/AnalyticsCommonComponents.res
@@ -1,11 +1,10 @@
external toString: option => string = "%identity"
external convertToStrDict: 't => Js.Json.t = "%identity"
-external evToString: ReactEvent.Form.t => string = "%identity"
external objToJson: {..} => Js.Json.t = "%identity"
external toJson: exn => Js.Json.t = "%identity"
external toRespJson: Fetch.Response.t => Js.Json.t = "%identity"
@get external keyCode: 'a => int = "keyCode"
-external formEventToStr: ReactEvent.Form.t => string = "%identity"
+
type window
@val external window: window = "window"
@scope("window") @val external parent: window = "parent"
@@ -348,7 +347,7 @@ module AnalyticsSaveViewNew = {
name: "savedView",
onBlur: _ev => (),
onChange: ev => {
- let appliedVal = ev->formEventToStr
+ let appliedVal = ev->Identity.formReactEventToString
if appliedVal === "baseView" {
updateExistingKeys(defaultSearchDict)
setAppliedSaveView(_ => SaveViewEntity.defaultSaveView)
@@ -1305,7 +1304,7 @@ module SankeyWithDropDown = {
onBlur: _ev => (),
onChange: ev => {
setSankeyCardinality(_ => {
- ev->formEventToStr->Belt.Int.fromString->Belt.Option.getWithDefault(5)
+ ev->Identity.formReactEventToString->Belt.Int.fromString->Belt.Option.getWithDefault(5)
})
},
onFocus: _ev => (),
@@ -1651,7 +1650,7 @@ module ErrorOnCellClick = {
let modalInput: ReactFinalForm.fieldRenderPropsInput = {
name: "modalInput",
onBlur: _ev => (),
- onChange: ev => renderModalChart(ev->evToString),
+ onChange: ev => renderModalChart(ev->Identity.formReactEventToString),
onFocus: _ev => (),
value: ""->Js.Json.string,
checked: true,
diff --git a/src/screens/login/HSwitchLoginFlow/HyperSwitchAuthUtils.res b/src/screens/login/HSwitchLoginFlow/HyperSwitchAuthUtils.res
index 8e2c7905a..3b8e7ccdc 100644
--- a/src/screens/login/HSwitchLoginFlow/HyperSwitchAuthUtils.res
+++ b/src/screens/login/HSwitchLoginFlow/HyperSwitchAuthUtils.res
@@ -1,5 +1,4 @@
open HyperSwitchAuthTypes
-external formEventToStr: ReactEvent.Form.t => string = "%identity"
module TermsAndCondition = {
@react.component
diff --git a/src/utils/JsonFlattenUtils.res b/src/utils/JsonFlattenUtils.res
index a7f398088..e4c5fbef0 100644
--- a/src/utils/JsonFlattenUtils.res
+++ b/src/utils/JsonFlattenUtils.res
@@ -1,5 +1,3 @@
-external toNullable: Js.Json.t => Js.Nullable.t = "%identity"
-
let rec flattenObject = (obj, addIndicatorForObject) => {
let newDict = Js.Dict.empty()
switch obj->Js.Json.decodeObject {
@@ -9,7 +7,7 @@ let rec flattenObject = (obj, addIndicatorForObject) => {
->Js.Array2.forEach(entry => {
let (key, value) = entry
- if value->toNullable->Js.Nullable.isNullable {
+ if value->Identity.jsonToNullableJson->Js.Nullable.isNullable {
Js.Dict.set(newDict, key, value)
} else {
switch value->Js.Json.decodeObject {
From 9e3aec7f7434cf4610db50a716653e73693aec94 Mon Sep 17 00:00:00 2001
From: Pritish Budhiraja <77892330+PritishBudhiraja@users.noreply.github.com>
Date: Mon, 11 Dec 2023 18:13:29 +0530
Subject: [PATCH 04/15] feat: Identity file changes in Codebase. (#89)
---
.../HighchartHorizontalBarChart.res | 3 +-
.../CustomCharts/HighchartPieChart.res | 3 +-
.../CustomCharts/HighchartTimeSeriesChart.res | 35 +++++++++----------
src/components/CustomExpandableTable.res | 2 +-
src/components/DynamicTableUtils.res | 5 ++-
src/components/LocalFilters.res | 4 +--
src/components/RemoteFilter.res | 4 +--
src/components/SelectModal.res | 4 +--
src/components/Table.res | 2 +-
src/components/Table.resi | 2 --
src/components/TableUtils.res | 1 -
src/components/TableUtils.resi | 1 -
src/components/form/SelectBoxCard.res | 3 +-
.../priority-logics/AddPLGateway.res | 3 +-
.../priority-logics/PriorityLogicUtils.res | 2 --
src/entities/analytics/IntegrationsEntity.res | 1 -
src/genericUtils/DOMUtils.res | 9 -----
src/genericUtils/Identity.res | 6 ++++
src/hooks/AuthHooks.res | 8 ++---
src/libraries/Jose.res | 2 +-
.../HyperSwitch/Analytics/Analytics.res | 1 -
.../Analytics/DownloadReportModal.res | 6 ++--
.../Analytics/HSAnalyticsUtils.res | 3 +-
.../Connectors/ConnectorAccountDetails.res | 2 --
.../FraudAndRisk/FRMIntegrationFields.res | 4 +--
.../FraudAndRisk/FRMPaymentMethods.res | 4 +--
.../HyperSwitch/FraudAndRisk/FRMUtils.res | 2 --
src/screens/HyperSwitch/HSwitchUtils.res | 1 -
.../HyperSwitch/Order/OrderUIUtils.res | 3 +-
.../HyperSwitch/Refunds/RefundUtils.res | 3 +-
.../HyperSwitch/Routing/RoutingStack.res | 1 -
.../RoutingRevamp/AddRuleGateway.res | 16 ++++-----
.../RoutingRevamp/AdvancedRouting.res | 11 +++---
.../RoutingRevamp/AdvancedRoutingUIUtils.res | 3 +-
.../RoutingRevamp/AdvancedRoutingUtils.res | 4 +--
.../HyperSwitch/SDKPayment/SDKPage.res | 3 +-
.../HyperSwitch/SDKPayment/TestPayment.res | 11 +++---
src/screens/HyperSwitch/SDKPayment/WebSDK.res | 9 +++--
.../ThreeDSFlow/HSwitchThreeDS.res | 6 ++--
.../HyperSwitch/ThreeDSFlow/ThreeDSUtils.res | 2 --
.../AnalyticsCommonComponents.res | 3 +-
src/server/Server.res | 2 --
src/utils/FullscreenUtils.res | 20 +++++------
43 files changed, 88 insertions(+), 132 deletions(-)
diff --git a/src/components/CustomCharts/HighchartHorizontalBarChart.res b/src/components/CustomCharts/HighchartHorizontalBarChart.res
index 51594df08..dc1f3faa4 100644
--- a/src/components/CustomCharts/HighchartHorizontalBarChart.res
+++ b/src/components/CustomCharts/HighchartHorizontalBarChart.res
@@ -1,4 +1,3 @@
-external objToJson: 'a => Js.Json.t = "%identity"
module RawHBarChart = {
@react.component
let make = (~options: Js.Json.t) => {
@@ -159,7 +158,7 @@ let make = (
enabled: false,
},
}
- defaultOptions->objToJson
+ defaultOptions->Identity.genericTypeToJson
}, (barChartData, theme))
diff --git a/src/components/CustomCharts/HighchartPieChart.res b/src/components/CustomCharts/HighchartPieChart.res
index 572d4b76c..3eb59a4fa 100644
--- a/src/components/CustomCharts/HighchartPieChart.res
+++ b/src/components/CustomCharts/HighchartPieChart.res
@@ -1,4 +1,3 @@
-external objToJson: 'a => Js.Json.t = "%identity"
%%raw(`require("./highcharts.css")`)
module RawPieChart = {
@react.component
@@ -106,7 +105,7 @@ let make = (
backgroundColor: theme === Dark ? "#202124" : "white",
},
}
- defaultOptions->objToJson
+ defaultOptions->Identity.genericTypeToJson
}, (pieSeriesData, theme))
diff --git a/src/components/CustomCharts/HighchartTimeSeriesChart.res b/src/components/CustomCharts/HighchartTimeSeriesChart.res
index 272474225..bb060d79b 100644
--- a/src/components/CustomCharts/HighchartTimeSeriesChart.res
+++ b/src/components/CustomCharts/HighchartTimeSeriesChart.res
@@ -3,8 +3,6 @@ type domElement
open LogicUtils
open DictionaryUtils
-external toJson: 'a => Js.Json.t = "%identity"
-
type ele
external toElement: Dom.element => ele = "%identity"
@@ -43,6 +41,7 @@ module TooltipString = {
type legendType = Table | Points
module LineChart1D = {
+ open Identity
@react.component
let make = (
~class: string="",
@@ -455,14 +454,14 @@ module LineChart1D = {
| Table =>
{
"enabled": {isMobileView ? false : showLegend},
- }->DOMUtils.objToJson
+ }->genericObjectOrRecordToJson
| Points =>
{
"enabled": !isMultiDimensional,
"itemStyle": legendItemStyle(theme, "IBM Plex Sans", "12px"),
"itemHiddenStyle": legendHiddenStyle(theme),
"itemHoverStyle": legendItemStyle(theme),
- }->DOMUtils.objToJson
+ }->genericObjectOrRecordToJson
}
let a: options = {
@@ -489,13 +488,13 @@ module LineChart1D = {
tick.gridLine.attr(.
{
"stroke-width": "0",
- }->DOMUtils.objToJson,
+ }->genericObjectOrRecordToJson,
)
} else {
tick.gridLine.attr(.
{
"stroke": strokeColor,
- }->DOMUtils.objToJson,
+ }->genericObjectOrRecordToJson,
)
}
})
@@ -504,13 +503,13 @@ module LineChart1D = {
}
)->Some,
}->Some,
- }->DOMUtils.objToJson,
+ }->genericObjectOrRecordToJson,
)
},
title: {
"text": chartTitle ? chartTitleText : "",
"style": chartTitleStyle,
- }->DOMUtils.objToJson,
+ }->genericObjectOrRecordToJson,
credits: {
"enabled": false,
},
@@ -529,7 +528,7 @@ module LineChart1D = {
"style": {
"color": theme === Light ? "rgba(246, 248, 249, 1)" : "rgba(25, 26, 26, 1)",
},
- }->DOMUtils.objToJson,
+ }->genericObjectOrRecordToJson,
plotOptions: Some(
{
"area": {
@@ -543,7 +542,7 @@ module LineChart1D = {
},
"lineWidth": 1.2,
"threshold": Js.Nullable.null,
- }->DOMUtils.objToJson,
+ }->genericObjectOrRecordToJson,
"line": {
"pointStart": None,
"fillColor": None,
@@ -555,7 +554,7 @@ module LineChart1D = {
},
"lineWidth": 1.2,
"threshold": Js.Nullable.null,
- }->DOMUtils.objToJson,
+ }->genericObjectOrRecordToJson,
"boxplot": {
"visible": false,
},
@@ -582,20 +581,20 @@ module LineChart1D = {
),
"mouseOver": None,
}),
- }->DOMUtils.objToJson,
- }->DOMUtils.objToJson,
+ }->genericObjectOrRecordToJson,
+ }->genericObjectOrRecordToJson,
),
xAxis: {
let defaultValue = {
"type": "datetime",
- }->DOMUtils.objToJson
+ }->genericObjectOrRecordToJson
let defaultValue = if (
["run_date", "run_month", "run_week"]->Js.Array2.includes(groupKey)
) {
{
"type": "category",
"tickWidth": 0,
- }->DOMUtils.objToJson
+ }->genericObjectOrRecordToJson
} else {
defaultValue
}
@@ -662,7 +661,7 @@ module LineChart1D = {
"title": {
"text": "",
"style": chartTitleStyle,
- }->DOMUtils.objToJson,
+ }->genericObjectOrRecordToJson,
"labels": {
let labelsValue = {
"formatter": Some(
@@ -680,11 +679,11 @@ module LineChart1D = {
"letterSpacing": "1px",
"color": theme === Light ? "#4B5468" : "rgba(246, 248, 249, 0.25)",
},
- }->DOMUtils.objToJson
+ }->genericObjectOrRecordToJson
labelsValue->getDictFromJsonObject->deleteKey("style")->Js.Json.object_
},
- }->DOMUtils.objToJson,
+ }->genericObjectOrRecordToJson,
series: chartData,
}
a
diff --git a/src/components/CustomExpandableTable.res b/src/components/CustomExpandableTable.res
index e6ecb519c..5f8a0453c 100644
--- a/src/components/CustomExpandableTable.res
+++ b/src/components/CustomExpandableTable.res
@@ -64,7 +64,7 @@ let make = (
{
key: string_of_int(i),
options: obj.options,
- selected: ev->formEventToStrArr,
+ selected: ev->Identity.formReactEventToArrayOfString,
}
} else {
obj
diff --git a/src/components/DynamicTableUtils.res b/src/components/DynamicTableUtils.res
index fb01ab3d8..b9ff8b725 100644
--- a/src/components/DynamicTableUtils.res
+++ b/src/components/DynamicTableUtils.res
@@ -2,8 +2,7 @@ let tableHeadingClass = "font-bold text-xl text-black text-opacity-75 dark:text-
type view = Table | Card
@val @scope(("window", "location"))
external reload: unit => unit = "reload"
-external convertToJsonDict: 't => Js.Dict.t = "%identity"
-external formEventToJsonArr: ReactEvent.Form.t => array = "%identity"
+
let visibilityColFunc = (
~dateFormatConvertor: string => option,
~jsonVal: option,
@@ -54,7 +53,7 @@ let filteredData = (
switch item->Js.Nullable.toOption {
| Some(row) =>
// either to take this row or not if any filter is present then take row or else drop
- let rowDict = row->convertToJsonDict
+ let rowDict = row->Identity.genericTypeToDictOfJson
let anyMatch = selectedFiltersKeys->Js.Array2.find(keys => {
// Selected fitler
switch Js.Dict.get(columnFilter, keys) {
diff --git a/src/components/LocalFilters.res b/src/components/LocalFilters.res
index aae59c1bd..43b5398e1 100644
--- a/src/components/LocalFilters.res
+++ b/src/components/LocalFilters.res
@@ -1,7 +1,5 @@
let makeFieldInfo = FormRenderer.makeFieldInfo
-external formEventToStrArr: ReactEvent.Form.t => array = "%identity"
-
module CheckLocalFilters = {
@react.component
let make = (
@@ -31,7 +29,7 @@ module CheckLocalFilters = {
None
}, [values])
let onChangeSelect = ev => {
- let fieldNameArr = ev->formEventToStrArr
+ let fieldNameArr = ev->Identity.formReactEventToArrayOfString
let newlyAdded = Js.Array2.filter(fieldNameArr, newVal =>
!Js.Array2.includes(checkedFilters, newVal)
)
diff --git a/src/components/RemoteFilter.res b/src/components/RemoteFilter.res
index d8df016a8..f80354334 100644
--- a/src/components/RemoteFilter.res
+++ b/src/components/RemoteFilter.res
@@ -1,7 +1,5 @@
let makeFieldInfo = FormRenderer.makeFieldInfo
-external formEventToStrArr: ReactEvent.Form.t => array = "%identity"
-
@val @scope(("window", "location"))
external reload: unit => unit = "reload"
@val @scope(("window", "location"))
@@ -288,7 +286,7 @@ module CheckCustomFilters = {
let values = formState.values
let onChangeSelect = ev => {
- let fieldNameArr = ev->formEventToStrArr
+ let fieldNameArr = ev->Identity.formReactEventToArrayOfString
let newlyAdded = Js.Array2.filter(fieldNameArr, newVal =>
!Js.Array2.includes(checkedFilters, newVal)
)
diff --git a/src/components/SelectModal.res b/src/components/SelectModal.res
index 5e3709cf2..70c8dd8b2 100644
--- a/src/components/SelectModal.res
+++ b/src/components/SelectModal.res
@@ -1,5 +1,3 @@
-external formEventToStrArr: ReactEvent.Form.t => array = "%identity"
-
@react.component
let make = (
~modalHeading="Select Options",
@@ -66,7 +64,7 @@ let make = (
name: "cutomixedColumnsInput",
onBlur: _ev => (),
onChange: ev => {
- let target = ev->formEventToStrArr
+ let target = ev->Identity.formReactEventToArrayOfString
Js.log2("ppp", target)
maxLengthArray(target, setValues)
},
diff --git a/src/components/Table.res b/src/components/Table.res
index b5bf98613..0c225c706 100644
--- a/src/components/Table.res
+++ b/src/components/Table.res
@@ -333,7 +333,7 @@ module TableHeadingCell = {
? {
key: string_of_int(i),
options: obj.options,
- selected: ev->formEventToStrArr,
+ selected: ev->Identity.formReactEventToArrayOfString,
}
: obj
})
diff --git a/src/components/Table.resi b/src/components/Table.resi
index 8c2a9e46e..ce1b7faa0 100644
--- a/src/components/Table.resi
+++ b/src/components/Table.resi
@@ -22,8 +22,6 @@ type filterDataType = TableUtils.filterDataType =
| Float(float, float)
| String
| DateTime
-
-external formEventToStrArr: ReactEvent.Form.t => array = "%identity"
external jsonToStr: Js.Json.t => string = "%identity"
type textAlign = TableUtils.textAlign = Left | Right
type fontBold = bool
diff --git a/src/components/TableUtils.res b/src/components/TableUtils.res
index e0ee86655..80665f195 100644
--- a/src/components/TableUtils.res
+++ b/src/components/TableUtils.res
@@ -75,7 +75,6 @@ type hideItem = {
value: string,
}
-external formEventToStrArr: ReactEvent.Form.t => array = "%identity"
external jsonToStr: Js.Json.t => string = "%identity"
type textAlign = Left | Right
diff --git a/src/components/TableUtils.resi b/src/components/TableUtils.resi
index 8008ebd92..f5ed0a51f 100644
--- a/src/components/TableUtils.resi
+++ b/src/components/TableUtils.resi
@@ -26,7 +26,6 @@ type selectAllSubmitActions = {
disableParam: disableField,
}
type hideItem = {key: string, value: string}
-external formEventToStrArr: ReactEvent.Form.t => array = "%identity"
external jsonToStr: Js.Json.t => string = "%identity"
type textAlign = Left | Right
type fontBold = bool
diff --git a/src/components/form/SelectBoxCard.res b/src/components/form/SelectBoxCard.res
index 70b94f830..6033b9a67 100644
--- a/src/components/form/SelectBoxCard.res
+++ b/src/components/form/SelectBoxCard.res
@@ -1,6 +1,5 @@
module CustomViewSection = {
external formEventToInt: ReactEvent.Form.t => int = "%identity"
- external formEventToStrArr: ReactEvent.Form.t => array = "%identity"
external arrToFormEvent: array<'a> => ReactEvent.Form.t = "%identity"
external jsonArrToa: array => array<'a> = "%identity"
@@ -52,7 +51,7 @@ module CustomViewSection = {
->ignore
}
} else {
- let evArr = ev->formEventToStrArr
+ let evArr = ev->Identity.formReactEventToArrayOfString
for i in 0 to evArr->Js.Array2.length - 1 {
valueArrReversed
->Js.Array2.find(x => keyExtractor(x) == evArr[i]->Belt.Option.getWithDefault(""))
diff --git a/src/components/priority-logics/AddPLGateway.res b/src/components/priority-logics/AddPLGateway.res
index 97ca505c1..ee7bb14ca 100644
--- a/src/components/priority-logics/AddPLGateway.res
+++ b/src/components/priority-logics/AddPLGateway.res
@@ -1,4 +1,3 @@
-external formEventToStrArr: ReactEvent.Form.t => array = "%identity"
type gateway = PriorityLogicUtils.gateway
module GatewayView = {
@@ -105,7 +104,7 @@ let make = (
name: "gateways",
onBlur: _ev => (),
onChange: ev => {
- let newSelectedOptions = ev->formEventToStrArr
+ let newSelectedOptions = ev->Identity.formReactEventToArrayOfString
if newSelectedOptions->Js.Array2.length === 0 {
gateWaysInput.onChange([]->Identity.anyTypeToReactEvent)
} else {
diff --git a/src/components/priority-logics/PriorityLogicUtils.res b/src/components/priority-logics/PriorityLogicUtils.res
index 219143a86..83f1337b9 100644
--- a/src/components/priority-logics/PriorityLogicUtils.res
+++ b/src/components/priority-logics/PriorityLogicUtils.res
@@ -1,8 +1,6 @@
type val =
StringArray(array) | String(string) | IntArray(array) | Int(int) | Bool(bool)
-external tojsonObjTest: 'a => Js.Json.t = "%identity"
-
type gateway = {
gateway_name: string,
distribution: int,
diff --git a/src/entities/analytics/IntegrationsEntity.res b/src/entities/analytics/IntegrationsEntity.res
index f415e33f0..3cc43a93f 100644
--- a/src/entities/analytics/IntegrationsEntity.res
+++ b/src/entities/analytics/IntegrationsEntity.res
@@ -1,4 +1,3 @@
-external toDict: 'a => Js.Dict.t = "%identity"
let domain = "integrations"
open LogicUtils
diff --git a/src/genericUtils/DOMUtils.res b/src/genericUtils/DOMUtils.res
index ba46d9617..7e73c403e 100644
--- a/src/genericUtils/DOMUtils.res
+++ b/src/genericUtils/DOMUtils.res
@@ -12,15 +12,6 @@ type event
external event: string => event = "Event"
@send external dispatchEvent: ('a, event) => unit = "dispatchEvent"
@send external postMessage: (window, Js.Json.t, string) => unit = "postMessage"
-
@val @scope(("window", "location")) external windowOrigin: string = "origin"
-external toString: option => string = "%identity"
-external convertToStrDict: 't => Js.Json.t = "%identity"
-external objToJson: {..} => Js.Json.t = "%identity"
-
-external toJson: exn => Js.Json.t = "%identity"
-external toRespJson: Fetch.Response.t => Js.Json.t = "%identity"
@get external keyCode: 'a => int = "keyCode"
-
-external formEventToBoolean: ReactEvent.Form.t => bool = "%identity"
@send external querySelectorAll: (document, string) => array = "querySelectorAll"
diff --git a/src/genericUtils/Identity.res b/src/genericUtils/Identity.res
index 024baa29c..b23176438 100644
--- a/src/genericUtils/Identity.res
+++ b/src/genericUtils/Identity.res
@@ -4,3 +4,9 @@ external anyTypeToReactEvent: 'a => ReactEvent.Form.t = "%identity"
external arrofStringToReactEvent: array => ReactEvent.Form.t = "%identity"
external jsonToNullableJson: Js.Json.t => Js.Nullable.t = "%identity"
external jsonToReactDOMStyle: Js.Json.t => ReactDOM.style = "%identity"
+external genericTypeToJson: 'a => Js.Json.t = "%identity"
+external genericTypeToBool: 'a => bool = "%identity"
+external formReactEventToBool: ReactEvent.Form.t => bool = "%identity"
+external genericObjectOrRecordToJson: {..} => Js.Json.t = "%identity"
+external genericTypeToDictOfJson: 't => Js.Dict.t = "%identity"
+external formReactEventToArrayOfString: ReactEvent.Form.t => array = "%identity"
diff --git a/src/hooks/AuthHooks.res b/src/hooks/AuthHooks.res
index 8e7bacd98..5d60501df 100644
--- a/src/hooks/AuthHooks.res
+++ b/src/hooks/AuthHooks.res
@@ -14,7 +14,6 @@ type sessionStorage = {
external dictToObj: Js.Dict.t<'a> => {..} = "%identity"
@val external atob: string => string = "atob"
-external toJson: 'a => Js.Json.t = "%identity"
let getAgentId = _ => {
switch LocalStorage.getItem("agentId")->Js.Nullable.toOption {
| Some(str) => str
@@ -74,7 +73,7 @@ let getHeadersJson = (
key
->Js.String2.replace("-----BEGIN PUBLIC KEY-----\n", "")
->Js.String2.replace("\n-----END PUBLIC KEY-----", "")
- ->toJson,
+ ->Identity.genericTypeToJson,
)
} else {
Js.Dict.set(headerObj, "X-RequestId", requestId->Js.Json.string)
@@ -94,7 +93,7 @@ let getHeadersJson = (
key
->Js.String2.replace("-----BEGIN PUBLIC KEY-----\n", "")
->Js.String2.replace("\n-----END PUBLIC KEY-----", "")
- ->toJson,
+ ->Identity.genericTypeToJson,
)
}
}
@@ -110,11 +109,12 @@ let getHeadersJson = (
key
->Js.String2.replace("-----BEGIN PUBLIC KEY-----\n", "")
->Js.String2.replace("\n-----END PUBLIC KEY-----", "")
- ->toJson,
+ ->Identity.genericTypeToJson,
)
}
}
}
+
headerObj->Js.Json.object_
}
diff --git a/src/libraries/Jose.res b/src/libraries/Jose.res
index ce6bbe66d..a356301bd 100644
--- a/src/libraries/Jose.res
+++ b/src/libraries/Jose.res
@@ -75,7 +75,7 @@ external generateKeyPairs: 'a = "generateKeyPair"
@module("jose") external importPKCS8: ('a, string) => Js.Promise.t = "importPKCS8"
@module("jose") external compactDecrypt: ('a, key) => Js.Promise.t = "compactDecrypt"
@module("jose") external compactVerify: ('a, key) => Js.Promise.t = "compactVerify"
-external toJson: 'a => Js.Json.t = "%identity"
+
let getKey = keyType => {
switch LocalStorage.getItem(keyType)->Js.Nullable.toOption {
| Some(str) => str
diff --git a/src/screens/HyperSwitch/Analytics/Analytics.res b/src/screens/HyperSwitch/Analytics/Analytics.res
index c0303e12f..2be798615 100644
--- a/src/screens/HyperSwitch/Analytics/Analytics.res
+++ b/src/screens/HyperSwitch/Analytics/Analytics.res
@@ -1,6 +1,5 @@
external toString: option => string = "%identity"
external convertToStrDict: 't => Js.Json.t = "%identity"
-external asJson: 'a => Js.Json.t = "%identity"
external sankeyTest: string => SankeyCharts.sankeyEntity = "%identity"
@get external keyCode: 'a => int = "keyCode"
type window
diff --git a/src/screens/HyperSwitch/Analytics/DownloadReportModal.res b/src/screens/HyperSwitch/Analytics/DownloadReportModal.res
index 6955e3041..a793e92df 100644
--- a/src/screens/HyperSwitch/Analytics/DownloadReportModal.res
+++ b/src/screens/HyperSwitch/Analytics/DownloadReportModal.res
@@ -1,5 +1,3 @@
-external toJson: 'a => Js.Json.t = "%identity"
-
type lteGte = {
gte: Js.Json.t,
lte: Js.Json.t,
@@ -62,7 +60,7 @@ let make = (~reportModal, ~setReportModal, ~entityName) => {
endTime: lte,
},
dimensions: [],
- }->toJson
+ }->Identity.genericTypeToJson
downloadReport(body)
}
@@ -80,7 +78,7 @@ let make = (~reportModal, ~setReportModal, ~entityName) => {
lte: Js.Date.now()->Js.Date.fromFloat->Js.Date.toISOString->Js.Json.string,
},
},
- }->toJson
+ }->Identity.genericTypeToJson
array> = json => {
->Belt.Option.getWithDefault([])
}
-external toDict: 't => Js.Dict.t = "%identity"
let filterByData = (txnArr, value) => {
let searchText = LogicUtils.getStringFromJson(value, "")
@@ -70,7 +69,7 @@ let filterByData = (txnArr, value) => {
->Belt.Array.keepMap((data: 't) => {
let valueArr =
data
- ->toDict
+ ->Identity.genericTypeToDictOfJson
->Js.Dict.entries
->Js.Array2.map(item => {
let (_, value) = item
diff --git a/src/screens/HyperSwitch/Connectors/ConnectorAccountDetails.res b/src/screens/HyperSwitch/Connectors/ConnectorAccountDetails.res
index 91073e932..e50416cb1 100644
--- a/src/screens/HyperSwitch/Connectors/ConnectorAccountDetails.res
+++ b/src/screens/HyperSwitch/Connectors/ConnectorAccountDetails.res
@@ -1,5 +1,3 @@
-external formEventToBool: ReactEvent.Form.t => bool = "%identity"
-
let connectorsWithIntegrationSteps: array = [
ADYEN,
CHECKOUT,
diff --git a/src/screens/HyperSwitch/FraudAndRisk/FRMIntegrationFields.res b/src/screens/HyperSwitch/FraudAndRisk/FRMIntegrationFields.res
index 648298560..56c3db9d8 100644
--- a/src/screens/HyperSwitch/FraudAndRisk/FRMIntegrationFields.res
+++ b/src/screens/HyperSwitch/FraudAndRisk/FRMIntegrationFields.res
@@ -1,5 +1,3 @@
-external formEventToBool: ReactEvent.Form.t => bool = "%identity"
-
module AdvanceSettings = {
@react.component
let make = (~isUpdateFlow, ~frmName, ~renderCountrySelector) => {
@@ -14,7 +12,7 @@ module AdvanceSettings = {
name: `input`,
onBlur: _ev => (),
onChange: ev => {
- let value = ev->formEventToBool
+ let value = ev->Identity.formReactEventToBool
setIsFRMSettings(_ => value)
[frmName, "global"]->Js.Array2.forEach(ele =>
hyperswitchMixPanel(
diff --git a/src/screens/HyperSwitch/FraudAndRisk/FRMPaymentMethods.res b/src/screens/HyperSwitch/FraudAndRisk/FRMPaymentMethods.res
index 361371c48..f3966caab 100644
--- a/src/screens/HyperSwitch/FraudAndRisk/FRMPaymentMethods.res
+++ b/src/screens/HyperSwitch/FraudAndRisk/FRMPaymentMethods.res
@@ -1,5 +1,3 @@
-external convertToJsonDict: 't => Js.Dict.t = "%identity"
-
module RadioSection = {
open ConnectorTypes
open FRMTypes
@@ -344,7 +342,7 @@ let make = (~setCurrentStep, ~retrivedValues=None, ~setInitialValues, ~isUpdateF
->parseFRMConfig
->Js.Array2.filter(config => config.payment_methods->Js.Array2.length > 0)
- valuesDict->Js.Dict.set("frm_configs", filteredArray->toJson)
+ valuesDict->Js.Dict.set("frm_configs", filteredArray->Identity.genericTypeToJson)
setInitialValues(_ => valuesDict->Js.Json.object_)
setCurrentStep(prev => prev->getNextStep)
diff --git a/src/screens/HyperSwitch/FraudAndRisk/FRMUtils.res b/src/screens/HyperSwitch/FraudAndRisk/FRMUtils.res
index 1c8228f7e..14d5aa999 100644
--- a/src/screens/HyperSwitch/FraudAndRisk/FRMUtils.res
+++ b/src/screens/HyperSwitch/FraudAndRisk/FRMUtils.res
@@ -17,8 +17,6 @@ let base64Format = (. ~value, ~name as _) => {
value->Js.Json.decodeString->Belt.Option.getWithDefault("")->atob->Js.Json.string
}
-external toJson: 'a => Js.Json.t = "%identity"
-
let toggleDefaultStyle = "mb-2 relative inline-flex flex-shrink-0 h-6 w-12 border-2 rounded-full transition-colors ease-in-out duration-200 focus:outline-none focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-opacity-75 items-center"
let accordionDefaultStyle = "border pointer-events-none inline-block h-3 w-3 rounded-full bg-white dark:bg-white shadow-lg transform ring-0 transition ease-in-out duration-200"
diff --git a/src/screens/HyperSwitch/HSwitchUtils.res b/src/screens/HyperSwitch/HSwitchUtils.res
index 0f1fc990b..11e40900c 100644
--- a/src/screens/HyperSwitch/HSwitchUtils.res
+++ b/src/screens/HyperSwitch/HSwitchUtils.res
@@ -16,7 +16,6 @@ type browserDetailsObject = {
let feedbackModalOpenCountForConnectors = 4
-external objToJson: {..} => Js.Json.t = "%identity"
let errorClass = "text-sm leading-4 font-medium text-start ml-1 mt-2"
type pageLevelVariant =
diff --git a/src/screens/HyperSwitch/Order/OrderUIUtils.res b/src/screens/HyperSwitch/Order/OrderUIUtils.res
index 661ca040a..2514bd116 100644
--- a/src/screens/HyperSwitch/Order/OrderUIUtils.res
+++ b/src/screens/HyperSwitch/Order/OrderUIUtils.res
@@ -100,7 +100,6 @@ let filterUrl = `${HSwitchGlobalVars.hyperSwitchApiPrefix}/payments/filter`
let (startTimeFilterKey, endTimeFilterKey) = ("start_time", "end_time")
-external toDict: 't => Js.Dict.t = "%identity"
let filterByData = (txnArr, value) => {
open LogicUtils
let searchText = value->getStringFromJson("")
@@ -110,7 +109,7 @@ let filterByData = (txnArr, value) => {
->Belt.Array.keepMap(data => {
let valueArr =
data
- ->toDict
+ ->Identity.genericTypeToDictOfJson
->Js.Dict.entries
->Js.Array2.map(item => {
let (_, value) = item
diff --git a/src/screens/HyperSwitch/Refunds/RefundUtils.res b/src/screens/HyperSwitch/Refunds/RefundUtils.res
index 99c9c4868..2421f3469 100644
--- a/src/screens/HyperSwitch/Refunds/RefundUtils.res
+++ b/src/screens/HyperSwitch/Refunds/RefundUtils.res
@@ -48,7 +48,6 @@ let customUI =
let (startTimeFilterKey, endTimeFilterKey) = ("start_time", "end_time")
-external toDict: 't => Js.Dict.t = "%identity"
let filterByData = (txnArr, value) => {
open LogicUtils
let searchText = value->getStringFromJson("")
@@ -58,7 +57,7 @@ let filterByData = (txnArr, value) => {
->Belt.Array.keepMap(data => {
let valueArr =
data
- ->toDict
+ ->Identity.genericTypeToDictOfJson
->Js.Dict.entries
->Js.Array2.map(item => {
let (_, value) = item
diff --git a/src/screens/HyperSwitch/Routing/RoutingStack.res b/src/screens/HyperSwitch/Routing/RoutingStack.res
index 0deba0211..169da83b8 100644
--- a/src/screens/HyperSwitch/Routing/RoutingStack.res
+++ b/src/screens/HyperSwitch/Routing/RoutingStack.res
@@ -1,5 +1,4 @@
open APIUtils
-external toJson: 'a => Js.Json.t = "%identity"
@react.component
let make = (~remainingPath, ~previewOnly=false) => {
let fetchDetails = useGetMethod()
diff --git a/src/screens/HyperSwitch/RoutingRevamp/AddRuleGateway.res b/src/screens/HyperSwitch/RoutingRevamp/AddRuleGateway.res
index c662025a3..d3ea4e15b 100644
--- a/src/screens/HyperSwitch/RoutingRevamp/AddRuleGateway.res
+++ b/src/screens/HyperSwitch/RoutingRevamp/AddRuleGateway.res
@@ -1,5 +1,3 @@
-external formEventToStrArr: ReactEvent.Form.t => array = "%identity"
-external toJson: 'a => Js.Json.t = "%identity"
external anyToEnum: 'a => AdvancedRoutingTypes.connectorSelectionData = "%identity"
@react.component
@@ -36,7 +34,7 @@ let make = (~id, ~gatewayOptions, ~isFirst=false, ~isExpanded=false) => {
name: "gateways",
onBlur: _ev => (),
onChange: ev => {
- let newSelectedOptions = ev->formEventToStrArr
+ let newSelectedOptions = ev->Identity.formReactEventToArrayOfString
if newSelectedOptions->Js.Array2.length === 0 {
gateWaysInput.onChange([]->Identity.anyTypeToReactEvent)
@@ -54,14 +52,14 @@ let make = (~id, ~gatewayOptions, ~isFirst=false, ~isExpanded=false) => {
merchant_connector_id: item,
},
split: sharePercent,
- }->toJson
+ }->Identity.genericTypeToJson
} else {
{
connector: (
connectorList->ConnectorTableUtils.getConnectorNameViaId(item)
).connector_name,
merchant_connector_id: item,
- }->toJson
+ }->Identity.genericTypeToJson
}
})
gateWaysInput.onChange(gatewaysArr->Identity.anyTypeToReactEvent)
@@ -98,9 +96,9 @@ let make = (~id, ~gatewayOptions, ~isFirst=false, ~isExpanded=false) => {
merchant_connector_id: obj.merchant_connector_id,
},
split: sharePercent,
- }->toJson
+ }->Identity.genericTypeToJson
- | VolumeObject(obj) => obj.connector->toJson
+ | VolumeObject(obj) => obj.connector->Identity.genericTypeToJson
}
})
gateWaysInput.onChange(gatewaysArr->Identity.anyTypeToReactEvent)
@@ -118,7 +116,7 @@ let make = (~id, ~gatewayOptions, ~isFirst=false, ~isExpanded=false) => {
if value < 100 {
let newList = selectedOptions->Js.Array2.map(option => {
switch option {
- | PriorityObject(obj) => obj.connector->toJson
+ | PriorityObject(obj) => obj.connector->Identity.genericTypeToJson
| VolumeObject(obj) =>
{
...obj,
@@ -128,7 +126,7 @@ let make = (~id, ~gatewayOptions, ~isFirst=false, ~isExpanded=false) => {
).merchant_connector_id
? value
: obj.split,
- }->toJson
+ }->Identity.genericTypeToJson
}
})
gateWaysInput.onChange(newList->Identity.anyTypeToReactEvent)
diff --git a/src/screens/HyperSwitch/RoutingRevamp/AdvancedRouting.res b/src/screens/HyperSwitch/RoutingRevamp/AdvancedRouting.res
index 7c93e1a4e..86954f45b 100644
--- a/src/screens/HyperSwitch/RoutingRevamp/AdvancedRouting.res
+++ b/src/screens/HyperSwitch/RoutingRevamp/AdvancedRouting.res
@@ -3,7 +3,6 @@ open AdvancedRoutingTypes
open AdvancedRoutingUtils
open LogicUtils
-external toJson: 'a => Js.Json.t = "%identity"
external arrToFormEvent: array<'a> => ReactEvent.Form.t = "%identity"
external toWasm: Js.Dict.t => RoutingTypes.wasmModule = "%identity"
@@ -248,8 +247,8 @@ module RuleBasedUI = {
let addRule = (index, copy) => {
let existingRules = ruleInput.value->getArrayFromJson([])
let newRule = copy
- ? existingRules[index]->Belt.Option.getWithDefault(defaultRule->toJson)
- : defaultRule->toJson
+ ? existingRules[index]->Belt.Option.getWithDefault(defaultRule->Identity.genericTypeToJson)
+ : defaultRule->Identity.genericTypeToJson
let newRules = existingRules->Js.Array2.concat([newRule])
ruleInput.onChange(newRules->arrToFormEvent)
}
@@ -339,7 +338,9 @@ let make = (~routingRuleId, ~isActive, ~setCurrentRouting) => {
let businessProfiles = Recoil.useRecoilValueFromAtom(HyperswitchAtom.businessProfilesAtom)
let defaultBusinessProfile = businessProfiles->MerchantAccountUtils.getValueFromBusinessProfile
let (profile, setProfile) = React.useState(_ => defaultBusinessProfile.profile_id)
- let (initialValues, setInitialValues) = React.useState(_ => initialValues->toJson)
+ let (initialValues, setInitialValues) = React.useState(_ =>
+ initialValues->Identity.genericTypeToJson
+ )
let (initialRule, setInitialRule) = React.useState(() => None)
let showToast = ToastState.useShowToast()
let fetchDetails = useGetMethod()
@@ -593,7 +594,7 @@ let make = (~routingRuleId, ~isActive, ~setCurrentRouting) => {
}
let getActivateUrl = getURL(~entityName=ROUTING, ~methodType=Post, ~id=None, ())
- let response = await updateDetails(getActivateUrl, payload->toJson, Post)
+ let response = await updateDetails(getActivateUrl, payload->Identity.genericTypeToJson, Post)
showToast(
~message="Successfully Created a new Configuration !",
diff --git a/src/screens/HyperSwitch/RoutingRevamp/AdvancedRoutingUIUtils.res b/src/screens/HyperSwitch/RoutingRevamp/AdvancedRoutingUIUtils.res
index 2b5db95f3..61ef2af65 100644
--- a/src/screens/HyperSwitch/RoutingRevamp/AdvancedRoutingUIUtils.res
+++ b/src/screens/HyperSwitch/RoutingRevamp/AdvancedRoutingUIUtils.res
@@ -4,7 +4,6 @@ open FormRenderer
external arrToFormEvent: array<'a> => ReactEvent.Form.t = "%identity"
external strToFormEvent: Js.String.t => ReactEvent.Form.t = "%identity"
-external formEventToStrArr: ReactEvent.Form.t => array = "%identity"
module LogicalOps = {
@react.component
@@ -146,7 +145,7 @@ module ValueInp = {
name: "string",
onBlur: _ev => (),
onChange: ev => {
- let value = ev->formEventToStrArr
+ let value = ev->Identity.formReactEventToArrayOfString
valueField.onChange(value->Identity.anyTypeToReactEvent)
},
onFocus: _ev => (),
diff --git a/src/screens/HyperSwitch/RoutingRevamp/AdvancedRoutingUtils.res b/src/screens/HyperSwitch/RoutingRevamp/AdvancedRoutingUtils.res
index 0c342c5a1..45e55a43c 100644
--- a/src/screens/HyperSwitch/RoutingRevamp/AdvancedRoutingUtils.res
+++ b/src/screens/HyperSwitch/RoutingRevamp/AdvancedRoutingUtils.res
@@ -1,5 +1,3 @@
-external toJson: 'a => Js.Json.t = "%identity"
-
let getCurrentDetailedUTCTime = () => {
Js.Date.fromFloat(Js.Date.now())->Js.Date.toUTCString
}
@@ -410,7 +408,7 @@ let generateRule = rulesDict => {
{
"name": ruleDict->getString("name", ""),
"connectorSelection": ruleDict->getJsonObjectFromDict("connectorSelection"),
- "statements": modifiedStatements->Js.Array2.map(toJson)->Js.Json.array,
+ "statements": modifiedStatements->Js.Array2.map(Identity.genericTypeToJson)->Js.Json.array,
}
})
modifiedRules
diff --git a/src/screens/HyperSwitch/SDKPayment/SDKPage.res b/src/screens/HyperSwitch/SDKPayment/SDKPage.res
index fe9300e49..a4712dd51 100644
--- a/src/screens/HyperSwitch/SDKPayment/SDKPage.res
+++ b/src/screens/HyperSwitch/SDKPayment/SDKPage.res
@@ -1,5 +1,4 @@
let h3Leading2Style = HSwitchUtils.getTextClass(~textVariant=H3, ~h3TextVariant=Leading_2, ())
-external toJson: 'a => Js.Json.t = "%identity"
external strToFormEvent: Js.String.t => ReactEvent.Form.t = "%identity"
module SDKConfiguarationFields = {
@@ -140,7 +139,7 @@ let make = () => {