From 6a51261a3c9d704ac1b953459ba07e957282161e Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja <1805317@kiit.ac.in> Date: Mon, 11 Dec 2023 13:17:59 +0530 Subject: [PATCH 1/3] refactor: Common file for all identity functions --- config/FeatureFlag.json | 34 +++++++++---------- .../NestedDropdownWithCalendar.res | 2 +- src/components/Base64ImageInputWithDnD.res | 9 +++-- src/components/CsvFileUpload.res | 3 +- src/components/CsvInputField.res | 9 +++-- src/components/DatePicker.res | 4 +-- src/components/DateRangePicker.res | 5 ++- .../DistributionDonut/DistributionDonut.res | 3 +- src/components/DraggableFilter.res | 4 +-- src/components/DynamicChart.res | 13 ++++--- src/components/DynamicTabs.res | 1 - src/components/MultiLineInputBox.res | 5 ++- src/components/MultipleFileUpload.res | 13 ++++--- src/components/NestedDropdown.res | 5 ++- src/components/NewDateRangePicker.res | 1 - src/components/Paginator.res | 4 +-- src/components/RangeSlider.res | 9 +++-- src/components/RatingOptions.res | 4 +-- src/components/RedirectSearchInput.res | 6 ++-- src/components/Table.resi | 1 - src/components/TableLocalFilters.res | 1 - src/components/TableUtils.res | 1 - src/components/TableUtils.resi | 1 - src/components/TimeInput.res | 8 +++-- src/components/form/ColorPickerInput.res | 3 +- src/components/form/ComboInputField.res | 20 +++++++---- src/components/form/FileUpload.res | 11 +++--- src/components/form/MultipleTextInput.res | 1 - src/components/form/NumericTextInput.res | 5 ++- src/components/form/PasswordStrengthInput.res | 2 -- .../form/PasswordStrengthInputAsChips.res | 2 -- src/components/form/SelectBoxCard.res | 3 +- .../priority-logics/AddPLGateway.res | 20 +++++------ .../priority-logics/PriorityLogicUtils.res | 2 -- .../hyperswitch/HyperSwitchApp.res | 1 - src/genericUtils/DOMUtils.res | 2 -- src/genericUtils/Identity.res | 3 ++ .../HyperSwitch/Analytics/Analytics.res | 2 -- .../Connectors/ConnectorAccountDetails.res | 1 - .../HyperSwitch/Connectors/ConnectorList.res | 2 -- .../ApplePayWalletIntegrationTypes.res | 1 - .../FraudAndRisk/FRMPaymentMethods.res | 13 ++++--- src/screens/HyperSwitch/Home/HomeUtils.res | 1 - .../RoutingRevamp/AddRuleGateway.res | 16 ++++----- .../RoutingRevamp/AdvancedRoutingUIUtils.res | 24 ++++++------- .../RoutingRevamp/BasicDetailsForm.res | 5 +-- .../HyperSwitch/SDKPayment/SDKPage.res | 4 +-- .../UserOnboardingUIUtils.res | 7 ++-- .../AnalyticsCommonComponents.res | 9 +++-- .../HSwitchLoginFlow/HyperSwitchAuthUtils.res | 1 - 50 files changed, 136 insertions(+), 171 deletions(-) create mode 100644 src/genericUtils/Identity.res diff --git a/config/FeatureFlag.json b/config/FeatureFlag.json index 9d6e08029..0106d7dba 100644 --- a/config/FeatureFlag.json +++ b/config/FeatureFlag.json @@ -1,23 +1,23 @@ { - "test_live_toggle": false, + "test_live_toggle": true, "is_live_mode": false, - "magic_link": false, - "production_access": false, - "quick_start": false, - "switch_merchant": false, - "audit_trail": false, - "system_metrics": false, - "sample_data": false, - "frm": false, - "payout": false, - "recon": false, - "user_management": false, + "magic_link": true, + "production_access": true, + "quick_start": true, + "switch_merchant": true, + "audit_trail": true, + "system_metrics": true, + "sample_data": true, + "frm": true, + "payout": true, + "recon": true, + "user_management": true, "test_processors": true, - "feedback": false, - "verify_connector": false, + "feedback": true, + "verify_connector": true, "mixpanel": false, - "business_profile": false, - "generate_report": false, - "forgot_password": false, + "business_profile": true, + "generate_report": true, + "forgot_password": true, "oss_build": true } diff --git a/src/components/AnalyticsComponent/NestedDropdownWithCalendar.res b/src/components/AnalyticsComponent/NestedDropdownWithCalendar.res index a101dc0dc..fe729d39d 100644 --- a/src/components/AnalyticsComponent/NestedDropdownWithCalendar.res +++ b/src/components/AnalyticsComponent/NestedDropdownWithCalendar.res @@ -25,7 +25,7 @@ let make = ( endDateArr->Belt.Array.get(i)->Belt.Option.getWithDefault(x), )) - input.onChange(newArr->NestedDropdown.formToArray) + input.onChange(newArr->Identity.anyTypeToReactEvent) } let showCalendars = React.useMemo1(() => { diff --git a/src/components/Base64ImageInputWithDnD.res b/src/components/Base64ImageInputWithDnD.res index 3495dc2fa..40fa90417 100644 --- a/src/components/Base64ImageInputWithDnD.res +++ b/src/components/Base64ImageInputWithDnD.res @@ -1,4 +1,3 @@ -external toReactEvent: 'a => ReactEvent.Form.t = "%identity" external strToDomImg: string => Webapi.Dom.Image.t = "%identity" @send external drawImage: (Webapi.Canvas.Canvas2d.t, 'a, int, int) => unit = "drawImage" @send external toDataURL: 'a => string = "toDataURL" @@ -57,7 +56,7 @@ let make = ( ) let clearImage = _evt => { setFilename(_ => "") - input.onChange(""->toReactEvent) + input.onChange(""->Identity.stringToFormReactEvent) } let onChange = evt => { let target = ReactEvent.Form.target(evt) @@ -76,7 +75,7 @@ let make = ( let target = ReactEvent.Form.target(e) let data = target["result"] setIsNewUpload(_ => true) - input.onChange(toReactEvent(data)) + input.onChange(data->Identity.anyTypeToReactEvent) } } } @@ -106,7 +105,7 @@ let make = ( context->drawImage(img, 0, 0) toDataURL(canvas) } - input.onChange(a->toReactEvent) + input.onChange(a->Identity.stringToFormReactEvent) }
{ @@ -129,7 +128,7 @@ let make = ( let target = ReactEvent.Form.target(e) let data = target["result"] setIsNewUpload(_ => true) - input.onChange(toReactEvent(data)) + input.onChange(data->Identity.anyTypeToReactEvent) } } } diff --git a/src/components/CsvFileUpload.res b/src/components/CsvFileUpload.res index 8e1360611..30629d66a 100644 --- a/src/components/CsvFileUpload.res +++ b/src/components/CsvFileUpload.res @@ -1,4 +1,3 @@ -external toReactEvent: 'a => ReactEvent.Form.t = "%identity" type t type formData @@ -28,7 +27,7 @@ let make = ( setFilenameVal(_ => "") onFileUpload(None) - input.onChange(""->toReactEvent) + input.onChange(""->Identity.stringToFormReactEvent) } let onChange = evt => { diff --git a/src/components/CsvInputField.res b/src/components/CsvInputField.res index 4ead42446..6673571da 100644 --- a/src/components/CsvInputField.res +++ b/src/components/CsvInputField.res @@ -1,4 +1,3 @@ -external toReactEvent: 'a => ReactEvent.Form.t = "%identity" external jsonToarr: Js.Json.t => array<'a> = "%identity" external arrToReactEvent: array => ReactEvent.Form.t = "%identity" external strToReactEvent: string => ReactEvent.Form.t = "%identity" @@ -7,7 +6,7 @@ module FilenameSaver = { @react.component let make = (~input: ReactFinalForm.fieldRenderPropsInput, ~fileName) => { React.useEffect1(() => { - let reactEvFilename = fileName->toReactEvent + let reactEvFilename = fileName->Identity.anyTypeToReactEvent input.onChange(reactEvFilename) None }, [fileName]) @@ -164,7 +163,7 @@ let make = ( }) if errorLines->Js.Array2.length === 0 { - input.onChange(toReactEvent(res)) + input.onChange(res->Identity.anyTypeToReactEvent) toast("File Uploaded Successfully", ToastSuccess) } @@ -175,7 +174,7 @@ let make = ( } | None => { - input.onChange(toReactEvent(res)) + input.onChange(res->Identity.anyTypeToReactEvent) toast("File Uploaded Successfully", ToastSuccess) } } @@ -188,7 +187,7 @@ let make = ( } | _ => setIsNewUpload(_ => true) - input.onChange(toReactEvent(csv)) + input.onChange(csv->Identity.anyTypeToReactEvent) toast("File Uploaded Successfully", ToastSuccess) } } diff --git a/src/components/DatePicker.res b/src/components/DatePicker.res index 5eb475e1d..c37abb8e2 100644 --- a/src/components/DatePicker.res +++ b/src/components/DatePicker.res @@ -1,6 +1,6 @@ external strToForm: string => ReactEvent.Form.t = "%identity" external jsonToForm: Js.Json.t => ReactEvent.Form.t = "%identity" -external formEvAsString: ReactEvent.Form.t => string = "%identity" + @react.component let make = ( ~input: ReactFinalForm.fieldRenderPropsInput, @@ -167,7 +167,7 @@ let make = ( name: "string", onBlur: _ev => (), onChange: timeValEv => { - let timeVal = timeValEv->formEvAsString + let timeVal = timeValEv->Identity.formReactEventToString if selectedDate !== "" { let todayDayJsObj = Js.Date.make()->Js.Date.toString->DayJs.getDayJsForString let todayTime = todayDayJsObj.format(. "HH:mm:ss") diff --git a/src/components/DateRangePicker.res b/src/components/DateRangePicker.res index eeb831c42..210fa84f3 100644 --- a/src/components/DateRangePicker.res +++ b/src/components/DateRangePicker.res @@ -1,5 +1,4 @@ external strToForm: string => ReactEvent.Form.t = "%identity" -external formEvAsString: ReactEvent.Form.t => string = "%identity" let defaultCellHighlighter = (_): Calendar.highlighter => { { @@ -458,7 +457,7 @@ module Base = { name: "string", onBlur: _ev => (), onChange: timeValEv => { - let startTimeVal = timeValEv->formEvAsString + let startTimeVal = timeValEv->Identity.formReactEventToString let endTime = localEndDate->getTimeStringForValue(isoStringToCustomTimeZone) if localStartDate !== "" { @@ -481,7 +480,7 @@ module Base = { name: "string", onBlur: _ev => (), onChange: timeValEv => { - let endTimeVal = timeValEv->formEvAsString + let endTimeVal = timeValEv->Identity.formReactEventToString let startTime = localStartDate->getTimeStringForValue(isoStringToCustomTimeZone) if localEndDate !== "" { if disableFutureDates && selectedEndDate == todayDate && endTimeVal > todayTime { diff --git a/src/components/DistributionDonut/DistributionDonut.res b/src/components/DistributionDonut/DistributionDonut.res index 623635db1..6a056d565 100644 --- a/src/components/DistributionDonut/DistributionDonut.res +++ b/src/components/DistributionDonut/DistributionDonut.res @@ -1,5 +1,4 @@ external objToJson: {..} => Js.Json.t = "%identity" -external formEventToStr: ReactEvent.Form.t => string = "%identity" type dataPoint = {y: int, name: string} @@ -160,7 +159,7 @@ let make = ( let filterInput: ReactFinalForm.fieldRenderPropsInput = { name: "Get By", onBlur: _ev => (), - onChange: ev => {setGroupBy(_ => ev->formEventToStr)}, + onChange: ev => {setGroupBy(_ => ev->Identity.formReactEventToString)}, onFocus: _ev => (), value: groupBy->Js.Json.string, checked: true, diff --git a/src/components/DraggableFilter.res b/src/components/DraggableFilter.res index 04ef0f11d..0166806d9 100644 --- a/src/components/DraggableFilter.res +++ b/src/components/DraggableFilter.res @@ -4,8 +4,6 @@ type rec options = { options: option>, } -external formToArray: 'a => ReactEvent.Form.t = "%identity" - module TypeText = { @react.component let make = () => { @@ -429,7 +427,7 @@ let make = ( } React.useEffect1(() => { - input.onChange(dataSelectedBase->formToArray) + input.onChange(dataSelectedBase->Identity.anyTypeToReactEvent) None }, [dataSelectedBase]) let keyExtractor = (index, data, isDragging) => { diff --git a/src/components/DynamicChart.res b/src/components/DynamicChart.res index 35e06740c..db014ee6a 100644 --- a/src/components/DynamicChart.res +++ b/src/components/DynamicChart.res @@ -292,7 +292,6 @@ let useChartFetch = (~setStatusDict) => { fetchChartData } -external formEventToStr: ReactEvent.Form.t => string = "%identity" external tofloat: string => float = "%identity" let granularityMapper = (granularity: granularity) => { @@ -862,7 +861,9 @@ let make = ( let _inputChart: ReactFinalForm.fieldRenderPropsInput = { name: "inputChart", onChange: ev => { - updateChartCompFilters(Js.Dict.fromArray([("chartType", ev->formEventToStr)])) + updateChartCompFilters( + Js.Dict.fromArray([("chartType", ev->Identity.formReactEventToString)]), + ) }, value: chartTypeFromUrl->Js.Json.string, onBlur: _ev => (), @@ -872,7 +873,9 @@ let make = ( let inputMetricTop: ReactFinalForm.fieldRenderPropsInput = { name: "inputMetricTop", onChange: ev => { - updateChartCompFilters(Js.Dict.fromArray([("chartTopMetric", ev->formEventToStr)])) + updateChartCompFilters( + Js.Dict.fromArray([("chartTopMetric", ev->Identity.formReactEventToString)]), + ) }, value: chartTopMetricFromUrl->Js.Json.string, onBlur: _ev => (), @@ -882,7 +885,9 @@ let make = ( let inputMetricBottom: ReactFinalForm.fieldRenderPropsInput = { name: "inputMetricBottom", onChange: ev => { - updateChartCompFilters(Js.Dict.fromArray([("chartBottomMetric", ev->formEventToStr)])) + updateChartCompFilters( + Js.Dict.fromArray([("chartBottomMetric", ev->Identity.formReactEventToString)]), + ) }, value: chartBottomMetricFromUrl->Js.Json.string, onBlur: _ev => (), diff --git a/src/components/DynamicTabs.res b/src/components/DynamicTabs.res index c00d3a344..f1c6ca47b 100644 --- a/src/components/DynamicTabs.res +++ b/src/components/DynamicTabs.res @@ -177,7 +177,6 @@ module TabInfo = { } } -external syntheticEventAsStr: ReactEvent.Form.t => string = "%identity" module IndicationArrow = { @react.component let make = (~iconName, ~side, ~refElement: React.ref>, ~isVisible) => { diff --git a/src/components/MultiLineInputBox.res b/src/components/MultiLineInputBox.res index c9a016176..166cffabc 100644 --- a/src/components/MultiLineInputBox.res +++ b/src/components/MultiLineInputBox.res @@ -1,4 +1,3 @@ -external toReactFormEvent: 'a => ReactEvent.Form.t = "%identity" @react.component let make = ( ~input: ReactFinalForm.fieldRenderPropsInput, @@ -24,7 +23,7 @@ let make = ( } let handleRemove = _ => { - input.onChange(""->toReactFormEvent) + input.onChange(""->Identity.stringToFormReactEvent) setError(_ => None) setFocus(_ => false) handleRemove() @@ -51,7 +50,7 @@ let make = ( if value === "" || error->Belt.Option.isNone { setFocus(_ => false) - input.onChange(value->toReactFormEvent) + input.onChange(value->Identity.stringToFormReactEvent) setShow(_ => false) } else { setError(_ => error) diff --git a/src/components/MultipleFileUpload.res b/src/components/MultipleFileUpload.res index 56ef8f71a..940ca1b41 100644 --- a/src/components/MultipleFileUpload.res +++ b/src/components/MultipleFileUpload.res @@ -1,4 +1,3 @@ -external toReactEvent: 'a => ReactEvent.Form.t = "%identity" external arrToReactEvent: array => ReactEvent.Form.t = "%identity" external strToReactEvent: string => ReactEvent.Form.t = "%identity" type dataTransfer @@ -48,8 +47,8 @@ let make = ( let showToast = ToastState.useShowToast() React.useEffect2(() => { - fileNamesInput.onChange(fileNames->toReactEvent) - fileTypeInput.onChange(fileTypes->toReactEvent) + fileNamesInput.onChange(fileNames->Identity.anyTypeToReactEvent) + fileTypeInput.onChange(fileTypes->Identity.anyTypeToReactEvent) None }, (fileNames, fileTypes)) @@ -61,7 +60,7 @@ let make = ( ->getArrayFromJson([]) ->Js.Array2.filteri((_, i) => indx != i) ->Js.Json.array - ->toReactEvent, + ->Identity.anyTypeToReactEvent, ) setKey(prev => prev + 1) } @@ -130,7 +129,7 @@ let make = ( } if !isCorrectFileFormat { - input.onChange(toReactEvent("")) + input.onChange(Identity.stringToFormReactEvent("")) toast("Invalid file format", ToastError) } else if isValid { switch sizeLimit { @@ -180,7 +179,7 @@ let make = ( } else { break := true } - input.onChange(toReactEvent(files)) + input.onChange(Identity.anyTypeToReactEvent(files)) } } @@ -226,7 +225,7 @@ let make = ( setFilenames(prev => prev->Js.Array2.concat(filename)) setFileTypes(prev => prev->Js.Array2.concat(mimeType)) input.onChange( - toReactEvent( + Identity.anyTypeToReactEvent( input.value->getArrayFromJson([])->Js.Array2.concat([file->Js.Json.string]), ), ) diff --git a/src/components/NestedDropdown.res b/src/components/NestedDropdown.res index 07a719ae8..0ffe83706 100644 --- a/src/components/NestedDropdown.res +++ b/src/components/NestedDropdown.res @@ -3,7 +3,6 @@ type rec options = { value: string, options?: array, } -external formToArray: 'a => ReactEvent.Form.t = "%identity" module RenderOption = { @react.component @@ -38,7 +37,7 @@ module RenderOption = { } setSelectedData(_ => data) setSelectedDataVal(_ => dataN) - input.onChange(data->formToArray) + input.onChange(data->Identity.anyTypeToReactEvent) } if selectedInd != index { setSelectedInd(_ => index) @@ -134,7 +133,7 @@ module RenderOptionList = { | None => false } let onClick = _ => { - input.onChange(selectedData->formToArray) + input.onChange(selectedData->Identity.anyTypeToReactEvent) } <>
ReactEvent.Form.t = "%identity" -external formEvAsString: ReactEvent.Form.t => string = "%identity" let defaultCellHighlighter = (_): NewCalendar.highlighter => { { diff --git a/src/components/Paginator.res b/src/components/Paginator.res index 55148c49b..94b5faf65 100644 --- a/src/components/Paginator.res +++ b/src/components/Paginator.res @@ -1,5 +1,3 @@ -external formEventToStr: ReactEvent.Form.t => string = "%identity" - @react.component let make = ( ~totalResults, @@ -50,7 +48,7 @@ let make = ( onBlur: _ev => (), onChange: ev => { setResultsPerPage(_ => { - ev->formEventToStr->Belt.Int.fromString->Belt.Option.getWithDefault(15) + ev->Identity.formReactEventToString->Belt.Int.fromString->Belt.Option.getWithDefault(15) }) }, onFocus: _ev => (), diff --git a/src/components/RangeSlider.res b/src/components/RangeSlider.res index b0d7d36f7..d3e28e319 100644 --- a/src/components/RangeSlider.res +++ b/src/components/RangeSlider.res @@ -1,4 +1,3 @@ -external toReactEvent: 'a => ReactEvent.Form.t = "%identity" @react.component let make = ( ~max="5000", @@ -148,7 +147,7 @@ let make = ( maxSlide.value->Js.Json.decodeNumber->Belt.Option.getWithDefault(0.) if minVal >= min && minVal < maxSliderValue { setHasError(((_, max)) => (false, max)) - minSlide.onChange(ev->toReactEvent) + minSlide.onChange(ev->Identity.anyTypeToReactEvent) } else { setHasError(((_, max)) => (true, max)) } @@ -166,7 +165,7 @@ let make = ( maxSlide.value->Js.Json.decodeNumber->Belt.Option.getWithDefault(0.) if minVal >= min && minVal <= maxSliderValue { setHasError(((_, max)) => (false, max)) - minSlide.onChange(ev->toReactEvent) + minSlide.onChange(ev->Identity.anyTypeToReactEvent) } else { setHasError(((_, max)) => (true, max)) } @@ -188,7 +187,7 @@ let make = ( minSlide.value->Js.Json.decodeNumber->Belt.Option.getWithDefault(0.) if maxVal <= max && maxVal > minSliderValue { setHasError(((min, _)) => (min, false)) - maxSlide.onChange(ev->toReactEvent) + maxSlide.onChange(ev->Identity.anyTypeToReactEvent) } else { setHasError(((min, _)) => (min, true)) } @@ -207,7 +206,7 @@ let make = ( if key === "Enter" || keyCode === 13 { if maxVal <= max && maxVal >= minSliderValue { setHasError(((min, _)) => (min, false)) - maxSlide.onChange(ev->toReactEvent) + maxSlide.onChange(ev->Identity.anyTypeToReactEvent) } else { setHasError(((min, _)) => (min, true)) } diff --git a/src/components/RatingOptions.res b/src/components/RatingOptions.res index 33274cb56..5d4f05f2d 100644 --- a/src/components/RatingOptions.res +++ b/src/components/RatingOptions.res @@ -1,5 +1,3 @@ -external toReactEvent: 'a => ReactEvent.Form.t = "%identity" - @react.component let make = (~icons, ~size) => { let (isActive, setIsActive) = React.useState(_ => false) @@ -7,7 +5,7 @@ let make = (~icons, ~size) => { let rating = ratingInput.value->LogicUtils.getIntFromJson(1) let handleClick = ratingNumber => { - ratingInput.onChange(ratingNumber->toReactEvent) + ratingInput.onChange(ratingNumber->Identity.anyTypeToReactEvent) setIsActive(_ => true) } diff --git a/src/components/RedirectSearchInput.res b/src/components/RedirectSearchInput.res index cdf26166e..a603351be 100644 --- a/src/components/RedirectSearchInput.res +++ b/src/components/RedirectSearchInput.res @@ -1,4 +1,3 @@ -external inputAsString: ReactEvent.Form.t => string = "%identity" external stringToForm: string => ReactEvent.Form.t = "%identity" external toReactForm: Js.Json.t => ReactEvent.Form.t = "%identity" @@ -21,7 +20,10 @@ module SearchInput = { let key = ev->ReactEvent.Keyboard.key let keyCode = ev->ReactEvent.Keyboard.keyCode if key === "Enter" || keyCode === 13 { - let value = {ev->ReactEvent.Keyboard.target}["value"]->inputAsString->Js.String2.trim + let value = + {ev->ReactEvent.Keyboard.target}["value"] + ->Identity.formReactEventToString + ->Js.String2.trim if value !== "" { RescriptReactRouter.push(`${redirectUrl}${value}`) } diff --git a/src/components/Table.resi b/src/components/Table.resi index ea3ffbf8c..c2cc56a27 100644 --- a/src/components/Table.resi +++ b/src/components/Table.resi @@ -24,7 +24,6 @@ type filterDataType = TableUtils.filterDataType = | DateTime external formEventToStrArr: ReactEvent.Form.t => array = "%identity" -external formEventToString: ReactEvent.Form.t => string = "%identity" external toReactDOMStyle: Js.Json.t => ReactDOM.style = "%identity" external jsonToStr: Js.Json.t => string = "%identity" type textAlign = TableUtils.textAlign = Left | Right diff --git a/src/components/TableLocalFilters.res b/src/components/TableLocalFilters.res index 17f8d6404..7427f1f66 100644 --- a/src/components/TableLocalFilters.res +++ b/src/components/TableLocalFilters.res @@ -1,5 +1,4 @@ external formEventToJsonArr: ReactEvent.Form.t => array = "%identity" -external inputAsString: ReactEvent.Form.t => string = "%identity" module RangeSliderLocalFilter = { @react.component diff --git a/src/components/TableUtils.res b/src/components/TableUtils.res index 9eb8c3d49..c33117d51 100644 --- a/src/components/TableUtils.res +++ b/src/components/TableUtils.res @@ -76,7 +76,6 @@ type hideItem = { } external formEventToStrArr: ReactEvent.Form.t => array = "%identity" -external formEventToString: ReactEvent.Form.t => string = "%identity" external toReactDOMStyle: Js.Json.t => ReactDOM.style = "%identity" external jsonToStr: Js.Json.t => string = "%identity" diff --git a/src/components/TableUtils.resi b/src/components/TableUtils.resi index 75e0c5e82..2b8a6a9f6 100644 --- a/src/components/TableUtils.resi +++ b/src/components/TableUtils.resi @@ -27,7 +27,6 @@ type selectAllSubmitActions = { } type hideItem = {key: string, value: string} external formEventToStrArr: ReactEvent.Form.t => array = "%identity" -external formEventToString: ReactEvent.Form.t => string = "%identity" external toReactDOMStyle: Js.Json.t => ReactDOM.style = "%identity" external jsonToStr: Js.Json.t => string = "%identity" type textAlign = Left | Right diff --git a/src/components/TimeInput.res b/src/components/TimeInput.res index df5f35606..d37eed727 100644 --- a/src/components/TimeInput.res +++ b/src/components/TimeInput.res @@ -26,8 +26,6 @@ module OptionVals = { } } -external asFormEvent: 'a => ReactEvent.Form.t = "%identity" - @react.component let make = ( ~label=?, @@ -70,7 +68,11 @@ let make = ( let arr = [hourVal, minuteVal, secondsVal] Belt.Array.set(arr, index, newVal)->ignore - arr->Js.Array2.map(padNum)->Js.Array2.joinWith(":")->asFormEvent->input.onChange + arr + ->Js.Array2.map(padNum) + ->Js.Array2.joinWith(":") + ->Identity.anyTypeToReactEvent + ->input.onChange }, (hourVal, minuteVal, secondsVal, input.onChange)) let onHourChange = React.useCallback1(changeVal(0), [changeVal]) let onMinuteChange = React.useCallback1(changeVal(1), [changeVal]) diff --git a/src/components/form/ColorPickerInput.res b/src/components/form/ColorPickerInput.res index ccda34e39..e783a469c 100644 --- a/src/components/form/ColorPickerInput.res +++ b/src/components/form/ColorPickerInput.res @@ -1,4 +1,3 @@ -external toReactEvent: 'a => ReactEvent.Form.t = "%identity" @react.component let make = (~input: ReactFinalForm.fieldRenderPropsInput) => { let (color, setColor) = React.useState(_ => @@ -11,7 +10,7 @@ let make = (~input: ReactFinalForm.fieldRenderPropsInput) => { let onChangeComplete = color => { let hex = color->LogicUtils.getDictFromJsonObject->LogicUtils.getString("hex", "") setColor(_ => hex) - input.onChange(hex->toReactEvent) + input.onChange(hex->Identity.anyTypeToReactEvent) } OutsideClick.useOutsideClick( diff --git a/src/components/form/ComboInputField.res b/src/components/form/ComboInputField.res index 2afcabdb8..ac997028b 100644 --- a/src/components/form/ComboInputField.res +++ b/src/components/form/ComboInputField.res @@ -1,7 +1,5 @@ -external inputAsString: ReactEvent.Form.t => string = "%identity" external inputAsArray: ReactEvent.Form.t => array = "%identity" external stringToForm: string => ReactEvent.Form.t = "%identity" -external toReactForm: 'a => ReactEvent.Form.t = "%identity" open LogicUtils @@ -42,7 +40,11 @@ module BaseComponent = { switch fieldType { | String => val | Array => - val->inputAsString->Js.String2.split(",")->Js.Array2.filter(x => x !== "")->toReactForm + val + ->Identity.formReactEventToString + ->Js.String2.split(",") + ->Js.Array2.filter(x => x !== "") + ->Identity.anyTypeToReactEvent }, ) }, @@ -76,13 +78,19 @@ module BaseComponent = { let handleKeyUp = React.useCallback1(ev => { if !submitOnEnter { - let value = {ev->ReactEvent.Keyboard.target}["value"]->inputAsString->Js.String2.trim + let value = + {ev->ReactEvent.Keyboard.target}["value"] + ->Identity.formReactEventToString + ->Js.String2.trim input.onChange(value->stringToForm) } else { let key = ev->ReactEvent.Keyboard.key let keyCode = ev->ReactEvent.Keyboard.keyCode if key === "Enter" || keyCode === 13 { - let value = {ev->ReactEvent.Keyboard.target}["value"]->inputAsString->Js.String2.trim + let value = + {ev->ReactEvent.Keyboard.target}["value"] + ->Identity.formReactEventToString + ->Js.String2.trim switch customSubmitFunction { | Some(fn) => fn(input, value) | None => @@ -200,7 +208,7 @@ let make = ( onBlur: _ev => (), onChange: ev => { setComboVal(_ => "") - let value = ev->inputAsString + let value = ev->Identity.formReactEventToString form.change(selectedMode, Js.Json.null) setSelectedMode(_ => value) }, diff --git a/src/components/form/FileUpload.res b/src/components/form/FileUpload.res index 5a13c8889..9a008509c 100644 --- a/src/components/form/FileUpload.res +++ b/src/components/form/FileUpload.res @@ -1,4 +1,3 @@ -external toReactEvent: 'a => ReactEvent.Form.t = "%identity" external arrToReactEvent: array => ReactEvent.Form.t = "%identity" external strToReactEvent: string => ReactEvent.Form.t = "%identity" @@ -30,13 +29,13 @@ let make = ( let showToast = ToastState.useShowToast() React.useEffect1(() => { - fileNameInput.onChange(fileName->toReactEvent) + fileNameInput.onChange(fileName->Identity.anyTypeToReactEvent) None }, [fileName]) let clearData = _ev => { setFilename(_ => "") - input.onChange(""->Js.Json.string->toReactEvent) + input.onChange(""->Js.Json.string->Identity.anyTypeToReactEvent) setKey(prev => prev + 1) } @@ -67,7 +66,7 @@ let make = ( | _ => true } if !isCorrectFileFormat { - input.onChange(toReactEvent("")) + input.onChange(Identity.anyTypeToReactEvent("")) toast("Invalid file format", ToastError) } else if isValid { switch rowsLimit { @@ -75,7 +74,7 @@ let make = ( let rows = Js.String2.split(file, "\n")->Js.Array2.length if value !== "" && rows - 1 < val { setFilename(_ => filename) - input.onChange(toReactEvent(value)) + input.onChange(Identity.anyTypeToReactEvent(value)) if showUploadtoast { toast("File Uploaded Successfully", ToastSuccess) } @@ -85,7 +84,7 @@ let make = ( | None => if value !== "" { setFilename(_ => filename) - input.onChange(toReactEvent(value)) + input.onChange(Identity.anyTypeToReactEvent(value)) if showUploadtoast { toast("File Uploaded Successfully", ToastSuccess) diff --git a/src/components/form/MultipleTextInput.res b/src/components/form/MultipleTextInput.res index 090a098a2..dfd361611 100644 --- a/src/components/form/MultipleTextInput.res +++ b/src/components/form/MultipleTextInput.res @@ -1,4 +1,3 @@ -external inputAsString: ReactEvent.Form.t => string = "%identity" external stringToFormEvent: string => ReactEvent.Form.t = "%identity" module Tag = { diff --git a/src/components/form/NumericTextInput.res b/src/components/form/NumericTextInput.res index 344a61c34..aafeecfc6 100644 --- a/src/components/form/NumericTextInput.res +++ b/src/components/form/NumericTextInput.res @@ -1,4 +1,3 @@ -external toReactFormEvent: 'a => ReactEvent.Form.t = "%identity" let getFloat = strJson => strJson->Js.Json.decodeString->Belt.Option.flatMap(Belt.Float.fromString) @react.component @@ -94,10 +93,10 @@ let make = ( setLocalStrValue(_ => finalVal->Js.Json.string) switch finalVal->Js.Json.string->getFloat { - | Some(num) => input.onChange(num->toReactFormEvent) + | Some(num) => input.onChange(num->Identity.anyTypeToReactEvent) | None => if value === "" { - input.onChange(Js.Json.null->toReactFormEvent) + input.onChange(Js.Json.null->Identity.anyTypeToReactEvent) } } }, diff --git a/src/components/form/PasswordStrengthInput.res b/src/components/form/PasswordStrengthInput.res index 0072ebed3..ae8b6d747 100644 --- a/src/components/form/PasswordStrengthInput.res +++ b/src/components/form/PasswordStrengthInput.res @@ -1,5 +1,3 @@ -external inputAsString: ReactEvent.Form.t => string = "%identity" - type regexTest = { regex: Js.Re.t, weight: float, diff --git a/src/components/form/PasswordStrengthInputAsChips.res b/src/components/form/PasswordStrengthInputAsChips.res index 3c1fea597..8995dfb9d 100644 --- a/src/components/form/PasswordStrengthInputAsChips.res +++ b/src/components/form/PasswordStrengthInputAsChips.res @@ -1,5 +1,3 @@ -external inputAsString: ReactEvent.Form.t => string = "%identity" - type passwordCheck = { number: bool, lowercase: bool, diff --git a/src/components/form/SelectBoxCard.res b/src/components/form/SelectBoxCard.res index ad4835aaa..70b94f830 100644 --- a/src/components/form/SelectBoxCard.res +++ b/src/components/form/SelectBoxCard.res @@ -1,7 +1,6 @@ module CustomViewSection = { external formEventToInt: ReactEvent.Form.t => int = "%identity" external formEventToStrArr: ReactEvent.Form.t => array = "%identity" - external formEventToStr: ReactEvent.Form.t => string = "%identity" external arrToFormEvent: array<'a> => ReactEvent.Form.t = "%identity" external jsonArrToa: array => array<'a> = "%identity" @@ -48,7 +47,7 @@ module CustomViewSection = { if !allowMultiSelect { for _ in 1 to ev->formEventToInt { Js.Array2.pop(valueArrReversed) - ->Belt.Option.getWithDefault(getDefaultObj(ev->formEventToStr)) + ->Belt.Option.getWithDefault(getDefaultObj(ev->Identity.formReactEventToString)) ->Js.Array.push(finalArr) ->ignore } diff --git a/src/components/priority-logics/AddPLGateway.res b/src/components/priority-logics/AddPLGateway.res index 6001c2f9b..553368796 100644 --- a/src/components/priority-logics/AddPLGateway.res +++ b/src/components/priority-logics/AddPLGateway.res @@ -1,7 +1,5 @@ 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" type gateway = PriorityLogicUtils.gateway module GatewayView = { @@ -110,7 +108,7 @@ let make = ( onChange: ev => { let newSelectedOptions = ev->formEventToStrArr if newSelectedOptions->Js.Array2.length === 0 { - gateWaysInput.onChange([]->toReactEvent) + gateWaysInput.onChange([]->Identity.anyTypeToReactEvent) } else { let sharePercent = isDistribute ? 100 / newSelectedOptions->Js.Array2.length : 100 let gatewaysArr = newSelectedOptions->Array.mapWithIndex((item, i) => { @@ -126,7 +124,7 @@ let make = ( } obj }) - gateWaysInput.onChange(gatewaysArr->toReactEvent) + gateWaysInput.onChange(gatewaysArr->Identity.anyTypeToReactEvent) } }, onFocus: _ev => (), @@ -149,7 +147,7 @@ let make = ( disableFallback: newDistributeValue ? item.disableFallback : false, } }) - gateWaysInput.onChange(gatewaysArr->toReactEvent) + gateWaysInput.onChange(gatewaysArr->Identity.anyTypeToReactEvent) } } @@ -157,7 +155,7 @@ let make = ( if isDistribute { selectedOptions ->Js.Array2.map(item => {...item, disableFallback: newFallbackValue}) - ->toReactEvent + ->Identity.anyTypeToReactEvent ->gateWaysInput.onChange } } @@ -177,7 +175,7 @@ let make = ( option } }) - gateWaysInput.onChange(newList->toReactEvent) + gateWaysInput.onChange(newList->Identity.anyTypeToReactEvent) } } @@ -189,7 +187,7 @@ let make = ( option } }) - gateWaysInput.onChange(newList->toReactEvent) + gateWaysInput.onChange(newList->Identity.anyTypeToReactEvent) } let removeItem = index => { @@ -197,7 +195,7 @@ let make = ( selectedOptions ->Js.Array2.map(i => i.gateway_name) ->Array.filterWithIndex((_, i) => i !== index) - ->toReactEvent, + ->Identity.anyTypeToReactEvent, ) } @@ -306,7 +304,7 @@ let make = ( { - enforceGatewayPriorityInput.onChange(v->toReactEvent) + enforceGatewayPriorityInput.onChange(v->Identity.anyTypeToReactEvent) }} isDisabled=false /> @@ -324,7 +322,7 @@ let make = ( { - isDistributeInput.onChange(v->toReactEvent) + isDistributeInput.onChange(v->Identity.anyTypeToReactEvent) onClickDistribute(v) }} isDisabled=false diff --git a/src/components/priority-logics/PriorityLogicUtils.res b/src/components/priority-logics/PriorityLogicUtils.res index c5f7c3bb9..219143a86 100644 --- a/src/components/priority-logics/PriorityLogicUtils.res +++ b/src/components/priority-logics/PriorityLogicUtils.res @@ -1,5 +1,3 @@ -external toReactEvent: 'a => ReactEvent.Form.t = "%identity" - type val = StringArray(array) | String(string) | IntArray(array) | Int(int) | Bool(bool) diff --git a/src/entryPoints/hyperswitch/HyperSwitchApp.res b/src/entryPoints/hyperswitch/HyperSwitchApp.res index e8f6b0dcf..56513e9f8 100644 --- a/src/entryPoints/hyperswitch/HyperSwitchApp.res +++ b/src/entryPoints/hyperswitch/HyperSwitchApp.res @@ -1,5 +1,4 @@ type modeType = LiveModeDropDown | TestModeDropDown -external formEventToStr: ReactEvent.Form.t => string = "%identity" open UIUtils open HSwitchUtils open HSLocalStorage diff --git a/src/genericUtils/DOMUtils.res b/src/genericUtils/DOMUtils.res index b7cabfb0e..ba46d9617 100644 --- a/src/genericUtils/DOMUtils.res +++ b/src/genericUtils/DOMUtils.res @@ -16,13 +16,11 @@ external event: string => event = "Event" @val @scope(("window", "location")) external windowOrigin: string = "origin" 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" 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 new file mode 100644 index 000000000..5829ad371 --- /dev/null +++ b/src/genericUtils/Identity.res @@ -0,0 +1,3 @@ +external formReactEventToString: ReactEvent.Form.t => string = "%identity" +external stringToFormReactEvent: string => ReactEvent.Form.t = "%identity" +external anyTypeToReactEvent: 'a => ReactEvent.Form.t = "%identity" diff --git a/src/screens/HyperSwitch/Analytics/Analytics.res b/src/screens/HyperSwitch/Analytics/Analytics.res index 9f54e85ec..454ecf467 100644 --- a/src/screens/HyperSwitch/Analytics/Analytics.res +++ b/src/screens/HyperSwitch/Analytics/Analytics.res @@ -1,10 +1,8 @@ external toString: option => string = "%identity" external convertToStrDict: 't => Js.Json.t = "%identity" -external evToString: ReactEvent.Form.t => string = "%identity" external asJson: 'a => Js.Json.t = "%identity" external sankeyTest: string => SankeyCharts.sankeyEntity = "%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" diff --git a/src/screens/HyperSwitch/Connectors/ConnectorAccountDetails.res b/src/screens/HyperSwitch/Connectors/ConnectorAccountDetails.res index 05be61eba..9b4ae3a84 100644 --- a/src/screens/HyperSwitch/Connectors/ConnectorAccountDetails.res +++ b/src/screens/HyperSwitch/Connectors/ConnectorAccountDetails.res @@ -1,5 +1,4 @@ external formEventToBool: ReactEvent.Form.t => bool = "%identity" -external formEventToStr: ReactEvent.Form.t => string = "%identity" let connectorsWithIntegrationSteps: array = [ ADYEN, diff --git a/src/screens/HyperSwitch/Connectors/ConnectorList.res b/src/screens/HyperSwitch/Connectors/ConnectorList.res index eff322ee2..7936a1322 100644 --- a/src/screens/HyperSwitch/Connectors/ConnectorList.res +++ b/src/screens/HyperSwitch/Connectors/ConnectorList.res @@ -1,5 +1,3 @@ -external formEventToStr: ReactEvent.Form.t => string = "%identity" - let p1MediumTextStyle = HSwitchUtils.getTextClass(~textVariant=P1, ~paragraphTextVariant=Medium, ()) module RequestConnector = { diff --git a/src/screens/HyperSwitch/Connectors/Wallets/ApplePayWalletIntegrationTypes.res b/src/screens/HyperSwitch/Connectors/Wallets/ApplePayWalletIntegrationTypes.res index 3e0da0950..e3438d581 100644 --- a/src/screens/HyperSwitch/Connectors/Wallets/ApplePayWalletIntegrationTypes.res +++ b/src/screens/HyperSwitch/Connectors/Wallets/ApplePayWalletIntegrationTypes.res @@ -7,4 +7,3 @@ type verifyApplePay = { domain_names: array, merchant_connector_account_id: string, } -external toForm: 'a => ReactEvent.Form.t = "%identity" diff --git a/src/screens/HyperSwitch/FraudAndRisk/FRMPaymentMethods.res b/src/screens/HyperSwitch/FraudAndRisk/FRMPaymentMethods.res index 1c16dbcce..361371c48 100644 --- a/src/screens/HyperSwitch/FraudAndRisk/FRMPaymentMethods.res +++ b/src/screens/HyperSwitch/FraudAndRisk/FRMPaymentMethods.res @@ -1,5 +1,4 @@ external convertToJsonDict: 't => Js.Dict.t = "%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 e5f9b2d7b..39ec58d1c 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..ea50ce0f3 100644 --- a/src/screens/HyperSwitch/RoutingRevamp/AddRuleGateway.res +++ b/src/screens/HyperSwitch/RoutingRevamp/AddRuleGateway.res @@ -1,7 +1,5 @@ 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 +20,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 +40,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 +65,7 @@ let make = (~id, ~gatewayOptions, ~isFirst=false, ~isExpanded=false) => { }->toJson } }) - gateWaysInput.onChange(gatewaysArr->toReactEvent) + gateWaysInput.onChange(gatewaysArr->Identity.anyTypeToReactEvent) } }, onFocus: _ev => (), @@ -106,7 +104,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 +132,7 @@ let make = (~id, ~gatewayOptions, ~isFirst=false, ~isExpanded=false) => { }->toJson } }) - gateWaysInput.onChange(newList->toReactEvent) + gateWaysInput.onChange(newList->Identity.anyTypeToReactEvent) } } @@ -145,7 +143,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 +232,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/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 7a102d294..5de1d1904 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 From 11900f1ed11accacc10a8f65c1c8d854d394cf3f Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja <1805317@kiit.ac.in> Date: Mon, 11 Dec 2023 13:27:20 +0530 Subject: [PATCH 2/3] fix: Feature flag revert --- config/FeatureFlag.json | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/config/FeatureFlag.json b/config/FeatureFlag.json index 0106d7dba..9d6e08029 100644 --- a/config/FeatureFlag.json +++ b/config/FeatureFlag.json @@ -1,23 +1,23 @@ { - "test_live_toggle": true, + "test_live_toggle": false, "is_live_mode": false, - "magic_link": true, - "production_access": true, - "quick_start": true, - "switch_merchant": true, - "audit_trail": true, - "system_metrics": true, - "sample_data": true, - "frm": true, - "payout": true, - "recon": true, - "user_management": true, + "magic_link": false, + "production_access": false, + "quick_start": false, + "switch_merchant": false, + "audit_trail": false, + "system_metrics": false, + "sample_data": false, + "frm": false, + "payout": false, + "recon": false, + "user_management": false, "test_processors": true, - "feedback": true, - "verify_connector": true, + "feedback": false, + "verify_connector": false, "mixpanel": false, - "business_profile": true, - "generate_report": true, - "forgot_password": true, + "business_profile": false, + "generate_report": false, + "forgot_password": false, "oss_build": true } From 166bd09dd34b2674571014f93f6e27731f510ca8 Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja <1805317@kiit.ac.in> Date: Mon, 11 Dec 2023 14:34:28 +0530 Subject: [PATCH 3/3] feat: identity added in common files --- src/components/BreadCrumb.res | 2 -- src/components/CsvInputField.res | 6 ++--- src/components/DateOnlySelector.res | 3 +-- src/components/DatePicker.res | 5 ++--- src/components/DateRangePicker.res | 10 +++------ src/components/DynamicChart.res | 2 -- .../InfraDateRangeCustomSelection.res | 1 - src/components/InfraDateRangePicker.res | 12 +++++----- src/components/InputFields.res | 7 +++--- src/components/InputFields.resi | 1 - src/components/LocalFilters.res | 2 -- src/components/MultiLineTextInput.res | 4 +--- src/components/MultipleFileUpload.res | 2 -- src/components/NewCalendar.res | 3 +-- src/components/NewDateRangePicker.res | 22 +++---------------- src/components/ReactWindowTable.res | 3 ++- src/components/RedirectSearchInput.res | 1 - src/components/Table.resi | 1 - src/components/TableUtils.res | 1 - src/components/TableUtils.resi | 1 - src/components/TimeRangeInput.res | 1 - src/components/form/ChipTextInput.res | 3 +-- src/components/form/ComboInputField.res | 7 +++--- src/components/form/FileUpload.res | 3 --- src/components/form/MultipleTextInput.res | 2 -- src/components/form/TextInput.res | 3 +-- .../priority-logics/AddPLGateway.res | 1 - src/genericUtils/Identity.res | 3 +++ .../RoutingRevamp/AddRuleGateway.res | 1 - .../RoutingRevamp/AdvancedRouting.res | 3 +-- src/utils/JsonFlattenUtils.res | 4 +--- 31 files changed, 35 insertions(+), 85 deletions(-) diff --git a/src/components/BreadCrumb.res b/src/components/BreadCrumb.res index 652a9b16e..ae374f060 100644 --- a/src/components/BreadCrumb.res +++ b/src/components/BreadCrumb.res @@ -1,5 +1,3 @@ -external jsonToarr: Js.Json.t => array<'a> = "%identity" - type status = Active | Disabled | Completed type breadCrumb_options = { diff --git a/src/components/CsvInputField.res b/src/components/CsvInputField.res index 6673571da..55f90010a 100644 --- a/src/components/CsvInputField.res +++ b/src/components/CsvInputField.res @@ -1,6 +1,4 @@ external jsonToarr: Js.Json.t => array<'a> = "%identity" -external arrToReactEvent: array => ReactEvent.Form.t = "%identity" -external strToReactEvent: string => ReactEvent.Form.t = "%identity" module FilenameSaver = { @react.component @@ -109,12 +107,12 @@ let make = ( let clearCsv = _evt => { setFilename(_ => "") setKey(pre => pre + 1) - input.onChange(arrToReactEvent([])) + input.onChange(Identity.arrofStringToReactEvent([])) } let clearData = _ev => { setFilename(_ => "") setKey(pre => pre + 1) - input.onChange(strToReactEvent("")) + input.onChange(Identity.stringToFormReactEvent("")) } let toast = (message, toastType) => { diff --git a/src/components/DateOnlySelector.res b/src/components/DateOnlySelector.res index 35353fbd9..a08ffd736 100644 --- a/src/components/DateOnlySelector.res +++ b/src/components/DateOnlySelector.res @@ -1,4 +1,3 @@ -external strToForm: string => ReactEvent.Form.t = "%identity" module DateCalendar = { open Calendar @react.component @@ -55,7 +54,7 @@ let make = (~input: ReactFinalForm.fieldRenderPropsInput) => { let currentDateSplit = Js.String2.split(str, "-") let currentDateDay = currentDateSplit[2]->Belt.Option.getWithDefault("") setSelectedDate(_ => currentDateDay) - input.onChange(currentDateDay->strToForm) + input.onChange(currentDateDay->Identity.stringToFormReactEvent) } OutsideClick.useOutsideClick( ~refs=ArrayOfRef([dropdownRef]), diff --git a/src/components/DatePicker.res b/src/components/DatePicker.res index c37abb8e2..83f694b19 100644 --- a/src/components/DatePicker.res +++ b/src/components/DatePicker.res @@ -1,4 +1,3 @@ -external strToForm: string => ReactEvent.Form.t = "%identity" external jsonToForm: Js.Json.t => ReactEvent.Form.t = "%identity" @react.component @@ -92,7 +91,7 @@ let make = ( currentDateSecondsFormat, ) setDate(_ => currentDateTimeCheck) - input.onChange(currentDateTimeCheck->strToForm) + input.onChange(currentDateTimeCheck->Identity.stringToFormReactEvent) } React.useEffect1(() => { if input.value == ""->Js.Json.string { @@ -198,7 +197,7 @@ let make = ( ) let timestamp = TimeZoneHook.formattedISOString(dateTimeCheck, format) setDate(_ => timestamp) - input.onChange(timestamp->Table.dateFormat(format)->strToForm) + input.onChange(timestamp->Table.dateFormat(format)->Identity.stringToFormReactEvent) } }, onFocus: _ev => (), diff --git a/src/components/DateRangePicker.res b/src/components/DateRangePicker.res index 210fa84f3..96243c58a 100644 --- a/src/components/DateRangePicker.res +++ b/src/components/DateRangePicker.res @@ -1,5 +1,3 @@ -external strToForm: string => ReactEvent.Form.t = "%identity" - let defaultCellHighlighter = (_): Calendar.highlighter => { { highlightSelf: false, @@ -276,7 +274,7 @@ module Base = { setStartDateVal(_ => localStartDate) setEndDateVal(_ => localEndDate) switch optInput { - | Some(ip) => ip.onChange(localOpt->strToForm) + | Some(ip) => ip.onChange(localOpt->Identity.stringToFormReactEvent) | None => () } } @@ -417,7 +415,7 @@ module Base = { setIsDropdownExpanded(_ => false) saveDates() switch optInput { - | Some(ip) => ip.onChange("custom_range"->strToForm) + | Some(ip) => ip.onChange("custom_range"->Identity.stringToFormReactEvent) | None => () } } @@ -884,14 +882,12 @@ module Base = { } } -external asFormEvent: string => ReactEvent.Form.t = "%identity" - let useStateForInput = (input: ReactFinalForm.fieldRenderPropsInput) => { React.useMemo1(() => { let val = input.value->Js.Json.decodeString->Belt.Option.getWithDefault("") let onChange = fn => { let newVal = fn(val) - input.onChange(newVal->asFormEvent) + input.onChange(newVal->Identity.stringToFormReactEvent) } (val, onChange) diff --git a/src/components/DynamicChart.res b/src/components/DynamicChart.res index db014ee6a..ab62cba4a 100644 --- a/src/components/DynamicChart.res +++ b/src/components/DynamicChart.res @@ -292,8 +292,6 @@ let useChartFetch = (~setStatusDict) => { fetchChartData } -external tofloat: string => float = "%identity" - let granularityMapper = (granularity: granularity) => { switch granularity { | G_ONEDAY => "G_ONEDAY" diff --git a/src/components/InfraDateRangeCustomSelection.res b/src/components/InfraDateRangeCustomSelection.res index ab49262ae..9f066fd21 100644 --- a/src/components/InfraDateRangeCustomSelection.res +++ b/src/components/InfraDateRangeCustomSelection.res @@ -1,4 +1,3 @@ -external strToForm: string => ReactEvent.Form.t = "%identity" @send external focus: Dom.element => unit = "focus" type focusElement = From | To diff --git a/src/components/InfraDateRangePicker.res b/src/components/InfraDateRangePicker.res index f2ddbe46a..84b74194a 100644 --- a/src/components/InfraDateRangePicker.res +++ b/src/components/InfraDateRangePicker.res @@ -1,5 +1,3 @@ -external strToForm: string => ReactEvent.Form.t = "%identity" - let useErroryValueResetter = ( input: ReactFinalForm.fieldRenderPropsInput, isoStringToCustomTimeZone, @@ -14,7 +12,7 @@ let useErroryValueResetter = ( } } if input.value->isErroryTimeValue { - input.onChange(""->strToForm) + input.onChange(""->Identity.stringToFormReactEvent) } None @@ -327,7 +325,9 @@ let make = ( sec, ) setStartTime(_ => `${hour}:${min}:${sec}`) - startInput.onChange(TimeZoneHook.formattedISOString(startDateTimeCheck, format)->strToForm) + startInput.onChange( + TimeZoneHook.formattedISOString(startDateTimeCheck, format)->Identity.stringToFormReactEvent, + ) } let changeEndDate = (~hour="23", ~min="59", ~sec="59", ~ele, ()) => { @@ -345,7 +345,9 @@ let make = ( sec, ) setEndTime(_ => `${hour}:${min}:${sec}`) - endInput.onChange(TimeZoneHook.formattedISOString(endDateTimeCheck, format)->strToForm) + endInput.onChange( + TimeZoneHook.formattedISOString(endDateTimeCheck, format)->Identity.stringToFormReactEvent, + ) } let processDate = x => { diff --git a/src/components/InputFields.res b/src/components/InputFields.res index 3aca67b35..c6743ee56 100644 --- a/src/components/InputFields.res +++ b/src/components/InputFields.res @@ -12,7 +12,6 @@ type comboCustomInputRecord = { } module DOBPicker = { - external strToForm: string => ReactEvent.Form.t = "%identity" external jsonToForm: Js.Json.t => ReactEvent.Form.t = "%identity" @react.component let make = ( @@ -47,7 +46,7 @@ module DOBPicker = { val := Js.String.concat("-", val.contents) } setSelectedDate(_ => val.contents) - input.onChange(val.contents->strToForm) + input.onChange(val.contents->Identity.stringToFormReactEvent) } let dropdownRef = React.useRef(Js.Nullable.null) let (isExpanded, setIsExpanded) = React.useState(_ => false) @@ -64,10 +63,10 @@ module DOBPicker = { setIsExpanded(p => !p) if format == "DD-MM-YYYY" { setSelectedDate(_ => changeDOBFormat(str)) - input.onChange(changeDOBFormat(str)->strToForm) + input.onChange(changeDOBFormat(str)->Identity.stringToFormReactEvent) } else { setSelectedDate(_ => str) - input.onChange(str->strToForm) + input.onChange(str->Identity.stringToFormReactEvent) } } React.useEffect1(() => { diff --git a/src/components/InputFields.resi b/src/components/InputFields.resi index 4ab8f9103..9b4cc6ce2 100644 --- a/src/components/InputFields.resi +++ b/src/components/InputFields.resi @@ -5,7 +5,6 @@ type customInputFn = ( type comboCustomInputFn = array => React.element type comboCustomInputRecord = {fn: comboCustomInputFn, names: array} module DOBPicker: { - external strToForm: string => ReactEvent.Form.t = "%identity" external jsonToForm: Js.Json.t => ReactEvent.Form.t = "%identity" @react.component let make: ( diff --git a/src/components/LocalFilters.res b/src/components/LocalFilters.res index 2245f416a..aae59c1bd 100644 --- a/src/components/LocalFilters.res +++ b/src/components/LocalFilters.res @@ -1,8 +1,6 @@ let makeFieldInfo = FormRenderer.makeFieldInfo external formEventToStrArr: ReactEvent.Form.t => array = "%identity" -external jsonToStr: Js.Json.t => array = "%identity" -external typesToFormEvent: string => ReactEvent.Form.t = "%identity" module CheckLocalFilters = { @react.component diff --git a/src/components/MultiLineTextInput.res b/src/components/MultiLineTextInput.res index b0989cc92..a5f47d3f9 100644 --- a/src/components/MultiLineTextInput.res +++ b/src/components/MultiLineTextInput.res @@ -1,5 +1,3 @@ -external stringToFormEvent: string => ReactEvent.Form.t = "%identity" - @react.component let make = ( ~input: ReactFinalForm.fieldRenderPropsInput, @@ -33,7 +31,7 @@ let make = ( val ->Js.String2.replace("", "") - ->stringToFormEvent, + ->Identity.stringToFormReactEvent, ) } None diff --git a/src/components/MultipleFileUpload.res b/src/components/MultipleFileUpload.res index 940ca1b41..7ee859ed2 100644 --- a/src/components/MultipleFileUpload.res +++ b/src/components/MultipleFileUpload.res @@ -1,5 +1,3 @@ -external arrToReactEvent: array => ReactEvent.Form.t = "%identity" -external strToReactEvent: string => ReactEvent.Form.t = "%identity" type dataTransfer @get external dataTransfer: ReactEvent.Mouse.t => 'a = "dataTransfer" @get external files: dataTransfer => 'a = "files" diff --git a/src/components/NewCalendar.res b/src/components/NewCalendar.res index 3c8dba0d8..2440ebb0f 100644 --- a/src/components/NewCalendar.res +++ b/src/components/NewCalendar.res @@ -1,4 +1,3 @@ -external toReactDOMStyle: Js.Json.t => ReactDOM.style = "%identity" open DateTimeUtils type highlighter = { highlightSelf: bool, @@ -495,7 +494,7 @@ let make = ( } let rowInfo = Js.Array2.mapi(dummyRow, rowMapper) -
LogicUtils.getJsonObjectFromDict("style")->toReactDOMStyle}> +
LogicUtils.getJsonObjectFromDict("style")->Identity.jsonToReactDOMStyle}>
{React.string(`${updatedMonth->getMonthInStr} ${newYear->Belt.Int.toString}`)}
diff --git a/src/components/NewDateRangePicker.res b/src/components/NewDateRangePicker.res index 0019862fc..7a94ab608 100644 --- a/src/components/NewDateRangePicker.res +++ b/src/components/NewDateRangePicker.res @@ -1,5 +1,4 @@ open DateTimeUtils -external strToForm: string => ReactEvent.Form.t = "%identity" let defaultCellHighlighter = (_): NewCalendar.highlighter => { { @@ -292,7 +291,7 @@ module Base = { setStartDateVal(_ => localStartDate) setEndDateVal(_ => localEndDate) switch optInput { - | Some(ip) => ip.onChange(localOpt->strToForm) + | Some(ip) => ip.onChange(localOpt->Identity.stringToFormReactEvent) | None => () } } @@ -303,19 +302,6 @@ module Base = { setLocalOpt(_ => optInputVal) } - // OutsideClick.useOutsideClick( - // ~refs=ArrayOfRef([dateRangeRef, dropdownRef]), - // ~isActive=isDropdownExpanded || calendarVisibility, - // ~callback=() => { - // setIsDropdownExpanded(_ => false) - // setCalendarVisibility(p => !p) - // if isDropdownExpandedActual && isCustomSelected { - // resetToInitalValues() - // } - // }, - // (), - // ) - let changeEndDate = (ele, isFromCustomInput, time) => { if disableApply { setIsDropdownExpanded(_ => false) @@ -434,7 +420,7 @@ module Base = { setIsDropdownExpanded(_ => false) saveDates() switch optInput { - | Some(ip) => ip.onChange("custom_range"->strToForm) + | Some(ip) => ip.onChange("custom_range"->Identity.stringToFormReactEvent) | None => () } } @@ -803,14 +789,12 @@ module Base = { } } -external asFormEvent: string => ReactEvent.Form.t = "%identity" - let useStateForInput = (input: ReactFinalForm.fieldRenderPropsInput) => { React.useMemo1(() => { let val = input.value->Js.Json.decodeString->Belt.Option.getWithDefault("") let onChange = fn => { let newVal = fn(val) - input.onChange(newVal->asFormEvent) + input.onChange(newVal->Identity.stringToFormReactEvent) } (val, onChange) diff --git a/src/components/ReactWindowTable.res b/src/components/ReactWindowTable.res index 1df7d96fc..f74387dd2 100644 --- a/src/components/ReactWindowTable.res +++ b/src/components/ReactWindowTable.res @@ -468,7 +468,8 @@ module ReactWindowTableComponent = { let item = rowInfo->Belt.Array.get(rowIndex)->Belt.Option.getWithDefault([]) - let style = index->LogicUtils.getJsonObjectFromDict("style")->toReactDOMStyle + let style = + index->LogicUtils.getJsonObjectFromDict("style")->Identity.jsonToReactDOMStyle <> ReactEvent.Form.t = "%identity" external toReactForm: Js.Json.t => ReactEvent.Form.t = "%identity" module SearchInput = { diff --git a/src/components/Table.resi b/src/components/Table.resi index c2cc56a27..8c2a9e46e 100644 --- a/src/components/Table.resi +++ b/src/components/Table.resi @@ -24,7 +24,6 @@ type filterDataType = TableUtils.filterDataType = | DateTime external formEventToStrArr: ReactEvent.Form.t => array = "%identity" -external toReactDOMStyle: Js.Json.t => ReactDOM.style = "%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 c33117d51..e0ee86655 100644 --- a/src/components/TableUtils.res +++ b/src/components/TableUtils.res @@ -76,7 +76,6 @@ type hideItem = { } external formEventToStrArr: ReactEvent.Form.t => array = "%identity" -external toReactDOMStyle: Js.Json.t => ReactDOM.style = "%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 2b8a6a9f6..8008ebd92 100644 --- a/src/components/TableUtils.resi +++ b/src/components/TableUtils.resi @@ -27,7 +27,6 @@ type selectAllSubmitActions = { } type hideItem = {key: string, value: string} external formEventToStrArr: ReactEvent.Form.t => array = "%identity" -external toReactDOMStyle: Js.Json.t => ReactDOM.style = "%identity" external jsonToStr: Js.Json.t => string = "%identity" type textAlign = Left | Right type fontBold = bool diff --git a/src/components/TimeRangeInput.res b/src/components/TimeRangeInput.res index 274d0eabf..d5b0eead2 100644 --- a/src/components/TimeRangeInput.res +++ b/src/components/TimeRangeInput.res @@ -1,4 +1,3 @@ -external strToForm: string => ReactEvent.Form.t = "%identity" external intToFormEvent: int => ReactEvent.Form.t = "%identity" open TimeRangeInputUtils diff --git a/src/components/form/ChipTextInput.res b/src/components/form/ChipTextInput.res index e1fd86bef..9384a9106 100644 --- a/src/components/form/ChipTextInput.res +++ b/src/components/form/ChipTextInput.res @@ -1,4 +1,3 @@ -external toForm: string => ReactEvent.Form.t = "%identity" @react.component let make = ( ~input: ReactFinalForm.fieldRenderPropsInput, @@ -53,7 +52,7 @@ let make = ( ->Js.Array2.map(Js.String2.trim) ->Js.Array2.filter(x => x !== value) ->Js.Array2.joinWith(", ") - ->toForm, + ->Identity.stringToFormReactEvent, ) }
diff --git a/src/components/form/ComboInputField.res b/src/components/form/ComboInputField.res index ac997028b..370051edf 100644 --- a/src/components/form/ComboInputField.res +++ b/src/components/form/ComboInputField.res @@ -1,5 +1,4 @@ external inputAsArray: ReactEvent.Form.t => array = "%identity" -external stringToForm: string => ReactEvent.Form.t = "%identity" open LogicUtils @@ -82,7 +81,7 @@ module BaseComponent = { {ev->ReactEvent.Keyboard.target}["value"] ->Identity.formReactEventToString ->Js.String2.trim - input.onChange(value->stringToForm) + input.onChange(value->Identity.stringToFormReactEvent) } else { let key = ev->ReactEvent.Keyboard.key let keyCode = ev->ReactEvent.Keyboard.keyCode @@ -95,7 +94,7 @@ module BaseComponent = { | Some(fn) => fn(input, value) | None => if value !== "" { - input.onChange(value->stringToForm) + input.onChange(value->Identity.stringToFormReactEvent) } } } @@ -103,7 +102,7 @@ module BaseComponent = { }, [selectedMode]) let onClick = (_: ReactEvent.Mouse.t) => { - fieldInput.onChange(""->stringToForm) + fieldInput.onChange(""->Identity.stringToFormReactEvent) setComboVal(_ => "") } diff --git a/src/components/form/FileUpload.res b/src/components/form/FileUpload.res index 9a008509c..6a2189823 100644 --- a/src/components/form/FileUpload.res +++ b/src/components/form/FileUpload.res @@ -1,6 +1,3 @@ -external arrToReactEvent: array => ReactEvent.Form.t = "%identity" -external strToReactEvent: string => ReactEvent.Form.t = "%identity" - @val external atob: string => string = "atob" @send external focus: Dom.element => unit = "focus" @react.component diff --git a/src/components/form/MultipleTextInput.res b/src/components/form/MultipleTextInput.res index dfd361611..82e0744b5 100644 --- a/src/components/form/MultipleTextInput.res +++ b/src/components/form/MultipleTextInput.res @@ -1,5 +1,3 @@ -external stringToFormEvent: string => ReactEvent.Form.t = "%identity" - module Tag = { @react.component let make = (~text, ~remove, ~customButtonStyle=?, ~disabled=false) => { diff --git a/src/components/form/TextInput.res b/src/components/form/TextInput.res index 415d61e0f..b29bed4ea 100644 --- a/src/components/form/TextInput.res +++ b/src/components/form/TextInput.res @@ -1,6 +1,5 @@ @send external focus: Dom.element => unit = "focus" @send @return(nullable) external closest: (Dom.element, string) => option = "closest" -external stringToFormEvent: string => ReactEvent.Form.t = "%identity" @react.component let make = ( @@ -98,7 +97,7 @@ let make = ( val ->Js.String2.replace("", "") - ->stringToFormEvent, + ->Identity.stringToFormReactEvent, ) } None diff --git a/src/components/priority-logics/AddPLGateway.res b/src/components/priority-logics/AddPLGateway.res index 553368796..97ca505c1 100644 --- a/src/components/priority-logics/AddPLGateway.res +++ b/src/components/priority-logics/AddPLGateway.res @@ -1,4 +1,3 @@ -external arrToReactEvent: array => ReactEvent.Form.t = "%identity" external formEventToStrArr: ReactEvent.Form.t => array = "%identity" type gateway = PriorityLogicUtils.gateway diff --git a/src/genericUtils/Identity.res b/src/genericUtils/Identity.res index 5829ad371..024baa29c 100644 --- a/src/genericUtils/Identity.res +++ b/src/genericUtils/Identity.res @@ -1,3 +1,6 @@ external formReactEventToString: ReactEvent.Form.t => string = "%identity" external stringToFormReactEvent: string => ReactEvent.Form.t = "%identity" 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" diff --git a/src/screens/HyperSwitch/RoutingRevamp/AddRuleGateway.res b/src/screens/HyperSwitch/RoutingRevamp/AddRuleGateway.res index ea50ce0f3..c662025a3 100644 --- a/src/screens/HyperSwitch/RoutingRevamp/AddRuleGateway.res +++ b/src/screens/HyperSwitch/RoutingRevamp/AddRuleGateway.res @@ -1,4 +1,3 @@ -external arrToReactEvent: array => ReactEvent.Form.t = "%identity" external formEventToStrArr: ReactEvent.Form.t => array = "%identity" external toJson: 'a => Js.Json.t = "%identity" external anyToEnum: 'a => AdvancedRoutingTypes.connectorSelectionData = "%identity" 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/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 {