From ade63aa8177d6269e02ac0db4f6e63867511b661 Mon Sep 17 00:00:00 2001 From: Riddhiagrawal001 <50551695+Riddhiagrawal001@users.noreply.github.com> Date: Mon, 11 Dec 2023 17:17:04 +0530 Subject: [PATCH 01/15] fix: Added configure return url after business profile (#82) Co-authored-by: Pritish Budhiraja <77892330+PritishBudhiraja@users.noreply.github.com> --- .../BusinessMapping/BusinessMappingUtils.res | 2 +- .../BusinessMapping/BusinessProfile.res | 86 +++++++++++++++++-- 2 files changed, 78 insertions(+), 10 deletions(-) diff --git a/src/screens/HyperSwitch/Settings/BusinessMapping/BusinessMappingUtils.res b/src/screens/HyperSwitch/Settings/BusinessMapping/BusinessMappingUtils.res index 6a21fd6cd..6d2cdafd2 100644 --- a/src/screens/HyperSwitch/Settings/BusinessMapping/BusinessMappingUtils.res +++ b/src/screens/HyperSwitch/Settings/BusinessMapping/BusinessMappingUtils.res @@ -17,7 +17,7 @@ let labelField = FormRenderer.makeFieldInfo( (), ) -type modalState = Loading | Edit +type modalState = Loading | Edit | Successful let validateEmptyValue = (key, errors) => { switch key { diff --git a/src/screens/HyperSwitch/Settings/BusinessMapping/BusinessProfile.res b/src/screens/HyperSwitch/Settings/BusinessMapping/BusinessProfile.res index 4cea24ef1..ad54c171b 100644 --- a/src/screens/HyperSwitch/Settings/BusinessMapping/BusinessProfile.res +++ b/src/screens/HyperSwitch/Settings/BusinessMapping/BusinessProfile.res @@ -1,9 +1,30 @@ +module WarningArea = { + @react.component + let make = (~warningText) => { +

+ {"NOTE:"->React.string} + {warningText->React.string} +

+ } +} module AddEntryBtn = { @react.component - let make = (~onSubmit, ~modalState, ~showModal, ~setShowModal, ~list, ~isFromSettings=true) => { + let make = ( + ~onSubmit, + ~modalState, + ~showModal, + ~setShowModal, + ~list, + ~isFromSettings=true, + ~updatedProfileId, + ~setModalState, + ) => { open HSwitchUtils open BusinessMappingUtils - let initialValues = [("profile_name", "Default"->Js.Json.string)]->Js.Dict.fromArray + let initialValues = + [ + ("profile_name", `default${list->Js.Array2.length->string_of_int}`->Js.Json.string), + ]->Js.Dict.fromArray let modalBody =
{switch modalState { @@ -37,9 +58,34 @@ module AddEntryBtn = {
+ | Successful => +
+ +

+ {"Business Profile successfully created! Set up your payments settings like webhooks, return url for your new profile before trying a payment."->React.string} +

+
}} + let modalHeaderText = switch modalState { + | Edit | Loading => "Add Business Profile Name" + | Successful => "Configure payment settings" + } +
- -
-
-

- {`Setup Webhook on ${connectorName->LogicUtils.capitalizeString}`->React.string} -

-

- {"Configure hyperswitch's webhook on your processor's end"->React.string} -

-
- } - /> -
- -} diff --git a/src/screens/HyperSwitch/FraudAndRisk/FRMConfigure.res b/src/screens/HyperSwitch/FraudAndRisk/FRMConfigure.res index f1cce8246..8a804ac3f 100644 --- a/src/screens/HyperSwitch/FraudAndRisk/FRMConfigure.res +++ b/src/screens/HyperSwitch/FraudAndRisk/FRMConfigure.res @@ -120,8 +120,7 @@ let make = () => { setCurrentStep retrivedValues=Some(initialValues) setInitialValues isUpdateFlow /> | SummaryAndTest - | Preview - | _ => + | Preview => }} diff --git a/src/screens/HyperSwitch/FraudAndRisk/FRMInfo.res b/src/screens/HyperSwitch/FraudAndRisk/FRMInfo.res index d613284a0..4c07a6c31 100644 --- a/src/screens/HyperSwitch/FraudAndRisk/FRMInfo.res +++ b/src/screens/HyperSwitch/FraudAndRisk/FRMInfo.res @@ -77,7 +77,7 @@ let getNextStep: ConnectorTypes.steps => ConnectorTypes.steps = currentStep => { | PaymentMethods => IntegFields | IntegFields => SummaryAndTest | SummaryAndTest => SummaryAndTest - | Preview | _ => Preview + | Preview => Preview } } diff --git a/src/screens/HyperSwitch/FraudAndRisk/FRMIntegrationFields.res b/src/screens/HyperSwitch/FraudAndRisk/FRMIntegrationFields.res index 56c3db9d8..33224ae07 100644 --- a/src/screens/HyperSwitch/FraudAndRisk/FRMIntegrationFields.res +++ b/src/screens/HyperSwitch/FraudAndRisk/FRMIntegrationFields.res @@ -2,7 +2,7 @@ module AdvanceSettings = { @react.component let make = (~isUpdateFlow, ~frmName, ~renderCountrySelector) => { let (isFRMSettings, setIsFRMSettings) = React.useState(_ => isUpdateFlow) - + let featureFlagDetails = HyperswitchAtom.featureFlagAtom->Recoil.useRecoilValueFromAtom let form = ReactFinalForm.useForm() let hyperswitchMixPanel = HSMixPanel.useSendEvent() let url = RescriptReactRouter.useUrl() @@ -40,7 +40,7 @@ module AdvanceSettings = { None }, [businessProfileValue.profile_id]) - <> +

@@ -50,7 +50,7 @@ module AdvanceSettings = { - + } } diff --git a/src/screens/HyperSwitch/FraudAndRisk/FRMSummary.res b/src/screens/HyperSwitch/FraudAndRisk/FRMSummary.res index 255e5eff6..a967599f2 100644 --- a/src/screens/HyperSwitch/FraudAndRisk/FRMSummary.res +++ b/src/screens/HyperSwitch/FraudAndRisk/FRMSummary.res @@ -130,20 +130,6 @@ let make = (~initialValues, ~currentStep, ~setCurrentStep, ~isUpdateFlow) => { }}

-
-

{"Processor Mode"->React.string}

-
- {if frmInfo.test_mode { - - {"TEST MODE"->React.string} - - } else { - - {"LIVE MODE"->React.string} - - }} -
-

