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 diff --git a/package-lock.json b/package-lock.json index 195c36bdd..581a1335b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { - "name": "rescript-euler-dashboard", + "name": "hyperswitch-dashboard", "version": "1.0.5", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "rescript-euler-dashboard", + "name": "hyperswitch-dashboard", "version": "1.0.5", "hasInstallScript": true, "license": "MIT", diff --git a/public/hyperswitch/icons/solid.svg b/public/hyperswitch/icons/solid.svg index 6920b90d2..74489e91d 100644 --- a/public/hyperswitch/icons/solid.svg +++ b/public/hyperswitch/icons/solid.svg @@ -4116,7 +4116,8 @@ License) + fill="#354052" + > + + + + - + - + + + + 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/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/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 8e1360611..03548e79e 100644 --- a/src/components/CsvFileUpload.res +++ b/src/components/CsvFileUpload.res @@ -1,13 +1,6 @@ -external toReactEvent: 'a => ReactEvent.Form.t = "%identity" 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" @@ -28,7 +21,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..55f90010a 100644 --- a/src/components/CsvInputField.res +++ b/src/components/CsvInputField.res @@ -1,13 +1,10 @@ -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" 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]) @@ -110,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) => { @@ -164,7 +161,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 +172,7 @@ let make = ( } | None => { - input.onChange(toReactEvent(res)) + input.onChange(res->Identity.anyTypeToReactEvent) toast("File Uploaded Successfully", ToastSuccess) } } @@ -188,7 +185,7 @@ let make = ( } | _ => setIsNewUpload(_ => true) - input.onChange(toReactEvent(csv)) + input.onChange(csv->Identity.anyTypeToReactEvent) toast("File Uploaded Successfully", ToastSuccess) } } 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/HighchartHorizontalBarChart.res b/src/components/CustomCharts/HighchartHorizontalBarChart.res index 51594df08..dc1f3faa4 100644 --- a/src/components/CustomCharts/HighchartHorizontalBarChart.res +++ b/src/components/CustomCharts/HighchartHorizontalBarChart.res @@ -1,4 +1,3 @@ -external objToJson: 'a => Js.Json.t = "%identity" module RawHBarChart = { @react.component let make = (~options: Js.Json.t) => { @@ -159,7 +158,7 @@ let make = ( enabled: false, }, } - defaultOptions->objToJson + defaultOptions->Identity.genericTypeToJson }, (barChartData, theme)) diff --git a/src/components/CustomCharts/HighchartPieChart.res b/src/components/CustomCharts/HighchartPieChart.res index 572d4b76c..3eb59a4fa 100644 --- a/src/components/CustomCharts/HighchartPieChart.res +++ b/src/components/CustomCharts/HighchartPieChart.res @@ -1,4 +1,3 @@ -external objToJson: 'a => Js.Json.t = "%identity" %%raw(`require("./highcharts.css")`) module RawPieChart = { @react.component @@ -106,7 +105,7 @@ let make = ( backgroundColor: theme === Dark ? "#202124" : "white", }, } - defaultOptions->objToJson + defaultOptions->Identity.genericTypeToJson }, (pieSeriesData, theme)) diff --git a/src/components/CustomCharts/HighchartTimeSeriesChart.res b/src/components/CustomCharts/HighchartTimeSeriesChart.res index 272474225..bb060d79b 100644 --- a/src/components/CustomCharts/HighchartTimeSeriesChart.res +++ b/src/components/CustomCharts/HighchartTimeSeriesChart.res @@ -3,8 +3,6 @@ type domElement open LogicUtils open DictionaryUtils -external toJson: 'a => Js.Json.t = "%identity" - type ele external toElement: Dom.element => ele = "%identity" @@ -43,6 +41,7 @@ module TooltipString = { type legendType = Table | Points module LineChart1D = { + open Identity @react.component let make = ( ~class: string="", @@ -455,14 +454,14 @@ module LineChart1D = { | Table => { "enabled": {isMobileView ? false : showLegend}, - }->DOMUtils.objToJson + }->genericObjectOrRecordToJson | Points => { "enabled": !isMultiDimensional, "itemStyle": legendItemStyle(theme, "IBM Plex Sans", "12px"), "itemHiddenStyle": legendHiddenStyle(theme), "itemHoverStyle": legendItemStyle(theme), - }->DOMUtils.objToJson + }->genericObjectOrRecordToJson } let a: options = { @@ -489,13 +488,13 @@ module LineChart1D = { tick.gridLine.attr(. { "stroke-width": "0", - }->DOMUtils.objToJson, + }->genericObjectOrRecordToJson, ) } else { tick.gridLine.attr(. { "stroke": strokeColor, - }->DOMUtils.objToJson, + }->genericObjectOrRecordToJson, ) } }) @@ -504,13 +503,13 @@ module LineChart1D = { } )->Some, }->Some, - }->DOMUtils.objToJson, + }->genericObjectOrRecordToJson, ) }, title: { "text": chartTitle ? chartTitleText : "", "style": chartTitleStyle, - }->DOMUtils.objToJson, + }->genericObjectOrRecordToJson, credits: { "enabled": false, }, @@ -529,7 +528,7 @@ module LineChart1D = { "style": { "color": theme === Light ? "rgba(246, 248, 249, 1)" : "rgba(25, 26, 26, 1)", }, - }->DOMUtils.objToJson, + }->genericObjectOrRecordToJson, plotOptions: Some( { "area": { @@ -543,7 +542,7 @@ module LineChart1D = { }, "lineWidth": 1.2, "threshold": Js.Nullable.null, - }->DOMUtils.objToJson, + }->genericObjectOrRecordToJson, "line": { "pointStart": None, "fillColor": None, @@ -555,7 +554,7 @@ module LineChart1D = { }, "lineWidth": 1.2, "threshold": Js.Nullable.null, - }->DOMUtils.objToJson, + }->genericObjectOrRecordToJson, "boxplot": { "visible": false, }, @@ -582,20 +581,20 @@ module LineChart1D = { ), "mouseOver": None, }), - }->DOMUtils.objToJson, - }->DOMUtils.objToJson, + }->genericObjectOrRecordToJson, + }->genericObjectOrRecordToJson, ), xAxis: { let defaultValue = { "type": "datetime", - }->DOMUtils.objToJson + }->genericObjectOrRecordToJson let defaultValue = if ( ["run_date", "run_month", "run_week"]->Js.Array2.includes(groupKey) ) { { "type": "category", "tickWidth": 0, - }->DOMUtils.objToJson + }->genericObjectOrRecordToJson } else { defaultValue } @@ -662,7 +661,7 @@ module LineChart1D = { "title": { "text": "", "style": chartTitleStyle, - }->DOMUtils.objToJson, + }->genericObjectOrRecordToJson, "labels": { let labelsValue = { "formatter": Some( @@ -680,11 +679,11 @@ module LineChart1D = { "letterSpacing": "1px", "color": theme === Light ? "#4B5468" : "rgba(246, 248, 249, 0.25)", }, - }->DOMUtils.objToJson + }->genericObjectOrRecordToJson labelsValue->getDictFromJsonObject->deleteKey("style")->Js.Json.object_ }, - }->DOMUtils.objToJson, + }->genericObjectOrRecordToJson, series: chartData, } a diff --git a/src/components/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/CustomExpandableTable.res b/src/components/CustomExpandableTable.res index e6ecb519c..5f8a0453c 100644 --- a/src/components/CustomExpandableTable.res +++ b/src/components/CustomExpandableTable.res @@ -64,7 +64,7 @@ let make = ( { key: string_of_int(i), options: obj.options, - selected: ev->formEventToStrArr, + selected: ev->Identity.formReactEventToArrayOfString, } } else { obj diff --git a/src/components/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 5eb475e1d..f77716bb1 100644 --- a/src/components/DatePicker.res +++ b/src/components/DatePicker.res @@ -1,6 +1,3 @@ -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, @@ -92,7 +89,7 @@ let make = ( currentDateSecondsFormat, ) setDate(_ => currentDateTimeCheck) - input.onChange(currentDateTimeCheck->strToForm) + input.onChange(currentDateTimeCheck->Identity.stringToFormReactEvent) } React.useEffect1(() => { if input.value == ""->Js.Json.string { @@ -167,7 +164,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") @@ -198,7 +195,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 eeb831c42..96243c58a 100644 --- a/src/components/DateRangePicker.res +++ b/src/components/DateRangePicker.res @@ -1,6 +1,3 @@ -external strToForm: string => ReactEvent.Form.t = "%identity" -external formEvAsString: ReactEvent.Form.t => string = "%identity" - let defaultCellHighlighter = (_): Calendar.highlighter => { { highlightSelf: false, @@ -277,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 => () } } @@ -418,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 => () } } @@ -458,7 +455,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 +478,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 { @@ -885,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/DistributionDonut/DistributionDonut.res b/src/components/DistributionDonut/DistributionDonut.res index 623635db1..4611f2a6e 100644 --- a/src/components/DistributionDonut/DistributionDonut.res +++ b/src/components/DistributionDonut/DistributionDonut.res @@ -1,6 +1,3 @@ -external objToJson: {..} => Js.Json.t = "%identity" -external formEventToStr: ReactEvent.Form.t => string = "%identity" - type dataPoint = {y: int, name: string} module LegendField = { @@ -51,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 => { @@ -59,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", @@ -102,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(_ => @@ -160,7 +158,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..ab62cba4a 100644 --- a/src/components/DynamicChart.res +++ b/src/components/DynamicChart.res @@ -292,9 +292,6 @@ let useChartFetch = (~setStatusDict) => { fetchChartData } -external formEventToStr: ReactEvent.Form.t => string = "%identity" -external tofloat: string => float = "%identity" - let granularityMapper = (granularity: granularity) => { switch granularity { | G_ONEDAY => "G_ONEDAY" @@ -862,7 +859,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 +871,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 +883,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/DynamicTableUtils.res b/src/components/DynamicTableUtils.res index fb01ab3d8..b9ff8b725 100644 --- a/src/components/DynamicTableUtils.res +++ b/src/components/DynamicTableUtils.res @@ -2,8 +2,7 @@ let tableHeadingClass = "font-bold text-xl text-black text-opacity-75 dark:text- type view = Table | Card @val @scope(("window", "location")) external reload: unit => unit = "reload" -external convertToJsonDict: 't => Js.Dict.t = "%identity" -external formEventToJsonArr: ReactEvent.Form.t => array = "%identity" + let visibilityColFunc = ( ~dateFormatConvertor: string => option, ~jsonVal: option, @@ -54,7 +53,7 @@ let filteredData = ( switch item->Js.Nullable.toOption { | Some(row) => // either to take this row or not if any filter is present then take row or else drop - let rowDict = row->convertToJsonDict + let rowDict = row->Identity.genericTypeToDictOfJson let anyMatch = selectedFiltersKeys->Js.Array2.find(keys => { // Selected fitler switch Js.Dict.get(columnFilter, keys) { diff --git a/src/components/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/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/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..d784b24dd 100644 --- a/src/components/InputFields.res +++ b/src/components/InputFields.res @@ -12,8 +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 = ( ~input: ReactFinalForm.fieldRenderPropsInput, @@ -47,7 +45,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 +62,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(() => { @@ -155,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) @@ -174,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 4ab8f9103..548a553cf 100644 --- a/src/components/InputFields.resi +++ b/src/components/InputFields.resi @@ -5,8 +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: ( ~input: ReactFinalForm.fieldRenderPropsInput, @@ -17,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/LocalFilters.res b/src/components/LocalFilters.res index 2245f416a..43b5398e1 100644 --- a/src/components/LocalFilters.res +++ b/src/components/LocalFilters.res @@ -1,9 +1,5 @@ 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 let make = ( @@ -33,7 +29,7 @@ module CheckLocalFilters = { None }, [values]) let onChangeSelect = ev => { - let fieldNameArr = ev->formEventToStrArr + let fieldNameArr = ev->Identity.formReactEventToArrayOfString let newlyAdded = Js.Array2.filter(fieldNameArr, newVal => !Js.Array2.includes(checkedFilters, newVal) ) diff --git a/src/components/MultiLineInputBox.res b/src/components/MultiLineInputBox.res deleted file mode 100644 index c9a016176..000000000 --- a/src/components/MultiLineInputBox.res +++ /dev/null @@ -1,141 +0,0 @@ -external toReactFormEvent: 'a => ReactEvent.Form.t = "%identity" -@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(""->toReactFormEvent) - 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->toReactFormEvent) - 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 = -