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 = () => {