{"Profile id"->React.string}

{frmInfo.profile_id->React.string}
diff --git a/src/screens/HyperSwitch/Home/CommonConnectorFlow/SetupConnector.res b/src/screens/HyperSwitch/Home/CommonConnectorFlow/SetupConnector.res index 84e126a53..82cdf8b01 100644 --- a/src/screens/HyperSwitch/Home/CommonConnectorFlow/SetupConnector.res +++ b/src/screens/HyperSwitch/Home/CommonConnectorFlow/SetupConnector.res @@ -133,9 +133,11 @@ module ConfigureProcessor = { nextButton={}> - + + + Date: Mon, 11 Dec 2023 14:34:54 +0000 Subject: [PATCH 06/15] chore(version): v1.5.0 --- CHANGELOG.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 13ad1ec53..bd6b18d39 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,29 @@ All notable changes to this project will be documented in this file. See [conven - - - +## 1.5.0 (2023-12-11) + +### Features + +- Refunds search based on refunds id ([#83](https://github.com/juspay/hyperswitch-control-center/pull/83)) ([`f5363b4`](https://github.com/juspay/hyperswitch-control-center/commit/f5363b4ac3547232bd637884bd8a9fad85056608)) +- Identity file changes in Codebase. ([#89](https://github.com/juspay/hyperswitch-control-center/pull/89)) ([`9e3aec7`](https://github.com/juspay/hyperswitch-control-center/commit/9e3aec7f7434cf4610db50a716653e73693aec94)) +- Webhook Section Update - In Connector Preview ([#90](https://github.com/juspay/hyperswitch-control-center/pull/90)) ([`07a2cf1`](https://github.com/juspay/hyperswitch-control-center/commit/07a2cf1d5f36541e69dcf701c38fce33697f0df0)) + +### Bug Fixes + +- Recoil value for feature flag updated ([#85](https://github.com/juspay/hyperswitch-control-center/pull/85)) ([`d7bb46e`](https://github.com/juspay/hyperswitch-control-center/commit/d7bb46e26c766ab8b43488ff42c6a0ad4eb21864)) +- Added configure return url after business profile ([#82](https://github.com/juspay/hyperswitch-control-center/pull/82)) ([`ade63aa`](https://github.com/juspay/hyperswitch-control-center/commit/ade63aa8177d6269e02ac0db4f6e63867511b661)) +- SDK Processing - Go to payments not working fix ([#88](https://github.com/juspay/hyperswitch-control-center/pull/88)) ([`f45d8dd`](https://github.com/juspay/hyperswitch-control-center/commit/f45d8dd6016f859b76013364c83c0758e5a42114)) + +### Refactors + +- Common file for all identity functions ([#86](https://github.com/juspay/hyperswitch-control-center/pull/86)) ([`6ad715f`](https://github.com/juspay/hyperswitch-control-center/commit/6ad715fb11da557f4f07ff35e8f616b69684ff0c)) + +**Full Changelog:** [`v1.4.0...v1.5.0`](https://github.com/juspay/hyperswitch-control-center/compare/v1.4.0...v1.5.0) + +- - - + + ## 1.4.0 (2023-12-08) ### Features From 706a414e4e3f455ebdc9a0cbf792b240e6f1b384 Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja <77892330+PritishBudhiraja@users.noreply.github.com> Date: Mon, 11 Dec 2023 20:05:22 +0530 Subject: [PATCH 07/15] feat: Identity file changes (#91) --- src/components/ButtonGroupIp.res | 3 +- src/components/CsvFileUpload.res | 6 ---- .../CustomCharts/HighchartBarChart.res | 4 +-- .../CustomCharts/LineChartUtils.res | 14 ++++----- src/components/DatePicker.res | 2 -- .../DistributionDonut/DistributionDonut.res | 31 +++++++++---------- src/components/ExportTable.res | 3 +- src/components/HSwitchSingleStatWidget.res | 24 ++++++++------ src/components/HighchartFunnelChart.res | 27 ++++++++-------- src/components/InputFields.res | 4 +-- src/components/InputFields.resi | 2 -- src/components/RedirectSearchInput.res | 2 -- src/components/SelectBox.res | 26 ++++++---------- src/components/SelectBox.resi | 6 ---- src/components/form/MultipleTextInput.res | 4 +-- src/components/form/SelectBoxCard.res | 3 +- .../analytics/EulerAnalyticsLogUtils.res | 1 - src/genericUtils/Identity.res | 4 +++ src/libraries/Highcharts.res | 2 -- src/libraries/SankeyHighcharts.res | 6 ++-- .../HyperSwitch/Analytics/Analytics.res | 3 -- .../RoutingRevamp/AdvancedRouting.res | 7 ++--- .../RoutingRevamp/AdvancedRoutingUIUtils.res | 14 +++++++-- .../HyperSwitch/SDKPayment/SDKPage.res | 4 +-- .../ThreeDSFlow/HSwitchThreeDS.res | 7 ++--- .../AnalyticsCommonComponents.res | 11 ++----- 26 files changed, 95 insertions(+), 125 deletions(-) diff --git a/src/components/ButtonGroupIp.res b/src/components/ButtonGroupIp.res index 5e649003a..58fd16ccb 100644 --- a/src/components/ButtonGroupIp.res +++ b/src/components/ButtonGroupIp.res @@ -1,4 +1,3 @@ -external strToFormEvent: Js.String.t => ReactEvent.Form.t = "%identity" open SelectBox @react.component let make = ( @@ -9,7 +8,7 @@ let make = ( ~isSeparate=false, ~buttonSize=?, ) => { - let onChange = str => input.onChange(str->strToFormEvent) + let onChange = str => input.onChange(str->Identity.stringToFormReactEvent) let buttonState = {isDisabled ? Button.Disabled : Button.Normal} let buttons = diff --git a/src/components/CsvFileUpload.res b/src/components/CsvFileUpload.res index 30629d66a..03548e79e 100644 --- a/src/components/CsvFileUpload.res +++ b/src/components/CsvFileUpload.res @@ -1,12 +1,6 @@ type t - type formData -external formDataToStr: t => string = "%identity" - -external toString: 't => string = "%identity" -external toRef: 'a => 't = "%identity" @new external formData: unit => t = "FormData" - @send external append: (t, string, 'a) => unit = "append" @send external delete: (t, string) => unit = "delete" @send external get: (t, string) => 'k = "get" diff --git a/src/components/CustomCharts/HighchartBarChart.res b/src/components/CustomCharts/HighchartBarChart.res index 81a46ab95..5d5c409c2 100644 --- a/src/components/CustomCharts/HighchartBarChart.res +++ b/src/components/CustomCharts/HighchartBarChart.res @@ -1,5 +1,3 @@ -external objToJson: {..} => Js.Json.t = "%identity" - module RawBarChart = { @react.component let make = (~options: Js.Json.t) => { @@ -59,7 +57,7 @@ module HighBarChart1D = { }, "series": barSeries, "legend": {"enabled": false}, - }->objToJson + }->Identity.genericObjectOrRecordToJson barOption }, (barSeries, gridLineColor)) if barSeries->Js.Array2.length > 0 { diff --git a/src/components/CustomCharts/LineChartUtils.res b/src/components/CustomCharts/LineChartUtils.res index fa44abd58..11075cee5 100644 --- a/src/components/CustomCharts/LineChartUtils.res +++ b/src/components/CustomCharts/LineChartUtils.res @@ -1,8 +1,8 @@ external legendItemAsBool: Highcharts.legendItem => Highcharts.element = "%identity" -external objToJson: {..} => Js.Json.t = "%identity" open LogicUtils open Highcharts +open Identity let defaultColor = "#7cb5ec" let legendColor = [ defaultColor, @@ -804,7 +804,7 @@ let legendItemStyle = (theme: ThemeProvider.theme, legendFontFamilyClass, legend "fontWeight": "500", "fontFamily": legendFontFamilyClass, "fontStyle": "normal", - }->objToJson + }->genericObjectOrRecordToJson | Light => { "color": "rgba(53, 64, 82, 0.8)", @@ -813,7 +813,7 @@ let legendItemStyle = (theme: ThemeProvider.theme, legendFontFamilyClass, legend "fontWeight": "500", "fontFamily": legendFontFamilyClass, "fontStyle": "normal", - }->objToJson + }->genericObjectOrRecordToJson } } @@ -831,7 +831,7 @@ let legendHiddenStyle = ( "fontWeight": "500", "fontFamily": legendFontFamilyClass, "fontStyle": "normal", - }->objToJson + }->genericObjectOrRecordToJson | Light => { "color": "rgba(53, 64, 82, 0.2)", @@ -840,7 +840,7 @@ let legendHiddenStyle = ( "fontWeight": "500", "fontFamily": legendFontFamilyClass, "fontStyle": "normal", - }->objToJson + }->genericObjectOrRecordToJson } } @@ -853,7 +853,7 @@ let chartTitleStyle = (theme: ThemeProvider.theme) => { "fontWeight": "500", "fontFamily": "IBM Plex Sans", "fontStyle": "normal", - }->objToJson + }->genericObjectOrRecordToJson | Light => { "color": "#354052", @@ -861,7 +861,7 @@ let chartTitleStyle = (theme: ThemeProvider.theme) => { "fontWeight": "500", "fontFamily": "IBM Plex Sans", "fontStyle": "normal", - }->objToJson + }->genericObjectOrRecordToJson } } diff --git a/src/components/DatePicker.res b/src/components/DatePicker.res index 83f694b19..f77716bb1 100644 --- a/src/components/DatePicker.res +++ b/src/components/DatePicker.res @@ -1,5 +1,3 @@ -external jsonToForm: Js.Json.t => ReactEvent.Form.t = "%identity" - @react.component let make = ( ~input: ReactFinalForm.fieldRenderPropsInput, diff --git a/src/components/DistributionDonut/DistributionDonut.res b/src/components/DistributionDonut/DistributionDonut.res index 6a056d565..4611f2a6e 100644 --- a/src/components/DistributionDonut/DistributionDonut.res +++ b/src/components/DistributionDonut/DistributionDonut.res @@ -1,5 +1,3 @@ -external objToJson: {..} => Js.Json.t = "%identity" - type dataPoint = {y: int, name: string} module LegendField = { @@ -50,6 +48,7 @@ let make = ( ~data: array, ~getGroupBasedData: (array, string) => array, ) => { + open Identity let (groupBy, setGroupBy) = React.useState(_ => "") let (groupBasedData, setGroupBasedData) = React.useState((_): array => []) let getDonutOptions = (_): Js.Json.t => { @@ -58,37 +57,37 @@ let make = ( "text": Js.Json.null, "align": "center", "margin": 0, - }->objToJson, + }->genericObjectOrRecordToJson, "colors": colors, "credits": { "enabled": false, - }->objToJson, + }->genericObjectOrRecordToJson, "subtitle": { "useHTML": true, "text": getSubtilteHtml(groupBasedData), "floating": true, "verticalAlign": "middle", "y": 10, - }->objToJson, + }->genericObjectOrRecordToJson, "legend": { "enabled": false, - }->objToJson, + }->genericObjectOrRecordToJson, "chart": { "backgroundColor": Js.Json.null, "className": "h-60", "height": 260, "width": 260, "borderColor": Js.Json.null, - }->objToJson, + }->genericObjectOrRecordToJson, "tooltip": { "valueDecimals": 0, "valueSuffix": "", - }->objToJson, + }->genericObjectOrRecordToJson, "plotOptions": { "series": { "animation": { "duration": 0, - }->objToJson, + }->genericObjectOrRecordToJson, "borderWidth": 5, "colorByPoint": true, "type": "pie", @@ -101,23 +100,23 @@ let make = ( "style": { "fontWeight": "bold", "fontSize": "16px", - }->objToJson, + }->genericObjectOrRecordToJson, "connectorWidth": 0, - }->objToJson, - }->objToJson, - }->objToJson, + }->genericObjectOrRecordToJson, + }->genericObjectOrRecordToJson, + }->genericObjectOrRecordToJson, "series": [ { "color": "black", "type": "pie", "name": tooltipTitle, "data": Js.Array.map( - (d: dataPoint): Js.Json.t => {"y": d.y, "name": d.name}->objToJson, + (d: dataPoint): Js.Json.t => {"y": d.y, "name": d.name}->genericObjectOrRecordToJson, groupBasedData, ), - }->objToJson, + }->genericObjectOrRecordToJson, ], - }->objToJson + }->genericObjectOrRecordToJson } React.useEffect1(() => { setGroupBy(_ => diff --git a/src/components/ExportTable.res b/src/components/ExportTable.res index 67a0f834f..452db359a 100644 --- a/src/components/ExportTable.res +++ b/src/components/ExportTable.res @@ -1,4 +1,3 @@ -external convertToStrDict: 't => Js.Json.t = "%identity" @react.component let make = ( ~title: string, @@ -11,7 +10,7 @@ let make = ( let actualDataOrig = tableData ->Belt.Array.keepMap(item => item->Js.Nullable.toOption) - ->Js.Array2.map(convertToStrDict) + ->Js.Array2.map(Identity.genericTypeToJson) let headerNames = visibleColumns->Belt.Array.keepMap(head => { let item = head->getHeading diff --git a/src/components/HSwitchSingleStatWidget.res b/src/components/HSwitchSingleStatWidget.res index f6a4ffa04..1a3666ad9 100644 --- a/src/components/HSwitchSingleStatWidget.res +++ b/src/components/HSwitchSingleStatWidget.res @@ -17,6 +17,7 @@ let make = ( ~statThreshold: Js.Dict.t=Js.Dict.empty(), ~isHomePage=false, ) => { + open Identity let (updateKey, setUpdateKey) = React.useState(_ => false) let sortedData = React.useMemo1(() => { @@ -85,21 +86,21 @@ let make = ( "height": (isHomePage ? "80" : "50")->Some, "width": isHomePage ? None : Some("105"), "events": None, - }->LineChartUtils.objToJson, + }->genericObjectOrRecordToJson, ), title: { "text": "", "style": Js.Json.object_(Js.Dict.empty()), - }->LineChartUtils.objToJson, + }->genericObjectOrRecordToJson, credits: { "enabled": false, }, legend: { "enabled": false, - }->LineChartUtils.objToJson, + }->genericObjectOrRecordToJson, tooltip: { "enabled": false, - }->LineChartUtils.objToJson, + }->genericObjectOrRecordToJson, plotOptions: Some( { "area": { @@ -114,7 +115,7 @@ let make = ( }, }, "lineWidth": 3, - }->LineChartUtils.objToJson, + }->genericObjectOrRecordToJson, "boxplot": { "visible": false, }, @@ -129,21 +130,24 @@ let make = ( "legendItemClick": None, "mouseOver": Some(""), }), - }->LineChartUtils.objToJson, - }->LineChartUtils.objToJson, + }->genericObjectOrRecordToJson, + }->genericObjectOrRecordToJson, ), xAxis: { "type": "datetime", "zoomEnabled": false, - }->LineChartUtils.objToJson, + }->genericObjectOrRecordToJson, yAxis: { "tickPositioner": None, "plotLines": None, "visible": false, - "title": {"text": "", "style": Js.Json.object_(Js.Dict.empty())}->LineChartUtils.objToJson, + "title": { + "text": "", + "style": Js.Json.object_(Js.Dict.empty()), + }->genericObjectOrRecordToJson, "labels": {"formatter": None, "enabled": false, "useHTML": false}->Some, "zoomEnabled": false, - }->LineChartUtils.objToJson, + }->genericObjectOrRecordToJson, series: [ { color: Some(strokeColor), diff --git a/src/components/HighchartFunnelChart.res b/src/components/HighchartFunnelChart.res index 8367ffff4..7f006d707 100644 --- a/src/components/HighchartFunnelChart.res +++ b/src/components/HighchartFunnelChart.res @@ -1,6 +1,5 @@ open Highcharts open LogicUtils -external objToJson: {..} => Js.Json.t = "%identity" type options = {x: int} type tooltipPoints = { name: string, @@ -50,7 +49,7 @@ let make = ( ->Belt.Array.get(0) ->Belt.Option.getWithDefault("")}${opacity}`, "color": `${chartColors->Belt.Array.get(0)->Belt.Option.getWithDefault("")}`, - }->LineChartUtils.objToJson + }->Identity.genericObjectOrRecordToJson }), "area", ) @@ -70,7 +69,7 @@ let make = ( { "name": key, "y": item->Js.Nullable.return, - }->LineChartUtils.objToJson + }->Identity.genericObjectOrRecordToJson }) let values = { "name": key, @@ -78,7 +77,7 @@ let make = ( "color": chartColors->Belt.Array.get(chartItemIndex), "pointPlacement": "on", "legendIndex": chartItemIndex, - }->LineChartUtils.objToJson + }->Identity.genericObjectOrRecordToJson if zonesFor1D->Js.Array2.length !== 0 { Js.Array2.concat( values->getDictFromJsonObject->Js.Dict.entries, @@ -102,12 +101,12 @@ let make = ( "backgroundColor": Js.Nullable.null, "events": None, "marginBottom": 50, - }->objToJson, + }->Identity.genericObjectOrRecordToJson, ), title: { "text": "", "style": Js.Json.object_(Js.Dict.empty()), - }->objToJson, + }->Identity.genericObjectOrRecordToJson, credits: { "enabled": false, }, @@ -129,13 +128,13 @@ let make = ( "style": { "color": theme === Light ? "rgba(246, 248, 249, 1)" : "rgba(25, 26, 26, 1)", }, - }->objToJson, + }->Identity.genericObjectOrRecordToJson, plotOptions: Some( { "area": { "inverted": true, "lineWidth": 2, - }->objToJson, + }->Identity.genericObjectOrRecordToJson, "boxplot": { "visible": false, }, @@ -153,12 +152,12 @@ let make = ( "legendItemClick": None, "mouseOver": Some(""), }), - }->objToJson, - }->objToJson, + }->Identity.genericObjectOrRecordToJson, + }->Identity.genericObjectOrRecordToJson, ), legend: { "enabled": false, - }->objToJson, + }->Identity.genericObjectOrRecordToJson, xAxis: { "visible": true, "lineWidth": 0, @@ -175,7 +174,7 @@ let make = ( }, }, "categories": categories, - }->objToJson, + }->Identity.genericObjectOrRecordToJson, yAxis: { "title": "", "max": maxValueForTheDataSet, @@ -195,8 +194,8 @@ let make = ( "letterSpacing": "1px", "color": theme === Light ? "#4B5468" : "rgba(246, 248, 249, 0.25)", }, - }->objToJson, - }->objToJson, + }->Identity.genericObjectOrRecordToJson, + }->Identity.genericObjectOrRecordToJson, series: chartData, } }, (dataSet, categories, formatter)) diff --git a/src/components/InputFields.res b/src/components/InputFields.res index c6743ee56..d784b24dd 100644 --- a/src/components/InputFields.res +++ b/src/components/InputFields.res @@ -12,7 +12,6 @@ type comboCustomInputRecord = { } module DOBPicker = { - external jsonToForm: Js.Json.t => ReactEvent.Form.t = "%identity" @react.component let make = ( ~input: ReactFinalForm.fieldRenderPropsInput, @@ -154,7 +153,6 @@ module DOBPicker = { } } module NumericArrayInput = { - external jsonToForm: Js.Json.t => ReactEvent.Form.t = "%identity" @react.component let make = (~input: ReactFinalForm.fieldRenderPropsInput, ~placeholder) => { let (localValue, setLocalValue) = React.useState(() => input.value) @@ -173,7 +171,7 @@ module NumericArrayInput = { value->Js.Json.string } setLocalValue(_ => value) - input.onChange(value->jsonToForm) + input.onChange(value->Identity.jsonToFormReactEvent) }, } }, (input, localValue, setLocalValue)) diff --git a/src/components/InputFields.resi b/src/components/InputFields.resi index 9b4cc6ce2..548a553cf 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 jsonToForm: Js.Json.t => ReactEvent.Form.t = "%identity" @react.component let make: ( ~input: ReactFinalForm.fieldRenderPropsInput, @@ -16,7 +15,6 @@ module DOBPicker: { ) => React.element } module NumericArrayInput: { - external jsonToForm: Js.Json.t => ReactEvent.Form.t = "%identity" @react.component let make: (~input: ReactFinalForm.fieldRenderPropsInput, ~placeholder: string) => React.element } diff --git a/src/components/RedirectSearchInput.res b/src/components/RedirectSearchInput.res index b97607155..2cb6408c6 100644 --- a/src/components/RedirectSearchInput.res +++ b/src/components/RedirectSearchInput.res @@ -1,5 +1,3 @@ -external toReactForm: Js.Json.t => ReactEvent.Form.t = "%identity" - module SearchInput = { @react.component let make = ( diff --git a/src/components/SelectBox.res b/src/components/SelectBox.res index 2454906fc..6e36e5bcd 100644 --- a/src/components/SelectBox.res +++ b/src/components/SelectBox.res @@ -434,7 +434,6 @@ let makeOptions = (options: array): array => { } module BaseSelect = { - external toReactFocusEv: Webapi.Dom.FocusEvent.t => ReactEvent.Focus.t = "%identity" @react.component let make = ( ~showSelectAll=true, @@ -554,7 +553,8 @@ module BaseSelect = { } onSelect(data) switch onBlur { - | Some(fn) => "blur"->Webapi.Dom.FocusEvent.make->toReactFocusEv->fn + | Some(fn) => + "blur"->Webapi.Dom.FocusEvent.make->Identity.webAPIFocusEventToReactEventFocus->fn | None => () } } @@ -577,7 +577,8 @@ module BaseSelect = { onSelect(newValues) switch onBlur { - | Some(fn) => "blur"->Webapi.Dom.FocusEvent.make->toReactFocusEv->fn + | Some(fn) => + "blur"->Webapi.Dom.FocusEvent.make->Identity.webAPIFocusEventToReactEventFocus->fn | None => () } } @@ -942,8 +943,6 @@ module BaseSelect = { } module BaseSelectButton = { - external toReactFocusEv: Webapi.Dom.FocusEvent.t => ReactEvent.Focus.t = "%identity" - @react.component let make = ( ~showDropDown=false, @@ -985,7 +984,8 @@ module BaseSelectButton = { setAssignButtonState(_ => true) switch onBlur { - | Some(fn) => "blur"->Webapi.Dom.FocusEvent.make->toReactFocusEv->fn + | Some(fn) => + "blur"->Webapi.Dom.FocusEvent.make->Identity.webAPIFocusEventToReactEventFocus->fn | None => () } } @@ -1105,8 +1105,6 @@ module BaseSelectButton = { } } module BaseRadio = { - external toReactFocusEv: Webapi.Dom.FocusEvent.t => ReactEvent.Focus.t = "%identity" - @react.component let make = ( ~showDropDown=false, @@ -1184,7 +1182,8 @@ module BaseRadio = { } setSearchString(_ => "") switch onBlur { - | Some(fn) => "blur"->Webapi.Dom.FocusEvent.make->toReactFocusEv->fn + | Some(fn) => + "blur"->Webapi.Dom.FocusEvent.make->Identity.webAPIFocusEventToReactEventFocus->fn | None => () } } @@ -1362,8 +1361,6 @@ module BaseRadio = { } module CustomUISearchOptionUI = { - external toReactFocusEv: Webapi.Dom.FocusEvent.t => ReactEvent.Focus.t = "%identity" - @react.component let make = ( ~showDropDown=false, @@ -1415,7 +1412,8 @@ module CustomUISearchOptionUI = { } setSearchString(_ => "") switch onBlur { - | Some(fn) => "blur"->Webapi.Dom.FocusEvent.make->toReactFocusEv->fn + | Some(fn) => + "blur"->Webapi.Dom.FocusEvent.make->Identity.webAPIFocusEventToReactEventFocus->fn | None => () } } @@ -2115,8 +2113,6 @@ module BaseDropdown = { } module InfraSelectBox = { - external toReactFocusEv: Webapi.Dom.FocusEvent.t => ReactEvent.Focus.t = "%identity" - @react.component let make = ( ~options: array, @@ -2186,8 +2182,6 @@ module InfraSelectBox = { } module ChipFilterSelectBox = { - external toReactFocusEv: Webapi.Dom.FocusEvent.t => ReactEvent.Focus.t = "%identity" - @react.component let make = ( ~options: array, diff --git a/src/components/SelectBox.resi b/src/components/SelectBox.resi index c35d29b27..d51532307 100644 --- a/src/components/SelectBox.resi +++ b/src/components/SelectBox.resi @@ -76,7 +76,6 @@ type opt = {name_: string} let makeUpdatedOptions: (array, array) => array let makeOptions: array => array module BaseSelect: { - external toReactFocusEv: Webapi.Dom.FocusEvent.t => ReactEvent.Focus.t = "%identity" @react.component let make: ( ~showSelectAll: bool=?, @@ -133,7 +132,6 @@ module BaseSelect: { ) => React.element } module BaseSelectButton: { - external toReactFocusEv: Webapi.Dom.FocusEvent.t => ReactEvent.Focus.t = "%identity" @react.component let make: ( ~showDropDown: bool=?, @@ -158,7 +156,6 @@ module BaseSelectButton: { ) => React.element } module BaseRadio: { - external toReactFocusEv: Webapi.Dom.FocusEvent.t => ReactEvent.Focus.t = "%identity" @react.component let make: ( ~showDropDown: bool=?, @@ -197,7 +194,6 @@ module BaseRadio: { ) => React.element } module CustomUISearchOptionUI: { - external toReactFocusEv: Webapi.Dom.FocusEvent.t => ReactEvent.Focus.t = "%identity" @react.component let make: ( ~showDropDown: bool=?, @@ -298,7 +294,6 @@ module BaseDropdown: { ) => React.element } module InfraSelectBox: { - external toReactFocusEv: Webapi.Dom.FocusEvent.t => ReactEvent.Focus.t = "%identity" @react.component let make: ( ~options: array, @@ -312,7 +307,6 @@ module InfraSelectBox: { ) => React.element } module ChipFilterSelectBox: { - external toReactFocusEv: Webapi.Dom.FocusEvent.t => ReactEvent.Focus.t = "%identity" @react.component let make: ( ~options: array, diff --git a/src/components/form/MultipleTextInput.res b/src/components/form/MultipleTextInput.res index 82e0744b5..ae847738a 100644 --- a/src/components/form/MultipleTextInput.res +++ b/src/components/form/MultipleTextInput.res @@ -27,7 +27,7 @@ module Tag = { } } } -external toForm: Js.Array2.t => ReactEvent.Form.t = "%identity" + @react.component let make = ( ~input: ReactFinalForm.fieldRenderPropsInput, @@ -49,7 +49,7 @@ let make = ( }, [input.value]) let setTags = tags => { - tags->toForm->input.onChange + tags->Identity.arrayOfGenericTypeToFormReactEvent->input.onChange } let (text, setText) = React.useState(_ => "") diff --git a/src/components/form/SelectBoxCard.res b/src/components/form/SelectBoxCard.res index 6033b9a67..a91ae97d2 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 arrToFormEvent: array<'a> => ReactEvent.Form.t = "%identity" external jsonArrToa: array => array<'a> = "%identity" @react.component @@ -60,7 +59,7 @@ module CustomViewSection = { ->ignore } } - onChange(finalArr->arrToFormEvent) + onChange(finalArr->Identity.arrayOfGenericTypeToFormReactEvent) }, } input diff --git a/src/entities/analytics/EulerAnalyticsLogUtils.res b/src/entities/analytics/EulerAnalyticsLogUtils.res index 03a1740dc..8fe7d7585 100644 --- a/src/entities/analytics/EulerAnalyticsLogUtils.res +++ b/src/entities/analytics/EulerAnalyticsLogUtils.res @@ -2,7 +2,6 @@ external location: {..} = "location" external toJson: exn => Js.Json.t = "%identity" external toExn: string => exn = "%identity" -external objToJson: {..} => Js.Json.t = "%identity" let useAddLogsAroundFetch = () => { let addLogsAroundFetch = (~setStatusDict=?, ~logTitle, fetchPromise) => { diff --git a/src/genericUtils/Identity.res b/src/genericUtils/Identity.res index b23176438..008ac1180 100644 --- a/src/genericUtils/Identity.res +++ b/src/genericUtils/Identity.res @@ -10,3 +10,7 @@ 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" +external jsonToFormReactEvent: Js.Json.t => ReactEvent.Form.t = "%identity" +external arrayOfGenericTypeToFormReactEvent: array<'a> => ReactEvent.Form.t = "%identity" +external webAPIFocusEventToReactEventFocus: Webapi.Dom.FocusEvent.t => ReactEvent.Focus.t = + "%identity" diff --git a/src/libraries/Highcharts.res b/src/libraries/Highcharts.res index 6f0b19fb4..6da586eb3 100644 --- a/src/libraries/Highcharts.res +++ b/src/libraries/Highcharts.res @@ -50,8 +50,6 @@ external makeSomethingSeries: (~\"type": string, ~something: (float, int, string let x = makeAreaSeries(~\"type"="hello", ~something=false) let y = makeSomethingSeries(~\"type"="hello", ~something=(2., 1, "heloo")) -external makeAttribute: {..} => Js.Json.t = "%identity" - type gridLine = {attr: (. Js.Json.t) => unit} type pos type tick = { diff --git a/src/libraries/SankeyHighcharts.res b/src/libraries/SankeyHighcharts.res index a680a6bdc..e32490914 100644 --- a/src/libraries/SankeyHighcharts.res +++ b/src/libraries/SankeyHighcharts.res @@ -205,9 +205,9 @@ let init = (data: array<(string, string, int, int, int)>, nodes) => { "fontStyle": "normal", "fontWeight": 600, }, - }->LineChartUtils.objToJson, + }->Identity.genericObjectOrRecordToJson, "connectEnds": false, - }->LineChartUtils.objToJson, + }->Identity.genericObjectOrRecordToJson, ], "chart": { "height": 698, @@ -225,7 +225,7 @@ let init = (data: array<(string, string, int, int, int)>, nodes) => { "valueDecimals": 2, "backgroundColor": theme === Dark ? "white" : "black", }, - }->LineChartUtils.objToJson + }->Identity.genericObjectOrRecordToJson options } diff --git a/src/screens/HyperSwitch/Analytics/Analytics.res b/src/screens/HyperSwitch/Analytics/Analytics.res index 2be798615..e4ee6760e 100644 --- a/src/screens/HyperSwitch/Analytics/Analytics.res +++ b/src/screens/HyperSwitch/Analytics/Analytics.res @@ -1,6 +1,3 @@ -external toString: option => string = "%identity" -external convertToStrDict: 't => Js.Json.t = "%identity" -external sankeyTest: string => SankeyCharts.sankeyEntity = "%identity" @get external keyCode: 'a => int = "keyCode" type window @val external window: window = "window" diff --git a/src/screens/HyperSwitch/RoutingRevamp/AdvancedRouting.res b/src/screens/HyperSwitch/RoutingRevamp/AdvancedRouting.res index 86954f45b..076b6c8cd 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 arrToFormEvent: array<'a> => ReactEvent.Form.t = "%identity" external toWasm: Js.Dict.t => RoutingTypes.wasmModule = "%identity" let defaultRule = { @@ -240,7 +239,7 @@ module RuleBasedUI = { let (rules, setRules) = React.useState(_ => ruleInput.value->getArrayFromJson([])) React.useEffect1(() => { - ruleInput.onChange(rules->arrToFormEvent) + ruleInput.onChange(rules->Identity.arrayOfGenericTypeToFormReactEvent) None }, [rules]) @@ -250,13 +249,13 @@ module RuleBasedUI = { ? existingRules[index]->Belt.Option.getWithDefault(defaultRule->Identity.genericTypeToJson) : defaultRule->Identity.genericTypeToJson let newRules = existingRules->Js.Array2.concat([newRule]) - ruleInput.onChange(newRules->arrToFormEvent) + ruleInput.onChange(newRules->Identity.arrayOfGenericTypeToFormReactEvent) } let removeRule = index => { let existingRules = ruleInput.value->getArrayFromJson([]) let newRules = existingRules->Array.filterWithIndex((_, i) => i !== index) - ruleInput.onChange(newRules->arrToFormEvent) + ruleInput.onChange(newRules->Identity.arrayOfGenericTypeToFormReactEvent) }
diff --git a/src/screens/HyperSwitch/RoutingRevamp/AdvancedRoutingUIUtils.res b/src/screens/HyperSwitch/RoutingRevamp/AdvancedRoutingUIUtils.res index 61ef2af65..10d32844e 100644 --- a/src/screens/HyperSwitch/RoutingRevamp/AdvancedRoutingUIUtils.res +++ b/src/screens/HyperSwitch/RoutingRevamp/AdvancedRoutingUIUtils.res @@ -2,7 +2,6 @@ open AdvancedRoutingTypes open AdvancedRoutingUtils open FormRenderer -external arrToFormEvent: array<'a> => ReactEvent.Form.t = "%identity" external strToFormEvent: Js.String.t => ReactEvent.Form.t = "%identity" module LogicalOps = { @@ -398,12 +397,21 @@ module MakeRuleField = { let onPlusClick = _ => { if plusBtnEnabled { let toAdd = Js.Dict.empty() - conditionsInput.onChange(Js.Array2.concat(fields, [toAdd->Js.Json.object_])->arrToFormEvent) + conditionsInput.onChange( + Js.Array2.concat( + fields, + [toAdd->Js.Json.object_], + )->Identity.arrayOfGenericTypeToFormReactEvent, + ) } } let onCrossClick = index => { - conditionsInput.onChange(fields->Array.filterWithIndex((_, i) => index !== i)->arrToFormEvent) + conditionsInput.onChange( + fields + ->Array.filterWithIndex((_, i) => index !== i) + ->Identity.arrayOfGenericTypeToFormReactEvent, + ) }
diff --git a/src/screens/HyperSwitch/SDKPayment/SDKPage.res b/src/screens/HyperSwitch/SDKPayment/SDKPage.res index a4712dd51..4c37a06ed 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 strToFormEvent: Js.String.t => ReactEvent.Form.t = "%identity" module SDKConfiguarationFields = { open MerchantAccountUtils @@ -55,7 +54,8 @@ module SDKConfiguarationFields = { ev => { let eventValueToInt = ev->Identity.formReactEventToString->LogicUtils.getIntFromString(0) - let valInCents = (eventValueToInt * 100)->string_of_int->strToFormEvent + let valInCents = + (eventValueToInt * 100)->string_of_int->Identity.stringToFormReactEvent input.onChange(valInCents) } }, diff --git a/src/screens/HyperSwitch/ThreeDSFlow/HSwitchThreeDS.res b/src/screens/HyperSwitch/ThreeDSFlow/HSwitchThreeDS.res index 96183969f..fc7e3f54f 100644 --- a/src/screens/HyperSwitch/ThreeDSFlow/HSwitchThreeDS.res +++ b/src/screens/HyperSwitch/ThreeDSFlow/HSwitchThreeDS.res @@ -1,6 +1,5 @@ open RoutingTypes external toWasm: Js.Dict.t => wasmModule = "%identity" -external arrToFormEvent: array<'a> => ReactEvent.Form.t = "%identity" module ActiveRulePreview = { open LogicUtils @@ -42,20 +41,20 @@ module Configure3DSRule = { let ruleInput = ReactFinalForm.useField("algorithm.rules").input let (rules, setRules) = React.useState(_ => ruleInput.value->LogicUtils.getArrayFromJson([])) React.useEffect1(() => { - ruleInput.onChange(rules->arrToFormEvent) + ruleInput.onChange(rules->Identity.arrayOfGenericTypeToFormReactEvent) None }, [rules]) let addRule = (index, _copy) => { let existingRules = ruleInput.value->LogicUtils.getArrayFromJson([]) let newRule = existingRules[index]->Belt.Option.getWithDefault(Js.Json.null) let newRules = existingRules->Js.Array2.concat([newRule]) - ruleInput.onChange(newRules->arrToFormEvent) + ruleInput.onChange(newRules->Identity.arrayOfGenericTypeToFormReactEvent) } let removeRule = index => { let existingRules = ruleInput.value->LogicUtils.getArrayFromJson([]) let newRules = existingRules->Array.filterWithIndex((_, i) => i !== index) - ruleInput.onChange(newRules->arrToFormEvent) + ruleInput.onChange(newRules->Identity.arrayOfGenericTypeToFormReactEvent) }
diff --git a/src/screens/analyticsScreens/AnalyticsCommonComponents.res b/src/screens/analyticsScreens/AnalyticsCommonComponents.res index e4a35f44d..e0af3a513 100644 --- a/src/screens/analyticsScreens/AnalyticsCommonComponents.res +++ b/src/screens/analyticsScreens/AnalyticsCommonComponents.res @@ -1,8 +1,3 @@ -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" type window @@ -887,7 +882,7 @@ module FiltersComponent = { filteredTabKeys->Js.Array2.includes(dimension) }) ->Js.Json.array, - }->LineChartUtils.objToJson, + }->Identity.genericObjectOrRecordToJson, ) | None => None } @@ -1090,7 +1085,7 @@ module DownloadCsv = { let actualDataOrig = tableData ->Belt.Array.keepMap(item => item->Js.Nullable.toOption) - ->Js.Array2.map(convertToStrDict) + ->Js.Array2.map(Identity.genericTypeToJson) let headerNames = visibleColumns->Belt.Array.keepMap(head => { let item = head->getHeading @@ -1512,7 +1507,7 @@ module ErrorModalContent = { "credits": { "enabled": false, }, - }->objToJson + }->Identity.genericObjectOrRecordToJson }, (chartData, categoryData, colName, theme)) if showModalBarChart == "Table" {
From 6c3f3cf326c31b3bd2aa8931c169c86238d9ad88 Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja <77892330+PritishBudhiraja@users.noreply.github.com> Date: Tue, 12 Dec 2023 12:20:09 +0530 Subject: [PATCH 08/15] refactor: dead code removal. (#92) --- src/components/MultiLineInputBox.res | 140 - src/components/NProgressIndicator.res | 6 - src/components/Navbar.res | 100 - src/components/NewCalendarList.res | 12 - src/components/NewDateRangePicker.res | 2 +- src/components/NewPagination.res | 7 - src/components/NoDataFound.res | 14 +- src/components/NoteUI.res | 8 - src/components/Pagination.res | 6 - src/components/PaginationRevamp.res | 203 -- src/components/PopOver.res | 50 - src/components/RedirectSearchInput.res | 11 - src/components/RemoteFiltersUtils.res | 168 +- src/components/RouterTabs.res | 68 - src/components/SDKFunnelChart.res | 732 ----- src/components/SankeyUtils.res | 37 +- src/components/SectionAccordion.res | 105 - src/components/ServerComponent.res | 14 - src/components/SidebarStyleUtils.res | 55 - src/components/StagedProgressBar.res | 93 - src/components/StaticTable.res | 211 -- src/components/SynchronizedCharts.res | 294 -- src/components/ThemeSelector.res | 82 - src/components/ThemeToggle.res | 41 - src/components/TimeInput.res | 17 - src/components/TimeRangeInput.res | 242 -- src/components/TimeRangeInputUtils.res | 33 - src/components/Timer.res | 27 - src/components/TopActions.res | 146 - src/components/UploadImage.res | 50 - .../hyperswitch/HyperSwitchApp.res | 11 +- src/genericUtils/AtomsStorage.res | 8 - src/genericUtils/BreadCrumbNavigation.res | 2 - src/genericUtils/UseEvent.res | 12 - src/hooks/AnalyticsHooks.res | 174 - src/hooks/AuthHooks.res | 227 +- src/hooks/DateRefreshHooks.res | 2 +- src/hooks/ModalsState.res | 13 - src/hooks/NewThemeHooks.res | 42 - .../AnalyticsCommonComponents.res | 2809 ----------------- 40 files changed, 31 insertions(+), 6243 deletions(-) delete mode 100644 src/components/MultiLineInputBox.res delete mode 100644 src/components/NProgressIndicator.res delete mode 100644 src/components/NoteUI.res delete mode 100644 src/components/PaginationRevamp.res delete mode 100644 src/components/PopOver.res delete mode 100644 src/components/RouterTabs.res delete mode 100644 src/components/SDKFunnelChart.res delete mode 100644 src/components/SectionAccordion.res delete mode 100644 src/components/ServerComponent.res delete mode 100644 src/components/SidebarStyleUtils.res delete mode 100644 src/components/StagedProgressBar.res delete mode 100644 src/components/StaticTable.res delete mode 100644 src/components/SynchronizedCharts.res delete mode 100644 src/components/ThemeSelector.res delete mode 100644 src/components/ThemeToggle.res delete mode 100644 src/components/TimeRangeInput.res delete mode 100644 src/components/TimeRangeInputUtils.res delete mode 100644 src/components/Timer.res delete mode 100644 src/components/TopActions.res delete mode 100644 src/components/UploadImage.res delete mode 100644 src/genericUtils/AtomsStorage.res delete mode 100644 src/hooks/NewThemeHooks.res delete mode 100644 src/screens/analyticsScreens/AnalyticsCommonComponents.res diff --git a/src/components/MultiLineInputBox.res b/src/components/MultiLineInputBox.res deleted file mode 100644 index 166cffabc..000000000 --- a/src/components/MultiLineInputBox.res +++ /dev/null @@ -1,140 +0,0 @@ -@react.component -let make = ( - ~input: ReactFinalForm.fieldRenderPropsInput, - ~placeholder, - ~isDisabled, - ~rows=?, - ~cols=?, - ~customClass="", - ~readOnly=?, - ~maxLength=?, - ~class="", - ~roundedBorder=false, - ~prefix=?, - ~handleRemove=_ => (), - ~setShow=_ => (), -) => { - let (focus, setFocus) = React.useState(_ => false) - let (error, setError) = React.useState(_ => None) - let cursorClass = if isDisabled { - "cursor-not-allowed" - } else { - "" - } - - let handleRemove = _ => { - input.onChange(""->Identity.stringToFormReactEvent) - setError(_ => None) - setFocus(_ => false) - handleRemove() - } - - let className = `rounded-md border border-jp-gray-lightmode_steelgray border-opacity-75 font-normal p-2 text-jp-gray-900 text-opacity-75 placeholder-jp-gray-900 placeholder-opacity-25 hover:bg-jp-gray-lightmode_steelgray hover:bg-opacity-20 hover:border-jp-gray-900 hover:border-opacity-20 focus:text-opacity-100 focus:outline-none focus:border-blue-800 focus:border-opacity-100 dark:text-jp-gray-text_darktheme dark:text-opacity-75 dark:border-jp-gray-960 dark:hover:border-jp-gray-960 dark:hover:bg-jp-gray-970 dark:bg-jp-gray-darkgray_background dark:placeholder-jp-gray-text_darktheme dark:placeholder-opacity-25 dark:focus:text-opacity-100 dark:focus:border-blue-800 ${cursorClass} ${customClass}` - let value = switch input.value->Js.Json.classify { - | JSONString(str) => str - | JSONNumber(num) => num->Belt.Float.toString - | _ => "" - } - - let onBlur = _ => { - let value = value->Js_string.trim - - let lengthError = - maxLength->Belt.Option.flatMap(length => - value->Js_string.length <= length - ? None - : Some(`Maximum length should be ${length->Belt.Int.toString}`) - ) - - let error = lengthError - - if value === "" || error->Belt.Option.isNone { - setFocus(_ => false) - input.onChange(value->Identity.stringToFormReactEvent) - setShow(_ => false) - } else { - setError(_ => error) - setShow(_ => false) - } - } - - let isError = error->Belt.Option.isSome - - let borderColor = isError - ? "border rounded-md border-red-600 dark:border-red-600" - : focus - ? "border-opacity-100 border-blue-800" - : roundedBorder - ? "border-gray-300 dark:border-jp-gray-800" - : "border-opacity-75 border-gray-300 dark:border-jp-gray-800" - - let textAreaComponent = -