diff --git a/package.json b/package.json index c7d0738b0..6e4023b74 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "postcss-preset-env": "^6.7.0", "prettier": "^3.1.0", "react-refresh": "^0.10.0", - "rescript": "^10.1.2", + "rescript": "^11.1.1", "serve": "^14.2.1", "terser-webpack-plugin": "^5.1.3", "webpack": "^5.3.2", @@ -65,8 +65,7 @@ "@juspay-tech/react-hyper-js": "^1.0.2", "@monaco-editor/react": "^4.4.5", "@rescript/core": "^0.6.0", - "@rescript/react": "^0.11.0", - "@ryyppy/rescript-promise": "^2.1.0", + "@rescript/react": "^0.12.0", "bs-fetch": "^0.6.2", "csvjson-csv2json": "^5.0.6", "csvjson-json2csv": "^1.0.3", @@ -98,7 +97,7 @@ "react-virtualized-auto-sizer": "^1.0.11", "react-window": "^1.8.8", "recoil": "^0.1.2", - "rescript-webapi": "^0.7.0", + "rescript-webapi": "^0.9.1", "tailwindcss": "^3.0.0" }, "packageManager": "yarn@3.2.1" diff --git a/bsconfig.json b/rescript.json similarity index 91% rename from bsconfig.json rename to rescript.json index 431b5e3f1..9ec78b9a7 100644 --- a/bsconfig.json +++ b/rescript.json @@ -1,6 +1,7 @@ { "$schema": "https://raw.githubusercontent.com/rescript-lang/rescript-compiler/master/docs/docson/build-schema.json", "name": "editor-ui", + "uncurried": true, "jsx": { "version": 4, "mode": "classic" @@ -14,14 +15,13 @@ "namespace": false, "ppx-flags": [], "package-specs": { - "module": "es6", + "module": "esmodule", "in-source": true }, "bs-dependencies": [ "@rescript/react", "rescript-webapi", "bs-fetch", - "@ryyppy/rescript-promise", "@rescript/core" ] } diff --git a/src/Recoils/HyperswitchAtom.res b/src/Recoils/HyperswitchAtom.res index d165a62e2..746c24dfe 100644 --- a/src/Recoils/HyperswitchAtom.res +++ b/src/Recoils/HyperswitchAtom.res @@ -1,40 +1,40 @@ -let merchantDetailsValueAtom: Recoil.recoilAtom = Recoil.atom(. +let merchantDetailsValueAtom: Recoil.recoilAtom = Recoil.atom( "merchantDetailsValue", JSON.Encode.null->MerchantAccountDetailsMapper.getMerchantDetails, ) -let businessProfilesAtom = Recoil.atom(. +let businessProfilesAtom = Recoil.atom( "businessProfileDetails", JSON.Encode.null->BusinessProfileMapper.getArrayOfBusinessProfile, ) -let connectorListAtom: Recoil.recoilAtom> = Recoil.atom(. +let connectorListAtom: Recoil.recoilAtom> = Recoil.atom( "connectorListAtom", JSON.Encode.null->ConnectorListMapper.getArrayOfConnectorListPayloadType, ) -let enumVariantAtom = Recoil.atom(. "enumVariantDetails", "") +let enumVariantAtom = Recoil.atom("enumVariantDetails", "") -let featureFlagAtom: Recoil.recoilAtom = Recoil.atom(. +let featureFlagAtom: Recoil.recoilAtom = Recoil.atom( "featureFlag", JSON.Encode.null->FeatureFlagUtils.featureFlagType, ) -let paypalAccountStatusAtom: Recoil.recoilAtom = Recoil.atom(. +let paypalAccountStatusAtom: Recoil.recoilAtom = Recoil.atom( "paypalAccountStatusAtom", PayPalFlowTypes.Connect_paypal_landing, ) -let userPermissionAtom: Recoil.recoilAtom = Recoil.atom(. +let userPermissionAtom: Recoil.recoilAtom = Recoil.atom( "userPermissionAtom", PermissionUtils.defaultValueForPermission, ) let switchMerchantListAtom: Recoil.recoilAtom< array, -> = Recoil.atom(. "switchMerchantListAtom", [SwitchMerchantUtils.defaultValue]) +> = Recoil.atom("switchMerchantListAtom", [SwitchMerchantUtils.defaultValue]) -let currentTabNameRecoilAtom = Recoil.atom(. "currentTabName", "ActiveTab") +let currentTabNameRecoilAtom = Recoil.atom("currentTabName", "ActiveTab") -let globalSeacrchAtom: Recoil.recoilAtom = Recoil.atom(. +let globalSeacrchAtom: Recoil.recoilAtom = Recoil.atom( "globalSearch", { GlobalSearchTypes.local_results: [], diff --git a/src/Recoils/TableAtoms.res b/src/Recoils/TableAtoms.res index 79e691f1e..08790e3ad 100644 --- a/src/Recoils/TableAtoms.res +++ b/src/Recoils/TableAtoms.res @@ -1,19 +1,13 @@ -let historyDefaultCols = Recoil.atom(. - "hyperSwitchHistoryDefaultCols", - HistoryEntity.defaultColumns, -) +let historyDefaultCols = Recoil.atom("hyperSwitchHistoryDefaultCols", HistoryEntity.defaultColumns) -let refundsMapDefaultCols = Recoil.atom(. "refundsMapDefaultCols", RefundEntity.defaultColumns) +let refundsMapDefaultCols = Recoil.atom("refundsMapDefaultCols", RefundEntity.defaultColumns) -let payoutsMapDefaultCols = Recoil.atom(. "payoutsMapDefaultCols", PayoutsEntity.defaultColumns) +let payoutsMapDefaultCols = Recoil.atom("payoutsMapDefaultCols", PayoutsEntity.defaultColumns) -let ordersMapDefaultCols = Recoil.atom(. "ordersMapDefaultCols", OrderEntity.defaultColumns) +let ordersMapDefaultCols = Recoil.atom("ordersMapDefaultCols", OrderEntity.defaultColumns) -let disputesMapDefaultCols = Recoil.atom(. "disputesMapDefaultCols", DisputesEntity.defaultColumns) +let disputesMapDefaultCols = Recoil.atom("disputesMapDefaultCols", DisputesEntity.defaultColumns) -let apiDefaultCols = Recoil.atom(. "hyperSwitchApiDefaultCols", DeveloperUtils.defaultColumns) +let apiDefaultCols = Recoil.atom("hyperSwitchApiDefaultCols", DeveloperUtils.defaultColumns) -let customersMapDefaultCols = Recoil.atom(. - "customersMapDefaultCols", - CustomersEntity.defaultColumns, -) +let customersMapDefaultCols = Recoil.atom("customersMapDefaultCols", CustomersEntity.defaultColumns) diff --git a/src/components/AdvancedSearchComponent.res b/src/components/AdvancedSearchComponent.res index 1109428f3..af71bc562 100644 --- a/src/components/AdvancedSearchComponent.res +++ b/src/components/AdvancedSearchComponent.res @@ -28,7 +28,7 @@ let make = ( open Promise fetchApi(url, ~bodyStr=JSON.stringify(values), ~method_=Fetch.Post, ()) - ->then(Fetch.Response.json) + ->then(res => res->Fetch.Response.json) ->then(json => { let jsonData = json->JSON.Decode.object->Option.flatMap(dict => dict->Dict.get("rows")) let newData = switch jsonData { diff --git a/src/components/AdvancedSearchModal.res b/src/components/AdvancedSearchModal.res index ee5158220..39a5427dc 100644 --- a/src/components/AdvancedSearchModal.res +++ b/src/components/AdvancedSearchModal.res @@ -35,21 +35,22 @@ module AdvanceSearch = { None } }) - ->Array.joinWith("&") + ->Array.joinWithUnsafe("&") | _ => "" } let finalUrl = otherQueries->isNonEmptyString ? `${url}?${otherQueries}` : url open Promise fetchApi(finalUrl, ~bodyStr=JSON.stringify(initialValueJson), ~method_=Fetch.Get, ()) - ->then(Fetch.Response.json) + ->then(res => res->Fetch.Response.json) ->then(json => { switch JSON.Classify.classify(json) { | Object(jsonDict) => { let statusStr = getString(jsonDict, "status", "FAILURE") if statusStr === "SUCCESS" { - let payloadDict = jsonDict->Dict.get(detailsKey)->Option.flatMap(JSON.Decode.object) + let payloadDict = + jsonDict->Dict.get(detailsKey)->Option.flatMap(obj => obj->JSON.Decode.object) switch payloadDict { | Some(dict) => { @@ -100,7 +101,7 @@ module AdvanceSearch = { if !isSubmitEnabled { Dict.set( errors, - optionalSearchFieldsList->Array.joinWith(","), + optionalSearchFieldsList->Array.joinWithUnsafe(","), "Atleast One of Optional fields is Required"->JSON.Encode.string, ) } diff --git a/src/components/Calendar.res b/src/components/Calendar.res index db12cdfcd..481c44dc7 100644 --- a/src/components/Calendar.res +++ b/src/components/Calendar.res @@ -126,7 +126,7 @@ module TableRow = { | true => switch onDateClick { | Some(fn) => - fn((Date.toISOString(date)->DayJs.getDayJsForString).format(. "YYYY-MM-DD")) + fn((Date.toISOString(date)->DayJs.getDayJsForString).format("YYYY-MM-DD")) | None => () } @@ -134,7 +134,7 @@ module TableRow = { } } let hSelf = highlight( - (Date.toString(date)->DayJs.getDayJsForString).format(. "YYYY-MM-DD"), + (Date.toString(date)->DayJs.getDayJsForString).format("YYYY-MM-DD"), ) let dayClass = if ( @@ -159,13 +159,13 @@ module TableRow = { ) datevalue } - let today = (Date.make()->Date.toString->DayJs.getDayJsForString).format(. "YYYY-MM-DD") + let today = (Date.make()->Date.toString->DayJs.getDayJsForString).format("YYYY-MM-DD") let renderingDate = ( getDate([Float.toString(year), Float.toString(month +. 1.0), obj]) ->Date.toString ->DayJs.getDayJsForString - ).format(. "YYYY-MM-DD") + ).format("YYYY-MM-DD") let textColor = today == renderingDate @@ -227,7 +227,7 @@ module TableRow = { ) } let handleHover = () => { - let date = (Date.toString(date)->DayJs.getDayJsForString).format(. "YYYY-MM-DD") + let date = (Date.toString(date)->DayJs.getDayJsForString).format("YYYY-MM-DD") let parsedDate = getDate(String.split(date, "-")) setHoverdDate(_ => parsedDate->Date.toString) switch setShowMsg { @@ -252,7 +252,7 @@ module TableRow = { className={classN} onClick onMouseOver={_ => handleHover()} - onMouseOut={evt => setHoverdDate(_ => "")}> + onMouseOut={_evt => setHoverdDate(_ => "")}> isEmptyString ? None - : Some((Date.toString(date)->DayJs.getDayJsForString).format(. "YYYY-MM-DD")), + : Some((Date.toString(date)->DayJs.getDayJsForString).format("YYYY-MM-DD")), )} diff --git a/src/components/CalendarList.res b/src/components/CalendarList.res index ec4e46d08..78f9a190b 100644 --- a/src/components/CalendarList.res +++ b/src/components/CalendarList.res @@ -87,7 +87,7 @@ let make = ( Int.toFloat(Float.toInt(Js.Date.getMonth(currDateTemp)) + i), ) let tempMonth = if disableFutureDates { - (Js.Date.fromFloat(tempDate)->DayJs.getDayJsForJsDate).toString(.) + (Js.Date.fromFloat(tempDate)->DayJs.getDayJsForJsDate).toString() ->Date.fromString ->Js.Date.getMonth } else { diff --git a/src/components/CustomCharts/HighchartHorizontalBarChart.res b/src/components/CustomCharts/HighchartHorizontalBarChart.res index b37990980..fe416eba4 100644 --- a/src/components/CustomCharts/HighchartHorizontalBarChart.res +++ b/src/components/CustomCharts/HighchartHorizontalBarChart.res @@ -8,21 +8,21 @@ module RawHBarChart = { } open HighchartsHorizontalBarChart -let valueFormatter = { +let valueFormatter = ( @this (this: tooltipRecord) => { `
${this.category} count: ${this.y->Int.toString}
` } -} +)->asTooltipPointFormatter -let dataLabelFormatter: Js_OO.Callback.arity1 string> = { +let dataLabelFormatter: yAxisRecord => string = ( @this _param => { "" } -} +)->asDataLabelFormatter -let xLabelFormatter: Js_OO.Callback.arity1 string> = { +let xLabelFormatter: xAxisRecord => string = ( @this param => { let axis = param.axis @@ -55,7 +55,7 @@ let xLabelFormatter: Js_OO.Callback.arity1 string> = { (y->Float.fromInt *. 100. /. seriesSum->Float.fromInt) ->Float.toFixedWithPrecision(~digits=2) ++ `%` } -} +)->asXLabelFormatter @react.component let make = ( diff --git a/src/components/CustomCharts/HighchartPieChart.res b/src/components/CustomCharts/HighchartPieChart.res index 18a92e65f..91935c52a 100644 --- a/src/components/CustomCharts/HighchartPieChart.res +++ b/src/components/CustomCharts/HighchartPieChart.res @@ -7,22 +7,22 @@ module RawPieChart = { } open HighchartsPieChart -let valueFormatter = { +let valueFormatter = ( @this (this: tooltipRecord) => { `
${this.name} count: ${this.y->Int.toString}
` } -} +)->asTooltipPointFormatter -let formatter: Js_OO.Callback.arity1 string> = { - @this - param => { - `
` ++ - param.point.name ++ - `

` ++ - param.point.percentage->Float.toFixedWithPrecision(~digits=2) ++ `%
` - } -} +let formatter: yAxisRecord => string = + ( + @this + param => + `
` ++ + param.point.name ++ + `

` ++ + param.point.percentage->Float.toFixedWithPrecision(~digits=2) ++ `%
` + )->asDataLabelFormatter @react.component let make = ( diff --git a/src/components/CustomCharts/HighchartTimeSeriesChart.res b/src/components/CustomCharts/HighchartTimeSeriesChart.res index 24c93fa2e..8cfe11729 100644 --- a/src/components/CustomCharts/HighchartTimeSeriesChart.res +++ b/src/components/CustomCharts/HighchartTimeSeriesChart.res @@ -448,7 +448,7 @@ module LineChart1D = { | Points => { "enabled": !isMultiDimensional, - "itemStyle": legendItemStyle(theme, "IBM Plex Sans", "12px"), + "itemStyle": legendItemStyle(theme)("IBM Plex Sans", "12px"), "itemHiddenStyle": legendHiddenStyle(theme), "itemHoverStyle": legendItemStyle(theme), }->genericObjectOrRecordToJson @@ -464,34 +464,32 @@ module LineChart1D = { "backgroundColor": Nullable.null, "height": Some(chartHeight), "events": { - render: ( - @this - (this: chartEventOnload) => { - let strokeColor = switch theme { - | Dark => "#2e2f39" - | Light => "#e6e6e6" - } - switch this.yAxis[0] { - | Some(ele) => - Highcharts.objectEach(ele.ticks, tick => { - if Some(tick.pos) === thresholdVal { - tick.gridLine.attr(. - { - "stroke-width": "0", - }->genericObjectOrRecordToJson, - ) - } else { - tick.gridLine.attr(. - { - "stroke": strokeColor, - }->genericObjectOrRecordToJson, - ) - } - }) - | None => () - } + render: () => { + let this = thisChartEventOnLoad + let strokeColor = switch theme { + | Dark => "#2e2f39" + | Light => "#e6e6e6" } - )->Some, + switch this.yAxis[0] { + | Some(ele) => + Highcharts.objectEach(ele.ticks, tick => { + if Some(tick.pos) === thresholdVal { + tick.gridLine.attr( + { + "stroke-width": "0", + }->genericObjectOrRecordToJson, + ) + } else { + tick.gridLine.attr( + { + "stroke": strokeColor, + }->genericObjectOrRecordToJson, + ) + } + }) + | None => () + } + }, }->Some, }->genericObjectOrRecordToJson, ) @@ -719,7 +717,7 @@ module LineChart1D = { onEntityClick={val => { setClickedRowNames(val) }} - onEntityDoubleClick={val => { + onEntityDoubleClick={_val => { setClickedRowNamesOrig(_ => []) clickedRowNames->Array.length > 0 ? setHoverOnRows(_ => None) : () }} @@ -728,7 +726,7 @@ module LineChart1D = { ? setHoverOnRows(_ => Some(val.groupByName)) : () }} - onMouseLeave={val => { + onMouseLeave={_val => { clickedRowNames->Array.length === 0 ? setHoverOnRows(_ => None) : () }} isHighchartLegend=true diff --git a/src/components/CustomCharts/LineChartUtils.res b/src/components/CustomCharts/LineChartUtils.res index 448ec2e0f..3346fa25a 100644 --- a/src/components/CustomCharts/LineChartUtils.res +++ b/src/components/CustomCharts/LineChartUtils.res @@ -290,7 +290,7 @@ let timeSeriesDataMaker = ( ) ) ->Array.map(LogicUtils.snakeToTitle) - ->Array.joinWith(" : ") + ->Array.joinWithUnsafe(" : ") | None => dict->getString( groupKey, @@ -298,7 +298,8 @@ let timeSeriesDataMaker = ( ) } - let xAxisDataPoint = dict->getString(xAxis, "")->String.split(" ")->Array.joinWith("T") ++ "Z" // right now it is time string + let xAxisDataPoint = + dict->getString(xAxis, "")->String.split(" ")->Array.joinWithUnsafe("T") ++ "Z" // right now it is time string let yAxisDataPoint = dict->getFloat(yAxis, 0.) let secondryAxisPoint = switch secondryMetrics { @@ -612,31 +613,33 @@ let tooltipFormatter = ( metrics: metricsConfig, xAxisMapInfo: Dict.t)>>, groupKey: string, -) => - @this - (points: JSON.t) => { - let points = points->getDictFromJsonObject - let series = points->getJsonObjectFromDict("series")->getDictFromJsonObject - - let dataArr = if ["run_date", "run_month", "run_week"]->Array.includes(groupKey) { - let x = points->getString("name", "") - xAxisMapInfo->Dict.get(x)->Option.getOr([]) - } else { - let x = points->getFloat("x", 0.) - xAxisMapInfo->Dict.get(x->Float.toString)->Option.getOr([]) - } - - let onCursorName = series->getString("name", "") - let htmlStr = - dataArr - ->Array.map(data => { - getTooltipHTML(metrics, data, onCursorName) - }) - ->Array.joinWith("") - `${htmlStr}
` +) => @this +(points: JSON.t) => { + let points = points->getDictFromJsonObject + let series = points->getJsonObjectFromDict("series")->getDictFromJsonObject + + let dataArr = if ["run_date", "run_month", "run_week"]->Array.includes(groupKey) { + let x = points->getString("name", "") + xAxisMapInfo->Dict.get(x)->Option.getOr([]) + } else { + let x = points->getFloat("x", 0.) + xAxisMapInfo->Dict.get(x->Float.toString)->Option.getOr([]) } -let legendItemStyle = (theme: ThemeProvider.theme, legendFontFamilyClass, legendFontSizeClass) => { + let onCursorName = series->getString("name", "") + let htmlStr = + dataArr + ->Array.map(data => { + getTooltipHTML(metrics, data, onCursorName) + }) + ->Array.joinWithUnsafe("") + `${htmlStr}
` +} + +let legendItemStyle = (theme: ThemeProvider.theme) => ( + legendFontFamilyClass, + legendFontSizeClass, +) => { switch theme { | Dark => { @@ -659,8 +662,7 @@ let legendItemStyle = (theme: ThemeProvider.theme, legendFontFamilyClass, legend } } -let legendHiddenStyle = ( - theme: ThemeProvider.theme, +let legendHiddenStyle = (theme: ThemeProvider.theme) => ( legendFontFamilyClass, legendFontSizeClass, ) => { diff --git a/src/components/DatePicker.res b/src/components/DatePicker.res index f8a14b5b2..80d45ef89 100644 --- a/src/components/DatePicker.res +++ b/src/components/DatePicker.res @@ -164,8 +164,8 @@ let make = ( let timeVal = timeValEv->Identity.formReactEventToString if selectedDate->isNonEmptyString { let todayDayJsObj = Date.make()->Date.toString->DayJs.getDayJsForString - let todayTime = todayDayJsObj.format(. "HH:mm:ss") - let todayDate = todayDayJsObj.format(. "YYYY-MM-DD") + let todayTime = todayDayJsObj.format("HH:mm:ss") + let todayDate = todayDayJsObj.format("YYYY-MM-DD") let timeVal = if disableFutureDates && selectedDate == todayDate && timeVal > todayTime { todayTime } else { diff --git a/src/components/DateRangeField.res b/src/components/DateRangeField.res index 276ec5c93..630e5c0a3 100644 --- a/src/components/DateRangeField.res +++ b/src/components/DateRangeField.res @@ -205,10 +205,10 @@ module Base = { Date.make()->Date.toString->DayJs.getDayJsForString }, [isDropdownExpanded]) - let currentTime = todayDayJsObj.format(. "HH:mm") - let todayDate = todayDayJsObj.format(. "YYYY-MM-DD") + let currentTime = todayDayJsObj.format("HH:mm") + let todayDate = todayDayJsObj.format("YYYY-MM-DD") let todayTime = React.useMemo1(() => { - todayDayJsObj.format(. "HH:mm:ss") + todayDayJsObj.format("HH:mm:ss") }, [currentTime]) let initialStartTime = disableFutureDates || selectStandardTime ? "00:00:00" : "23:59:59" @@ -560,7 +560,7 @@ module Base = { DateRangeUtils.datetext(value, disableFutureDates) ->String.toLowerCase ->String.split(" ") - ->Array.joinWith("_") + ->Array.joinWithUnsafe("_") ) changeStartDate(stDate, false, Some(stTime)) changeEndDate(enDate, false, Some(enTime)) diff --git a/src/components/DateRangePicker.res b/src/components/DateRangePicker.res index 6ed86634e..2f6089026 100644 --- a/src/components/DateRangePicker.res +++ b/src/components/DateRangePicker.res @@ -207,10 +207,10 @@ module Base = { Date.make()->Date.toString->DayJs.getDayJsForString }, [isDropdownExpanded]) - let currentTime = todayDayJsObj.format(. "HH:mm") - let todayDate = todayDayJsObj.format(. "YYYY-MM-DD") + let currentTime = todayDayJsObj.format("HH:mm") + let todayDate = todayDayJsObj.format("YYYY-MM-DD") let todayTime = React.useMemo1(() => { - todayDayJsObj.format(. "HH:mm:ss") + todayDayJsObj.format("HH:mm:ss") }, [currentTime]) let initialStartTime = disableFutureDates || selectStandardTime ? "00:00:00" : "23:59:59" @@ -561,7 +561,7 @@ module Base = { DateRangeUtils.datetext(value, disableFutureDates) ->String.toLowerCase ->String.split(" ") - ->Array.joinWith("_") + ->Array.joinWithUnsafe("_") ) changeStartDate(stDate, false, Some(stTime)) changeEndDate(enDate, false, Some(enTime)) @@ -591,7 +591,7 @@ module Base = { formatDateTime, ) let modifiedStartDate = if removeConversion { - (displayStartDate->DayJs.getDayJsForString).subtract(. 330, "minute").format(. + (displayStartDate->DayJs.getDayJsForString).subtract(330, "minute").format( "YYYY-MM-DDTHH:mm:ss[Z]", ) } else { @@ -601,7 +601,7 @@ module Base = { let displayEndDate = convertTimeStamp(~isoStringToCustomTimeZone, localEndDate, formatDateTime) let modifiedEndDate = if removeConversion { - (displayEndDate->DayJs.getDayJsForString).subtract(. 330, "minute").format(. + (displayEndDate->DayJs.getDayJsForString).subtract(330, "minute").format( "YYYY-MM-DDTHH:mm:ss[Z]", ) } else { diff --git a/src/components/Debounce.res b/src/components/Debounce.res index f36448a28..8821b12fa 100644 --- a/src/components/Debounce.res +++ b/src/components/Debounce.res @@ -35,7 +35,7 @@ let makeControlled = (~wait=100, fn: 'a => unit): debounced<'a> => { if time->shouldCall { call() } else { - timerId := Some(time->remainingWait->setTimeout(timerExpired, _)) + timerId := Some(time->remainingWait->(setTimeout(timerExpired, _))) } } and call = () => { @@ -53,7 +53,7 @@ let makeControlled = (~wait=100, fn: 'a => unit): debounced<'a> => { let time = Date.now()->Int.fromFloat lastArg := Some(x) lastCallTime := Some(time) - timerId := Some(wait->setTimeout(timerExpired, _)) + timerId := Some(wait->(setTimeout(timerExpired, _))) } let scheduled = () => diff --git a/src/components/DynamicChart.res b/src/components/DynamicChart.res index a01ddab67..0eabff8da 100644 --- a/src/components/DynamicChart.res +++ b/src/components/DynamicChart.res @@ -463,7 +463,7 @@ let make = ( None } }) - ->Array.joinWith("&") + ->Array.joinWithUnsafe("&") (filterSearchParam, getTopLevelFilter->getString(customFilterKey, "")) }, [getTopLevelFilter]) @@ -502,7 +502,7 @@ let make = ( | _ => None } }) - ->Array.joinWith("&") + ->Array.joinWithUnsafe("&") filterSearchParam }, [topFiltersToSearchParam]) @@ -523,7 +523,7 @@ let make = ( }) None }, (startTimeFromUrl, endTimeFromUrl)) - let selectedTabStr = selectedTab->Option.getOr([])->Array.joinWith("") + let selectedTabStr = selectedTab->Option.getOr([])->Array.joinWithUnsafe("") let updatedChartConfigArr = React.useMemo7(() => { uriConfig->Array.map(item => { diff --git a/src/components/DynamicFilter.res b/src/components/DynamicFilter.res index 0a1728951..24baf8b15 100644 --- a/src/components/DynamicFilter.res +++ b/src/components/DynamicFilter.res @@ -90,7 +90,7 @@ module CustomFilters = { switch completionDisposable { | Some(_val) => () | None => - setCompletionDisposable(._ => + setCompletionDisposable(_ => Monaco.Language.registerCompletionItemProvider( monaco.languages, "sql", diff --git a/src/components/DynamicSingleStat.res b/src/components/DynamicSingleStat.res index e012bce1e..1a0a545c8 100644 --- a/src/components/DynamicSingleStat.res +++ b/src/components/DynamicSingleStat.res @@ -195,7 +195,7 @@ let make = ( None } }) - ->Array.joinWith("&") + ->Array.joinWithUnsafe("&") (filterSearchParam, getTopLevelFilter->getString(customFilterKey, "")) }, [getTopLevelFilter]) @@ -263,10 +263,7 @@ let make = ( let {uri, metrics} = urlConfig let domain = String.split("/", uri)->Array.get(4)->Option.getOr("") let startTime = if domain === "mandate" { - (endTimeFromUrl->DayJs.getDayJsForString).subtract(. - 1, - "hour", - ).toDate(.)->Date.toISOString + (endTimeFromUrl->DayJs.getDayJsForString).subtract(1, "hour").toDate()->Date.toISOString } else { startTimeFromUrl } @@ -360,10 +357,7 @@ let make = ( let {uri, metrics} = urlConfig let domain = String.split("/", uri)->Array.get(4)->Option.getOr("") let startTime = if domain === "mandate" { - (endTimeFromUrl->DayJs.getDayJsForString).subtract(. - 1, - "hour", - ).toDate(.)->Date.toISOString + (endTimeFromUrl->DayJs.getDayJsForString).subtract(1, "hour").toDate()->Date.toISOString } else { startTimeFromUrl } diff --git a/src/components/DynamicTable.res b/src/components/DynamicTable.res index e07d2fec0..4b0437d78 100644 --- a/src/components/DynamicTable.res +++ b/src/components/DynamicTable.res @@ -117,7 +117,7 @@ let make = ( } = entity let tableName = prefixAddition->Option.getOr(false) - ? title->String.replaceRegExp(_, %re("/ /g"), "-")->String.toLowerCase->Some + ? title->(String.replaceRegExp(_, %re("/ /g"), "-"))->String.toLowerCase->Some : None let (defaultFilters, setDefaultFilters) = React.useState(() => entity.defaultFilters) let defaultSummary: EntityType.summary = {totalCount: 0, count: 0} @@ -210,9 +210,9 @@ let make = ( ->Dict.get(val) ->Option.getOr(searchValueDict->Dict.get(val)->Option.getOr("")) if requireDateFormatting && (val == "startTime" || val == "endTime") { - (x->DayJs.getDayJsForString).format(. "YYYY-MM-DD+HH:mm:ss") + (x->DayJs.getDayJsForString).format("YYYY-MM-DD+HH:mm:ss") } else if requireDateFormatting && (val == "start_date" || val == "end_date") { - (x->DayJs.getDayJsForString).format(. "YYYY-MM-DD HH:mm:ss") + (x->DayJs.getDayJsForString).format("YYYY-MM-DD HH:mm:ss") } else { x } @@ -222,7 +222,7 @@ let make = ( urii }) let uri = - uri ++ "?" ++ uriList->Array.filter(val => val->isNonEmptyString)->Array.joinWith("&") + uri ++ "?" ++ uriList->Array.filter(val => val->isNonEmptyString)->Array.joinWithUnsafe("&") uri } diff --git a/src/components/DynamicTableUtils.res b/src/components/DynamicTableUtils.res index 2383f1efc..de6c5ed5f 100644 --- a/src/components/DynamicTableUtils.res +++ b/src/components/DynamicTableUtils.res @@ -288,7 +288,7 @@ module ChooseColumns = { let (visibleColumns, setVisibleColumns) = Recoil.useRecoilState(activeColumnsAtom) let {getHeading} = entity let setColumns = React.useCallback1(fn => { - setVisibleColumns(. fn) + setVisibleColumns(fn) setShowColumnSelector(_ => false) }, [setVisibleColumns]) if entity.allColumns->Option.isSome && totalResults > 0 { diff --git a/src/components/DynamicTabs.res b/src/components/DynamicTabs.res index b56d5fd59..ab45f1a9a 100644 --- a/src/components/DynamicTabs.res +++ b/src/components/DynamicTabs.res @@ -148,7 +148,7 @@ module TabInfo = { ->String.split("+") ->Array.map(String.trim) ->Array.map(LogicUtils.snakeToTitle) - ->Array.joinWith(" + "), + ->Array.joinWithUnsafe(" + "), )} crossIcon @@ -178,7 +178,7 @@ module IndicationArrow = { refElement.current ->Nullable.toOption ->Option.forEach(input => - input->scrollIntoView(_, {behavior: "smooth", block: "nearest", inline: "nearest"}) + input->(scrollIntoView(_, {behavior: "smooth", block: "nearest", inline: "nearest"})) ) } let roundness = side == "left" ? "rounded-tr-md ml-2" : "rounded-tl-md" @@ -289,14 +289,14 @@ let make = ( ) ->Array.length === 0 - let concatinatedTabNames = tabName->Array.map(getTitle)->Array.joinWith(" + ") + let concatinatedTabNames = tabName->Array.map(getTitle)->Array.joinWithUnsafe(" + ") if validated && tabName->Array.length <= maxSelection && tabName->Array.length > 0 { let newTab = { title: concatinatedTabNames, - value: tabName->Array.joinWith(","), + value: tabName->Array.joinWithUnsafe(","), description: switch tabs->Array.find( item => { - item.value === tabName->Array.joinWith(",") + item.value === tabName->Array.joinWithUnsafe(",") }, ) { | Some(tabValue) => @@ -305,7 +305,7 @@ let make = ( }, isRemovable: switch tabs->Array.find( item => { - item.value === tabName->Array.joinWith(",") + item.value === tabName->Array.joinWithUnsafe(",") }, ) { | Some(tabValue) => tabValue.isRemovable @@ -336,7 +336,7 @@ let make = ( }) ->Array.length === 0 - let concatinatedTabNames = tabName->Array.map(getTitle)->Array.joinWith(" + ") + let concatinatedTabNames = tabName->Array.map(getTitle)->Array.joinWithUnsafe(" + ") if validated && tabName->Array.length <= maxSelection && tabName->Array.length > 0 { let concatinatedTabIndex = @@ -346,7 +346,7 @@ let make = ( let newTab = [ { title: concatinatedTabNames, - value: tabName->Array.joinWith(","), + value: tabName->Array.joinWithUnsafe(","), isRemovable: true, }, ] @@ -478,8 +478,8 @@ let make = ( } let onSubmit = values => { - let tabName = values->Array.map(getTitle)->Array.joinWith(" + ") - let tabValue = values->Array.joinWith(",") + let tabName = values->Array.map(getTitle)->Array.joinWithUnsafe(" + ") + let tabValue = values->Array.joinWithUnsafe(",") if !Array.includes(collapsibleTabs->Array.map(item => item.title), tabName) { let newTab = [ { @@ -501,13 +501,13 @@ let make = ( lastTabRef.current ->Nullable.toOption ->Option.forEach(input => - input->scrollIntoView(_, {behavior: "smooth", block: "nearest", inline: "start"}) + input->(scrollIntoView(_, {behavior: "smooth", block: "nearest", inline: "start"})) ) }, 200)->ignore } else { setSelectedIndex(_ => Array.indexOf(collapsibleTabs->Array.map(item => item.value), tabValue)) - updateTabNameWith(Dict.fromArray([("tabName", `[${values->Array.joinWith(",")}]`)])) - setActiveTab(values->Array.joinWith(",")) + updateTabNameWith(Dict.fromArray([("tabName", `[${values->Array.joinWithUnsafe(",")}]`)])) + setActiveTab(values->Array.joinWithUnsafe(",")) } setShowModal(_ => false) } diff --git a/src/components/Filter.res b/src/components/Filter.res index 837f6101b..b413d362f 100644 --- a/src/components/Filter.res +++ b/src/components/Filter.res @@ -43,7 +43,7 @@ module ClearFilters = { | false => None } }) - ->Array.joinWith("&") + ->Array.joinWithUnsafe("&") searchStr->FilterUtils.parseFilterString->updateExistingKeys } @@ -305,11 +305,11 @@ let make = ( Array.length > 0}> - {menuProps => + {_menuProps =>
- {buttonProps => { + {_buttonProps => { <> {"Add Filters"->React.string} @@ -326,7 +326,7 @@ let make = ( leaveTo="transform opacity-0 scale-95"> { - {props => { + {_props => { <>
{allFilters diff --git a/src/components/FilterSelectBox.res b/src/components/FilterSelectBox.res index f36ca4e64..8eb6d70e7 100644 --- a/src/components/FilterSelectBox.res +++ b/src/components/FilterSelectBox.res @@ -511,7 +511,7 @@ module BaseSelect = { None }, [searchString]) - let onItemClick = (itemDataValue, isDisabled, e) => { + let onItemClick = (itemDataValue, isDisabled) => e => { if !isDisabled { let data = if Array.includes(saneValue, itemDataValue) { let values = @@ -536,7 +536,7 @@ module BaseSelect = { setSearchString(_ => str) } - let selectAll = (select, _ev) => { + let selectAll = select => _ev => { let newValues = if select { let newVal = filteredOptions @@ -641,7 +641,7 @@ module BaseSelect = { }, (noOfSelected, options)) let toggleSelectAll = val => { if !disableSelect { - selectAll(val, "") + selectAll(val)("") setChooseAllToggleSelected(_ => val) } @@ -898,7 +898,7 @@ module BaseSelectButton = { let (itemdata, setItemData) = React.useState(() => "") let (assignButtonState, setAssignButtonState) = React.useState(_ => false) let searchRef = React.useRef(Nullable.null) - let onItemClick = (itemData, _ev) => { + let onItemClick = itemData => _ev => { if !disableSelect { let isSelected = value->JSON.Decode.string->Option.mapOr(false, str => itemData === str) @@ -1210,7 +1210,7 @@ module BaseRadio = { }, (), ) - let onItemClick = (itemData, isDisabled, _ev) => { + let onItemClick = (itemData, isDisabled) => _ev => { if !isDisabled { let isSelected = value->JSON.Decode.string->Option.mapOr(false, str => itemData === str) @@ -1615,7 +1615,7 @@ module BaseDropdown = { } } - let removeOption = (text, _ev) => { + let removeOption = text => _ev => { let actualValue = switch Array.find(transformedOptions, option => option.value == text) { | Some(str) => str.value | None => "" @@ -1698,7 +1698,7 @@ module BaseDropdown = { ->Belt.Array.keepMap(str => { transformedOptions->Array.find(x => x.value == str)->Option.map(x => x.label) }) - ->Array.joinWith(", ") + ->Array.joinWithUnsafe(", ") ->LogicUtils.getNonEmptyString ->Option.getOr(buttonText) }, (transformedOptions, newInputSelect.value)) @@ -1894,7 +1894,7 @@ module BaseDropdown = { ? `Select ${LogicUtils.snakeToTitle(newInputSelect.name)}` : newInputSelect.value ->LogicUtils.getStrArryFromJson - ->Array.joinWith(",\n")} + ->Array.joinWithUnsafe(",\n")} toolTipFor=selectButton toolTipPosition=Bottom tooltipWidthClass="" diff --git a/src/components/FilterUtils.res b/src/components/FilterUtils.res index a746408e4..83e23ae05 100644 --- a/src/components/FilterUtils.res +++ b/src/components/FilterUtils.res @@ -5,7 +5,7 @@ let parseFilterString = queryString => { ->Belt.Array.keepMap(str => { let arr = str->String.split("=") let key = arr->Array.get(0)->Option.getOr("-") - let val = arr->Array.sliceToEnd(~start=1)->Array.joinWith("=") + let val = arr->Array.sliceToEnd(~start=1)->Array.joinWithUnsafe("=") key->LogicUtils.isEmptyString || val->LogicUtils.isEmptyString ? None : Some((key, val)) }) ->Dict.fromArray @@ -18,5 +18,5 @@ let parseFilterDict = dict => { let (key, value) = item `${key}=${value}` }) - ->Array.joinWith("&") + ->Array.joinWithUnsafe("&") } diff --git a/src/components/HeadlessUISelectBox.res b/src/components/HeadlessUISelectBox.res index 1a6231ebf..9965fbf17 100644 --- a/src/components/HeadlessUISelectBox.res +++ b/src/components/HeadlessUISelectBox.res @@ -38,9 +38,9 @@ let make = (
- {menuProps => + {_menuProps =>
- {buttonProps => children} + {_buttonProps => children} - {props => + {_props => options ->Array.mapWithIndex((option, index) => { let selected = switch value { @@ -82,7 +82,7 @@ let make = ( {switch option.leftIcon { | FontAwesome(iconName) => Belt.Option.getWithDefault( + className={`align-middle ${option.customIconStyle->Option.getOr( "", )}`} size=14 @@ -95,10 +95,7 @@ let make = ( | _ => React.null }} -
Belt.Option.getWithDefault( - "", - )}> +
Option.getOr("")}> Belt.Option.getWithDefault( + className={`align-middle ${option.customIconStyle->Option.getOr( "", )}`} size=12 @@ -140,7 +137,7 @@ let make = ( } else { - {props => + {_props => options ->Array.mapWithIndex((option, index) => { let selected = switch value { diff --git a/src/components/InfraCalendar.res b/src/components/InfraCalendar.res index 262a78260..b1105f63c 100644 --- a/src/components/InfraCalendar.res +++ b/src/components/InfraCalendar.res @@ -75,7 +75,7 @@ module TableRow = { switch onDateClick { | Some(fn) => if obj->isNonEmptyString { - fn((Date.toISOString(date)->DayJs.getDayJsForString).format(. "YYYY-MM-DD")) + fn((Date.toISOString(date)->DayJs.getDayJsForString).format("YYYY-MM-DD")) } | None => () } @@ -83,7 +83,7 @@ module TableRow = { } } let hSelf = highlight( - (Date.toString(date)->DayJs.getDayJsForString).format(. "YYYY-MM-DD"), + (Date.toString(date)->DayJs.getDayJsForString).format("YYYY-MM-DD"), ) let dayClass = if ( @@ -160,7 +160,7 @@ module TableRow = { {cellRenderer( obj->isEmptyString ? None - : Some((Date.toString(date)->DayJs.getDayJsForString).format(. "YYYY-MM-DD")), + : Some((Date.toString(date)->DayJs.getDayJsForString).format("YYYY-MM-DD")), )} diff --git a/src/components/InputFields.res b/src/components/InputFields.res index 9d3fe9a52..84545b6a6 100644 --- a/src/components/InputFields.res +++ b/src/components/InputFields.res @@ -10,9 +10,7 @@ type comboCustomInputRecord = { } let selectInput = ( - ~input: ReactFinalForm.fieldRenderPropsInput, ~options: array, - ~placeholder as _, ~buttonText, ~deselectDisable=false, ~isHorizontal=true, @@ -42,7 +40,7 @@ let selectInput = ( ~dropdownClassName="", ~descriptionOnHover=false, (), -) => { +) => (~input: ReactFinalForm.fieldRenderPropsInput, ~placeholder as _) => { , - ~placeholder as _, ~deselectDisable=false, ~borderRadius="rounded-full", ~selectedClass="border-jp-gray-900 dark:border-jp-gray-300 text-jp-gray-900 dark:text-jp-gray-300 font-semibold", @@ -89,7 +85,7 @@ let infraSelectInput = ( ~showTickMark=true, ~allowMultiSelect=true, (), -) => { +) => (~input: ReactFinalForm.fieldRenderPropsInput, ~placeholder as _) => { , ~optionSize: CheckBoxIcon.size=Small, - ~placeholder as _, ~buttonText, ~buttonSize=?, ~hideMultiSelectButtons=false, @@ -153,7 +147,7 @@ let filterMultiSelectInput = ( ~baseComponentMethod=?, ~disableSelect=false, (), -) => { +) => (~input: ReactFinalForm.fieldRenderPropsInput, ~placeholder as _) => { , ~optionSize: CheckBoxIcon.size=Small, - ~placeholder as _, ~buttonText, ~buttonSize=?, ~hideMultiSelectButtons=false, @@ -258,7 +250,7 @@ let multiSelectInput = ( ~baseComponentMethod=?, ~disableSelect=false, (), -) => { +) => (~input: ReactFinalForm.fieldRenderPropsInput, ~placeholder as _) => { , - ~placeholder as _, ~buttonText, ~disableSelect=true, ~optionSize: CheckBoxIcon.size=Small, @@ -327,7 +317,7 @@ let radioInput = ( ~fill=?, ~maxHeight=?, (), -) => { +) => (~input: ReactFinalForm.fieldRenderPropsInput, ~placeholder as _) => { { +) => (~input: ReactFinalForm.fieldRenderPropsInput, ~placeholder) => { { +) => (~input: ReactFinalForm.fieldRenderPropsInput, ~placeholder) => { { +) => (~input: ReactFinalForm.fieldRenderPropsInput, ~placeholder as _) => { { +) => (~input: ReactFinalForm.fieldRenderPropsInput, ~placeholder) => { } -let iconFieldWithMessageDes = ( - mainInputField, +let iconFieldWithMessageDes = (mainInputField, ~description="", ()) => ( ~input: ReactFinalForm.fieldRenderPropsInput, ~placeholder, - ~description="", - (), ) => {
{mainInputField(~input, ~placeholder)}
@@ -616,11 +595,9 @@ let iconFieldWithMessageDes = (
} -let passwordMatchField = ( +let passwordMatchField = (~leftIcon=?, ()) => ( ~input: ReactFinalForm.fieldRenderPropsInput, ~placeholder, - ~leftIcon=?, - (), ) => { } @@ -643,9 +620,7 @@ let checkboxInput = ( ~checkboxDimension="", ~wrapBasis="", (), - ~input: ReactFinalForm.fieldRenderPropsInput, - ~placeholder as _, -) => { +) => (~input: ReactFinalForm.fieldRenderPropsInput, ~placeholder as _) => { } -let boolInput = ( - ~isDisabled, - ~isCheckBox=false, - ~boolCustomClass="", +let boolInput = (~isDisabled, ~isCheckBox=false, ~boolCustomClass="", ()) => ( ~input: ReactFinalForm.fieldRenderPropsInput, ~placeholder as _, - (), ) => { } diff --git a/src/components/InputFields.resi b/src/components/InputFields.resi index d9f331c65..1b8827611 100644 --- a/src/components/InputFields.resi +++ b/src/components/InputFields.resi @@ -4,11 +4,8 @@ type customInputFn = ( ) => React.element type comboCustomInputFn = array => React.element type comboCustomInputRecord = {fn: comboCustomInputFn, names: array} - let selectInput: ( - ~input: ReactFinalForm.fieldRenderPropsInput, ~options: array, - ~placeholder: 'a, ~buttonText: string, ~deselectDisable: bool=?, ~isHorizontal: bool=?, @@ -31,18 +28,16 @@ let selectInput: ( ~buttonType: Button.buttonType=?, ~dropdownCustomWidth: string=?, ~allowButtonTextMinWidth: bool=?, - ~setExtSearchString: ('b => string) => unit=?, + ~setExtSearchString: ('a => string) => unit=?, ~textStyleClass: string=?, ~ellipsisOnly: bool=?, ~showBtnTextToolTip: bool=?, ~dropdownClassName: string=?, ~descriptionOnHover: bool=?, unit, -) => React.element +) => (~input: ReactFinalForm.fieldRenderPropsInput, ~placeholder: 'b) => React.element let infraSelectInput: ( - ~input: ReactFinalForm.fieldRenderPropsInput, ~options: array, - ~placeholder: 'a, ~deselectDisable: bool=?, ~borderRadius: string=?, ~selectedClass: string=?, @@ -50,12 +45,10 @@ let infraSelectInput: ( ~showTickMark: bool=?, ~allowMultiSelect: bool=?, unit, -) => React.element +) => (~input: ReactFinalForm.fieldRenderPropsInput, ~placeholder: 'a) => React.element let filterMultiSelectInput: ( - ~input: ReactFinalForm.fieldRenderPropsInput, ~options: array, ~optionSize: CheckBoxIcon.size=?, - ~placeholder: 'a, ~buttonText: string, ~buttonSize: Button.buttonSize=?, ~hideMultiSelectButtons: bool=?, @@ -96,18 +89,16 @@ let filterMultiSelectInput: ( ~leftIcon: Button.iconType=?, ~customBackColor: string=?, ~customSelectAllStyle: string=?, - ~onItemSelect: (JsxEvent.Mouse.t, Js_string.t) => unit=?, + ~onItemSelect: (JsxEventU.Mouse.t, string) => unit=?, ~wrapBasis: string=?, ~dropdownClassName: string=?, ~baseComponentMethod: bool => React.element=?, ~disableSelect: bool=?, unit, -) => React.element +) => (~input: ReactFinalForm.fieldRenderPropsInput, ~placeholder: 'a) => React.element let multiSelectInput: ( - ~input: ReactFinalForm.fieldRenderPropsInput, ~options: array, ~optionSize: CheckBoxIcon.size=?, - ~placeholder: 'a, ~buttonText: string, ~buttonSize: Button.buttonSize=?, ~hideMultiSelectButtons: bool=?, @@ -148,17 +139,15 @@ let multiSelectInput: ( ~leftIcon: Button.iconType=?, ~customBackColor: string=?, ~customSelectAllStyle: string=?, - ~onItemSelect: (JsxEvent.Mouse.t, Js_string.t) => unit=?, + ~onItemSelect: (JsxEventU.Mouse.t, string) => unit=?, ~wrapBasis: string=?, ~dropdownClassName: string=?, ~baseComponentMethod: bool => React.element=?, ~disableSelect: bool=?, unit, -) => React.element +) => (~input: ReactFinalForm.fieldRenderPropsInput, ~placeholder: 'a) => React.element let radioInput: ( - ~input: ReactFinalForm.fieldRenderPropsInput, ~options: array, - ~placeholder: 'a, ~buttonText: string, ~disableSelect: bool=?, ~optionSize: CheckBoxIcon.size=?, @@ -170,10 +159,8 @@ let radioInput: ( ~fill: string=?, ~maxHeight: string=?, unit, -) => React.element +) => (~input: ReactFinalForm.fieldRenderPropsInput, ~placeholder: 'a) => React.element let textInput: ( - ~input: ReactFinalForm.fieldRenderPropsInput, - ~placeholder: string, ~description: string=?, ~isDisabled: bool=?, ~autoFocus: bool=?, @@ -184,7 +171,7 @@ let textInput: ( ~maxLength: int=?, ~leftIcon: React.element=?, ~rightIcon: React.element=?, - ~rightIconOnClick: JsxEvent.Mouse.t => unit=?, + ~rightIconOnClick: JsxEventU.Mouse.t => unit=?, ~inputStyle: string=?, ~customStyle: string=?, ~customWidth: string=?, @@ -200,7 +187,7 @@ let textInput: ( ~phoneInput: bool=?, ~widthMatchwithPlaceholderLength: option=?, unit, -) => React.element +) => (~input: ReactFinalForm.fieldRenderPropsInput, ~placeholder: string) => React.element let textTagInput: ( ~input: ReactFinalForm.fieldRenderPropsInput, ~placeholder: string, @@ -213,8 +200,6 @@ let textTagInput: ( unit, ) => React.element let numericTextInput: ( - ~input: ReactFinalForm.fieldRenderPropsInput, - ~placeholder: string, ~isDisabled: bool=?, ~customStyle: string=?, ~inputMode: string=?, @@ -227,10 +212,8 @@ let numericTextInput: ( ~rightIconCustomStyle: string=?, ~leftIconCustomStyle: string=?, unit, -) => React.element +) => (~input: ReactFinalForm.fieldRenderPropsInput, ~placeholder: string) => React.element let singleDatePickerInput: ( - ~input: ReactFinalForm.fieldRenderPropsInput, - ~placeholder: 'a, ~disablePastDates: bool=?, ~disableFutureDates: bool=?, ~customDisabledFutureDays: float=?, @@ -245,7 +228,7 @@ let singleDatePickerInput: ( ~showTime: bool=?, ~fullLength: bool=?, unit, -) => React.element +) => (~input: ReactFinalForm.fieldRenderPropsInput, ~placeholder: 'a) => React.element let filterDateRangeField: ( ~startKey: string, ~endKey: string, @@ -258,7 +241,7 @@ let filterDateRangeField: ( ~numMonths: int=?, ~dateRangeLimit: int=?, ~removeFilterOption: bool=?, - ~optFieldKey: string=?, + ~optFieldKey: 'a=?, ~showSeconds: bool=?, ~hideDate: bool=?, ~selectStandardTime: bool=?, @@ -277,7 +260,7 @@ let dateRangeField: ( ~numMonths: int=?, ~dateRangeLimit: int=?, ~removeFilterOption: bool=?, - ~optFieldKey: string=?, + ~optFieldKey: 'a=?, ~showSeconds: bool=?, ~hideDate: bool=?, ~selectStandardTime: bool=?, @@ -286,8 +269,6 @@ let dateRangeField: ( unit, ) => comboCustomInputRecord let multiLineTextInput: ( - ~input: ReactFinalForm.fieldRenderPropsInput, - ~placeholder: string, ~isDisabled: bool, ~rows: option, ~cols: option, @@ -295,21 +276,16 @@ let multiLineTextInput: ( ~leftIcon: React.element=?, ~maxLength: int=?, unit, -) => React.element +) => (~input: ReactFinalForm.fieldRenderPropsInput, ~placeholder: string) => React.element let iconFieldWithMessageDes: ( (~input: ReactFinalForm.fieldRenderPropsInput, ~placeholder: 'a) => React.element, - ~input: ReactFinalForm.fieldRenderPropsInput, - ~placeholder: 'a, ~description: string=?, unit, -) => React.element +) => (~input: ReactFinalForm.fieldRenderPropsInput, ~placeholder: 'a) => React.element let passwordMatchField: ( - ~input: ReactFinalForm.fieldRenderPropsInput, - ~placeholder: string, ~leftIcon: React.element=?, unit, -) => React.element - +) => (~input: ReactFinalForm.fieldRenderPropsInput, ~placeholder: string) => React.element let checkboxInput: ( ~isHorizontal: bool=?, ~options: array, @@ -328,15 +304,10 @@ let checkboxInput: ( ~checkboxDimension: string=?, ~wrapBasis: string=?, unit, - ~input: ReactFinalForm.fieldRenderPropsInput, - ~placeholder: 'a, -) => React.element - +) => (~input: ReactFinalForm.fieldRenderPropsInput, ~placeholder: 'a) => React.element let boolInput: ( ~isDisabled: bool, ~isCheckBox: bool=?, ~boolCustomClass: string=?, - ~input: ReactFinalForm.fieldRenderPropsInput, - ~placeholder: 'a, unit, -) => React.element +) => (~input: ReactFinalForm.fieldRenderPropsInput, ~placeholder: 'a) => React.element diff --git a/src/components/LoadedTable.res b/src/components/LoadedTable.res index d9a713c2d..88cfc1b2c 100644 --- a/src/components/LoadedTable.res +++ b/src/components/LoadedTable.res @@ -18,7 +18,7 @@ let checkBoxPropDefaultVal: checkBoxProps = { setSelectedData: _ => (), } -let sortAtom: Recoil.recoilAtom> = Recoil.atom(. "sortAtom", Dict.make()) +let sortAtom: Recoil.recoilAtom> = Recoil.atom("sortAtom", Dict.make()) let backgroundClass = "bg-gray-50 dark:bg-jp-gray-darkgray_background" @@ -56,7 +56,7 @@ let useSortedObj = (title: string, defaultSort) => { }, } - setDict(.dict => { + setDict(dict => { let nDict = Dict.fromArray(Dict.toArray(dict)) Dict.set(nDict, title, sortOb) nDict @@ -128,7 +128,7 @@ type pageDetails = { resultsPerPage: int, } -let table_pageDetails: Recoil.recoilAtom> = Recoil.atom(. +let table_pageDetails: Recoil.recoilAtom> = Recoil.atom( "table_pageDetails", Dict.make(), ) @@ -268,7 +268,7 @@ let make = ( newDict->Dict.set(title, value) setOffset(_ => offsetVal(0)) - setPageDetails(._ => newDict) + setPageDetails(_ => newDict) } let url = RescriptReactRouter.useUrl() @@ -276,7 +276,7 @@ let make = ( setFirstRender(_ => false) setOffset(_ => pageDetail.offset) None - }, [url.path->List.toArray->Array.joinWith("/")]) + }, [url.path->List.toArray->Array.joinWithUnsafe("/")]) React.useEffect1(_ => { if pageDetail.offset !== offset && !firstRender { @@ -287,7 +287,7 @@ let make = ( let newDict = pageDetailDict->Dict.toArray->Dict.fromArray newDict->Dict.set(title, value) - setPageDetails(._ => newDict) + setPageDetails(_ => newDict) } None }, [offset]) @@ -305,7 +305,7 @@ let make = ( let newDict = pageDetailDict->Dict.toArray->Dict.fromArray newDict->Dict.set(title, value) - setPageDetails(._ => newDict) + setPageDetails(_ => newDict) } let (columnFilter, setColumnFilterOrig) = React.useState(_ => Dict.make()) diff --git a/src/components/LoadedTable.resi b/src/components/LoadedTable.resi index 3896b711d..c97cf4e1c 100644 --- a/src/components/LoadedTable.resi +++ b/src/components/LoadedTable.resi @@ -61,7 +61,7 @@ let make: ( ~setSummary: ('f => EntityType.summary) => unit=?, ~customGetObjects: JSON.t => array<'g>=?, ~dataNotFoundComponent: React.element=?, - ~renderCard: (~index: int, ~item: 'b, ~onRowClick: React.callback) => React.element=?, + ~renderCard: (~index: int, ~item: 'b, ~onRowClick: int => unit) => React.element=?, ~tableLocalFilter: bool=?, ~tableheadingClass: string=?, ~tableBorderClass: string=?, diff --git a/src/components/MultipleFileUpload.res b/src/components/MultipleFileUpload.res index 66c5053a8..1bb81eee5 100644 --- a/src/components/MultipleFileUpload.res +++ b/src/components/MultipleFileUpload.res @@ -111,11 +111,11 @@ let make = ( fileTypeArr->Array.includes(fileFormat) || fileTypeArr->Array.includes("*") let fileReader = FileReader.reader let _file = if filename->String.includes("p12") { - fileReader.readAsBinaryString(. value) + fileReader.readAsBinaryString(value) } else if shouldEncodeBase64 { - fileReader.readAsDataURL(. value) + fileReader.readAsDataURL(value) } else { - fileReader.readAsText(. value) + fileReader.readAsText(value) } fileReader.onload = e => { diff --git a/src/components/NewCalendar.res b/src/components/NewCalendar.res index 1bbc42e1b..f4b303bc2 100644 --- a/src/components/NewCalendar.res +++ b/src/components/NewCalendar.res @@ -110,7 +110,7 @@ module TableRow = { | true => switch onDateClick { | Some(fn) => - fn((Date.toISOString(date)->DayJs.getDayJsForString).format(. "YYYY-MM-DD")) + fn((Date.toISOString(date)->DayJs.getDayJsForString).format("YYYY-MM-DD")) | None => () } @@ -118,7 +118,7 @@ module TableRow = { } } let hSelf = highlight( - (Date.toString(date)->DayJs.getDayJsForString).format(. "YYYY-MM-DD"), + (Date.toString(date)->DayJs.getDayJsForString).format("YYYY-MM-DD"), ) let dayClass = if ( @@ -142,15 +142,13 @@ module TableRow = { ) datevalue } - let today = (Date.make()->Date.toString->DayJs.getDayJsForString).format(. - "YYYY-MM-DD", - ) + let today = (Date.make()->Date.toString->DayJs.getDayJsForString).format("YYYY-MM-DD") let renderingDate = ( getDate([Float.toString(year), Float.toString(month +. 1.0), obj]) ->Date.toString ->DayJs.getDayJsForString - ).format(. "YYYY-MM-DD") + ).format("YYYY-MM-DD") let isTodayHighlight = today == renderingDate && startDate != today && endDate != today let textColor = isTodayHighlight @@ -284,7 +282,7 @@ module TableRow = { ) } let handleHover = () => { - let date = (Date.toString(date)->DayJs.getDayJsForString).format(. "YYYY-MM-DD") + let date = (Date.toString(date)->DayJs.getDayJsForString).format("YYYY-MM-DD") let parsedDate = getDate(String.split(date, "-")) setHoverdDate(_ => parsedDate->Date.toString) switch setShowMsg { @@ -310,7 +308,7 @@ module TableRow = { className={`${classN} ${highlightBgClass} text-sm font-normal`} onClick onMouseOver={_ => handleHover()} - onMouseOut={evt => setHoverdDate(_ => "")}> + onMouseOut={_evt => setHoverdDate(_ => "")}> isEmptyString ? None - : Some( - (Date.toString(date)->DayJs.getDayJsForString).format(. "YYYY-MM-D"), - ), + : Some((Date.toString(date)->DayJs.getDayJsForString).format("YYYY-MM-D")), )} {isTodayHighlight ?
@@ -418,9 +414,9 @@ let make = ( if startDate != lastStartDate { let startYear = - startDate->isNonEmptyString ? (startDate->DayJs.getDayJsForString).format(. "YYYY") : "" + startDate->isNonEmptyString ? (startDate->DayJs.getDayJsForString).format("YYYY") : "" let startMonth = - (startDate->isNonEmptyString ? (startDate->DayJs.getDayJsForString).format(. "MM") : "") + (startDate->isNonEmptyString ? (startDate->DayJs.getDayJsForString).format("MM") : "") ->Int.fromString ->Option.getOr(currentMonth) let startYearDiff = year - startYear->Int.fromString->Option.getOr(2022) @@ -433,9 +429,9 @@ let make = ( setLastStartDate(_ => startDate) } else { let endYear = - endDate->isNonEmptyString ? (endDate->DayJs.getDayJsForString).format(. "YYYY") : "" + endDate->isNonEmptyString ? (endDate->DayJs.getDayJsForString).format("YYYY") : "" let endMonth = - (endDate->isNonEmptyString ? (endDate->DayJs.getDayJsForString).format(. "MM") : "") + (endDate->isNonEmptyString ? (endDate->DayJs.getDayJsForString).format("MM") : "") ->Int.fromString ->Option.getOr(currentMonth) let endYearDiff = year - endYear->Int.fromString->Option.getOr(2022) @@ -451,8 +447,8 @@ let make = ( let rows = index => { let windowIndex = totalMonths - index->getInt("index", 0) - 1 - let newMonth = DayJs.getDayJs().subtract(. windowIndex, "month").month(.) - let newYear = DayJs.getDayJs().subtract(. windowIndex, "month").year(.) + let newMonth = DayJs.getDayJs().subtract(windowIndex, "month").month() + let newYear = DayJs.getDayJs().subtract(windowIndex, "month").year() let updatedMonth = months->Array.get(newMonth)->Option.getOr(Jan) // get first day @@ -553,7 +549,7 @@ let make = ( { open ReactWindow.ListComponent - fn.current = el->scrollToItem + fn.current = (index, string) => el->scrollToItem(index, string) }} width=300 itemSize={_ => 290} diff --git a/src/components/NewCalendarList.res b/src/components/NewCalendarList.res index 64b45136f..bdcced175 100644 --- a/src/components/NewCalendarList.res +++ b/src/components/NewCalendarList.res @@ -46,10 +46,10 @@ let make = ( let updatedFromDate = fromDate->isNonEmptyString && fromDate->String.length >= 5 && - fromDateJs.isValid(.) && - fromDateJs.year(.) <= permittedMaxYears + fromDateJs.isValid() && + fromDateJs.year() <= permittedMaxYears ? try { - fromDateJs.format(. "YYYY-MM-DD") + fromDateJs.format("YYYY-MM-DD") } catch { | _error => "" } @@ -57,10 +57,10 @@ let make = ( let updatedToDate = toDate->isNonEmptyString && toDate->String.length >= 5 && - toDateJs.isValid(.) && - toDateJs.year(.) <= permittedMaxYears + toDateJs.isValid() && + toDateJs.year() <= permittedMaxYears ? try { - toDateJs.format(. "YYYY-MM-DD") + toDateJs.format("YYYY-MM-DD") } catch { | _error => "" } @@ -90,10 +90,10 @@ let make = ( React.useEffect2(() => { if startDate->isNonEmptyString && !fromDateOnFocus { - setFromDate(_ => (startDate->DayJs.getDayJsForString).format(. "MMM DD, YYYY")) + setFromDate(_ => (startDate->DayJs.getDayJsForString).format("MMM DD, YYYY")) } if endDate->isNonEmptyString && !toDateOnFocus { - setToDate(_ => (endDate->DayJs.getDayJsForString).format(. "MMM DD, YYYY")) + setToDate(_ => (endDate->DayJs.getDayJsForString).format("MMM DD, YYYY")) } else { setToDate(_ => "") } @@ -103,10 +103,10 @@ let make = ( React.useEffect1(() => { if isDateClicked { if startDate->isNonEmptyString && !fromDateOnFocus { - setFromDate(_ => (startDate->DayJs.getDayJsForString).format(. "MMM DD, YYYY")) + setFromDate(_ => (startDate->DayJs.getDayJsForString).format("MMM DD, YYYY")) } if endDate->isNonEmptyString && !toDateOnFocus { - setToDate(_ => (endDate->DayJs.getDayJsForString).format(. "MMM DD, YYYY")) + setToDate(_ => (endDate->DayJs.getDayJsForString).format("MMM DD, YYYY")) } else { setToDate(_ => "") } @@ -150,7 +150,7 @@ let make = ( Int.toFloat(Float.toInt(Js.Date.getMonth(currDateTemp)) + i), ) let tempMonth = if disableFutureDates { - (Js.Date.fromFloat(tempDate)->DayJs.getDayJsForJsDate).toString(.) + (Js.Date.fromFloat(tempDate)->DayJs.getDayJsForJsDate).toString() ->Date.fromString ->Js.Date.getMonth } else { diff --git a/src/components/NewCalendarTimeInput.res b/src/components/NewCalendarTimeInput.res index abca617a3..0491f7220 100644 --- a/src/components/NewCalendarTimeInput.res +++ b/src/components/NewCalendarTimeInput.res @@ -91,17 +91,17 @@ let make = ( ) => { let {globalUIConfig: {border: {borderColor}}} = React.useContext(ConfigContext.configContext) let todayDateTime = DayJs.getDayJs() - let time = todayDateTime.format(. "hh:mm:ss a") + let time = todayDateTime.format("hh:mm:ss a") let defaultStartTime = - endDate == todayDateTime.format(. "YYYY-MM-DD") + endDate == todayDateTime.format("YYYY-MM-DD") ? time->String.toUpperCase - : (`${endDate} ${endTimeStr}`->DayJs.getDayJsForString).format(. + : (`${endDate} ${endTimeStr}`->DayJs.getDayJsForString).format( "hh:mm:ss a", )->String.toUpperCase let (fromTime, setFromTime) = React.useState(_ => - (`${startDate} ${startTimeStr}`->DayJs.getDayJsForString).format(. + (`${startDate} ${startTimeStr}`->DayJs.getDayJsForString).format( "hh:mm:ss a", )->String.toUpperCase ) @@ -155,8 +155,8 @@ let make = ( let endTime = localEndDate->getTimeStringForValue(isoStringToCustomTimeZone) let startDateTime = `${startDate} ${fromTime}`->DayJs.getDayJsForString - if startDateTime.isValid(.) { - let startTimeVal = startDateTime.format(. "HH:mm:ss") + if startDateTime.isValid() { + let startTimeVal = startDateTime.format("HH:mm:ss") if localStartDate->LogicUtils.isNonEmptyString { if disableFutureDates && startDate == todayDate && startTimeVal > todayTime { @@ -175,8 +175,8 @@ let make = ( let startTime = localStartDate->getTimeStringForValue(isoStringToCustomTimeZone) let endDateTime = `${endDate} ${toTime}`->DayJs.getDayJsForString - if endDateTime.isValid(.) { - let endTimeVal = endDateTime.format(. "HH:mm:ss") + if endDateTime.isValid() { + let endTimeVal = endDateTime.format("HH:mm:ss") if localEndDate->LogicUtils.isNonEmptyString { if disableFutureDates && endDate == todayDate && endTimeVal > todayTime { setEndDate(~date=startDate, ~time=todayTime) @@ -191,17 +191,17 @@ let make = ( None }, [toTime]) - let updatedFromDate = fromDateJs.isValid(.) + let updatedFromDate = fromDateJs.isValid() ? try { - fromDateJs.format(. "dddd, MMMM DD, YYYY") + fromDateJs.format("dddd, MMMM DD, YYYY") } catch { | _error => "" } : "" - let updatedToDate = toDateJs.isValid(.) + let updatedToDate = toDateJs.isValid() ? try { - toDateJs.format(. "dddd, MMMM DD, YYYY") + toDateJs.format("dddd, MMMM DD, YYYY") } catch { | _error => "" } diff --git a/src/components/PopUpContainer.res b/src/components/PopUpContainer.res index 76bc2b2bd..214eb7fe1 100644 --- a/src/components/PopUpContainer.res +++ b/src/components/PopUpContainer.res @@ -7,7 +7,7 @@ let make = (~children) => { let popUp = switch activePopUp { | Some(popUp) => { let handleConfirm = ev => { - setOpenPopUp(.prevArr => prevArr->Array.sliceToEnd(~start=1)) + setOpenPopUp(prevArr => prevArr->Array.sliceToEnd(~start=1)) switch popUp.handleConfirm.onClick { | Some(onClick) => onClick(ev) | None => () @@ -15,7 +15,7 @@ let make = (~children) => { } let handlePopUp = ev => { - setOpenPopUp(.prevArr => prevArr->Array.sliceToEnd(~start=1)) + setOpenPopUp(prevArr => prevArr->Array.sliceToEnd(~start=1)) switch popUp.handleCancel { | Some(fn) => switch fn.onClick { @@ -27,7 +27,7 @@ let make = (~children) => { } let handleCancel = ev => { - setOpenPopUp(.prevArr => prevArr->Array.sliceToEnd(~start=1)) + setOpenPopUp(prevArr => prevArr->Array.sliceToEnd(~start=1)) switch popUp.handleCancel { | Some(fn) => switch fn.onClick { diff --git a/src/components/ReactWindowTable.res b/src/components/ReactWindowTable.res index b7738a5b9..d1237711f 100644 --- a/src/components/ReactWindowTable.res +++ b/src/components/ReactWindowTable.res @@ -512,7 +512,7 @@ module ReactWindowTableComponent = { { open ReactWindow.ListComponent - fn.current = el->resetAfterIndex + fn.current = (index, val) => el->resetAfterIndex(index, val) }} itemSize={index => getHeight(index)} height=tableHeight @@ -533,7 +533,7 @@ type sortOb = { sortType: sortTyp, } -let sortAtom: Recoil.recoilAtom> = Recoil.atom(. "sortAtom", Dict.make()) +let sortAtom: Recoil.recoilAtom> = Recoil.atom("sortAtom", Dict.make()) let useSortedObj = (title: string, defaultSort) => { let (dict, setDict) = Recoil.useRecoilState(sortAtom) @@ -569,7 +569,7 @@ let useSortedObj = (title: string, defaultSort) => { }, } - setDict(.dict => { + setDict(dict => { let nDict = Dict.fromArray(Dict.toArray(dict)) Dict.set(nDict, title, sortOb) nDict diff --git a/src/components/RemoteFiltersUtils.res b/src/components/RemoteFiltersUtils.res index 71b020c39..b9d7b4428 100644 --- a/src/components/RemoteFiltersUtils.res +++ b/src/components/RemoteFiltersUtils.res @@ -181,7 +181,7 @@ let getInitialValuesFromUrl = ( let key = String.sliceToEnd(splitArray[0]->Option.getOr(""), ~start=keyStartIndex) Array.push(keyList, key)->ignore splitArray->Array.shift->ignore - let value = splitArray->Array.joinWith("=") + let value = splitArray->Array.joinWithUnsafe("=") Array.push(valueList, value)->ignore entriesList->Array.push((key, value))->ignore @@ -329,7 +329,7 @@ let generateUrlFromDict = (~dict, ~options: array>, ta None } }) - ->Array.joinWith("&") + ->Array.joinWithUnsafe("&") } let applyFilters = ( diff --git a/src/components/SelectBox.res b/src/components/SelectBox.res index 4be0a66e8..6e02559fe 100644 --- a/src/components/SelectBox.res +++ b/src/components/SelectBox.res @@ -511,7 +511,7 @@ module BaseSelect = { None }, [searchString]) - let onItemClick = (itemDataValue, isDisabled, e) => { + let onItemClick = (itemDataValue, isDisabled) => e => { if !isDisabled { let data = if Array.includes(saneValue, itemDataValue) { let values = @@ -536,7 +536,7 @@ module BaseSelect = { setSearchString(_ => str) } - let selectAll = (select, _ev) => { + let selectAll = select => _ev => { let newValues = if select { let newVal = filteredOptions @@ -636,7 +636,7 @@ module BaseSelect = { }, (noOfSelected, options)) let toggleSelectAll = val => { if !disableSelect { - selectAll(val, "") + selectAll(val)("") setChooseAllToggleSelected(_ => val) } @@ -937,7 +937,7 @@ module BaseSelectButton = { let (itemdata, setItemData) = React.useState(() => "") let (assignButtonState, setAssignButtonState) = React.useState(_ => false) let searchRef = React.useRef(Nullable.null) - let onItemClick = (itemData, _ev) => { + let onItemClick = itemData => _ev => { if !disableSelect { let isSelected = value->JSON.Decode.string->Option.mapOr(false, str => itemData === str) @@ -1249,7 +1249,7 @@ module BaseRadio = { }, (), ) - let onItemClick = (itemData, isDisabled, _ev) => { + let onItemClick = (itemData, isDisabled) => _ev => { if !isDisabled { let isSelected = value->JSON.Decode.string->Option.mapOr(false, str => itemData === str) @@ -1594,7 +1594,7 @@ module BaseDropdown = { } } - let removeOption = (text, _ev) => { + let removeOption = text => _ev => { let actualValue = switch Array.find(transformedOptions, option => option.value == text) { | Some(str) => str.value | None => "" @@ -1677,7 +1677,7 @@ module BaseDropdown = { ->Belt.Array.keepMap(str => { transformedOptions->Array.find(x => x.value == str)->Option.map(x => x.label) }) - ->Array.joinWith(", ") + ->Array.joinWithUnsafe(", ") ->LogicUtils.getNonEmptyString ->Option.getOr(buttonText) }, (transformedOptions, newInputSelect.value)) @@ -1878,7 +1878,7 @@ module BaseDropdown = { ? `Select ${LogicUtils.snakeToTitle(newInputSelect.name)}` : newInputSelect.value ->LogicUtils.getStrArryFromJson - ->Array.joinWith(",\n")} + ->Array.joinWithUnsafe(",\n")} toolTipFor=selectButton toolTipPosition=Bottom tooltipWidthClass="" diff --git a/src/components/SelectBox.resi b/src/components/SelectBox.resi index f3062fc6a..c61148dda 100644 --- a/src/components/SelectBox.resi +++ b/src/components/SelectBox.resi @@ -20,10 +20,10 @@ module ListItem: { ~isSelected: bool, ~isPrevSelected: bool=?, ~isNextSelected: bool=?, - ~onClick: JsxEvent.Mouse.t => unit, - ~text: string, + ~onClick: JsxEventU.Mouse.t => unit, + ~text: Js.String2.t, ~fill: string=?, - ~labelValue: string=?, + ~labelValue: Js.String2.t=?, ~isDisabled: bool=?, ~icon: Button.iconType, ~leftVacennt: bool=?, @@ -84,7 +84,7 @@ module BaseSelect: { ~optionSize: CheckBoxIcon.size=?, ~isSelectedStateMinus: bool=?, ~onSelect: array => unit, - ~value: JSON.t, + ~value: RescriptCore.JSON.t, ~onBlur: ReactEvent.Focus.t => unit=?, ~showClearAll: bool=?, ~isHorizontal: bool=?, @@ -125,9 +125,9 @@ module BaseSelect: { ~customSelectAllStyle: string=?, ~checkboxDimension: string=?, ~dropdownClassName: string=?, - ~onItemSelect: (JsxEvent.Mouse.t, Js_string.t) => unit=?, + ~onItemSelect: (JsxEventU.Mouse.t, string) => unit=?, ~wrapBasis: string=?, - ~preservedAppliedOptions: array=?, + ~preservedAppliedOptions: array=?, ) => React.element } module BaseSelectButton: { @@ -140,7 +140,7 @@ module BaseSelectButton: { ~optionSize: CheckBoxIcon.size=?, ~isSelectedStateMinus: bool=?, ~onSelect: string => unit, - ~value: JSON.t, + ~value: RescriptCore.JSON.t, ~deselectDisable: bool=?, ~onBlur: ReactEvent.Focus.t => unit=?, ~setShowDropDown: ('a => bool) => unit=?, @@ -158,14 +158,14 @@ module RenderListItemInBaseRadio: { @react.component let make: ( ~newOptions: array, - ~value: JSON.t, + ~value: Core__JSON.t, ~descriptionOnHover: bool, ~isDropDown: bool, ~textIconPresent: bool, ~searchString: string, ~optionSize: CheckBoxIcon.size, ~isSelectedStateMinus: bool, - ~onItemClick: (string, bool, JsxEvent.Mouse.t) => unit, + ~onItemClick: (string, bool) => JsxEventU.Mouse.t => unit, ~fill: string, ~customStyle: string, ~isMobileView: bool, @@ -192,7 +192,7 @@ module BaseRadio: { ~optionSize: CheckBoxIcon.size=?, ~isSelectedStateMinus: bool=?, ~onSelect: string => unit, - ~value: JSON.t, + ~value: RescriptCore.JSON.t, ~deselectDisable: bool=?, ~onBlur: ReactEvent.Focus.t => unit=?, ~fill: string=?, @@ -203,11 +203,11 @@ module BaseRadio: { ~descriptionOnHover: bool=?, ~addDynamicValue: bool=?, ~dropdownCustomWidth: string=?, - ~dropdownRef: React.ref>=?, + ~dropdownRef: React.ref>=?, ~showMatchingRecordsText: bool=?, ~fullLength: bool=?, ~selectedString: string=?, - ~setSelectedString: ('a => Js_string.t) => unit=?, + ~setSelectedString: ('a => string) => unit=?, ~setExtSearchString: ('b => string) => unit=?, ~listFlexDirection: string=?, ~baseComponentCustomStyle: string=?, @@ -273,7 +273,7 @@ module BaseDropdown: { ~textStyleClass: string=?, ~buttonStyleOnDropDownOpened: string=?, ~selectedString: string=?, - ~setSelectedString: ('a => Js_string.t) => unit=?, + ~setSelectedString: ('a => string) => unit=?, ~setExtSearchString: ('b => string) => unit=?, ~listFlexDirection: string=?, ~ellipsisOnly: bool=?, @@ -397,6 +397,6 @@ let make: ( ~textEllipsisForDropDownOptions: bool=?, ~showBtnTextToolTip: bool=?, ~dropdownClassName: string=?, - ~onItemSelect: (JsxEvent.Mouse.t, Js_string.t) => unit=?, + ~onItemSelect: (JsxEventU.Mouse.t, string) => unit=?, ~wrapBasis: string=?, ) => React.element diff --git a/src/components/SnackBarContainer.res b/src/components/SnackBarContainer.res index 3a7b462ba..aad92b4ae 100644 --- a/src/components/SnackBarContainer.res +++ b/src/components/SnackBarContainer.res @@ -66,7 +66,7 @@ let make = (~children) => { let (openSnackbar, setOpenSnackbar) = Recoil.useRecoilState(SnackBarState.openSnackbar) let hideSnackbar = React.useCallback1(key => { - setOpenSnackbar(.prevArr => { + setOpenSnackbar(prevArr => { Array.filter( prevArr, (snackbarProps: SnackBarState.snackbarProps) => { diff --git a/src/components/TableLocalFilters.res b/src/components/TableLocalFilters.res index 2cf9fd8e9..9acc09673 100644 --- a/src/components/TableLocalFilters.res +++ b/src/components/TableLocalFilters.res @@ -117,7 +117,7 @@ module FilterDropDown = {
e->ReactEvent.Mouse.stopPropagation}> { + onClick={_e => { setLclFltrState(val, []) }}> diff --git a/src/components/Tabs.res b/src/components/Tabs.res index 55b1e78b7..07772d916 100644 --- a/src/components/Tabs.res +++ b/src/components/Tabs.res @@ -79,7 +79,7 @@ module TabInfo = { tabRef.current ->Nullable.toOption ->Option.forEach(input => - input->scrollIntoView(_, {behavior: "smooth", block: "nearest", inline: "nearest"}) + input->(scrollIntoView(_, {behavior: "smooth", block: "nearest", inline: "nearest"})) ) } None @@ -110,7 +110,7 @@ module IndicationArrow = { refElement.current ->Nullable.toOption ->Option.forEach(input => - input->scrollIntoView(_, {behavior: "smooth", block: "nearest", inline: "start"}) + input->(scrollIntoView(_, {behavior: "smooth", block: "nearest", inline: "start"})) ) } let roundness = side == "left" ? "rounded-tr-md" : "rounded-tl-md" diff --git a/src/components/TabularInput.res b/src/components/TabularInput.res index 1809b9cb8..b94941ef6 100644 --- a/src/components/TabularInput.res +++ b/src/components/TabularInput.res @@ -126,7 +126,7 @@ let make = (~input: ReactFinalForm.fieldRenderPropsInput, ~headings, ~fields) => setKeyValue(_ => a) } - let onClick = (elemIndex, isLast, _) => { + let onClick = (elemIndex, isLast) => _ev => { let value = if isLast { Array.concat(initialState, dummyInitialState) } else { diff --git a/src/components/TimeInput.res b/src/components/TimeInput.res index dca60a0a1..a3ad9ac26 100644 --- a/src/components/TimeInput.res +++ b/src/components/TimeInput.res @@ -40,18 +40,27 @@ let make = ( | None => "" } let arr = value->String.split(":") - let hourVal = arr->Array.get(0)->Option.flatMap(Belt.Int.fromString)->Option.getOr(0) - let minuteVal = arr->Array.get(1)->Option.flatMap(Belt.Int.fromString)->Option.getOr(0) - let secondsVal = arr->Array.get(2)->Option.flatMap(Belt.Int.fromString)->Option.getOr(0) + let hourVal = arr->Array.get(0)->Option.flatMap(val => val->Belt.Int.fromString)->Option.getOr(0) + let minuteVal = + arr->Array.get(1)->Option.flatMap(val => val->Belt.Int.fromString)->Option.getOr(0) + let secondsVal = + arr->Array.get(2)->Option.flatMap(val => val->Belt.Int.fromString)->Option.getOr(0) - let changeVal = React.useCallback4((index, ev: ReactEvent.Form.t) => { - let newVal = {ev->ReactEvent.Form.target}["value"]->Int.fromString->Option.getOr(0) + let changeVal = React.useCallback4(index => { + (ev: ReactEvent.Form.t) => { + let newVal = {ev->ReactEvent.Form.target}["value"]->Int.fromString->Option.getOr(0) - let arr = [hourVal, minuteVal, secondsVal] - arr[index] = newVal + let arr = [hourVal, minuteVal, secondsVal] + arr[index] = newVal - arr->Array.map(padNum)->Array.joinWith(":")->Identity.anyTypeToReactEvent->input.onChange + arr + ->Array.map(padNum) + ->Array.joinWithUnsafe(":") + ->Identity.anyTypeToReactEvent + ->input.onChange + } }, (hourVal, minuteVal, secondsVal, input.onChange)) + let onHourChange = React.useCallback1(changeVal(0), [changeVal]) let onMinuteChange = React.useCallback1(changeVal(1), [changeVal]) let onSecondsChange = React.useCallback1(changeVal(2), [changeVal]) diff --git a/src/components/ToastContainer.res b/src/components/ToastContainer.res index 31c399cdf..f082965cc 100644 --- a/src/components/ToastContainer.res +++ b/src/components/ToastContainer.res @@ -86,7 +86,7 @@ let make = (~children) => { let (openToasts, setOpenToasts) = Recoil.useRecoilState(ToastState.openToasts) let hideToast = React.useCallback1(key => { - setOpenToasts(.prevArr => { + setOpenToasts(prevArr => { Array.filter( prevArr, (toastProps: ToastState.toastProps) => { diff --git a/src/components/custom-icons/LottieFiles.res b/src/components/custom-icons/LottieFiles.res index de11dc8e4..a3ecce92e 100644 --- a/src/components/custom-icons/LottieFiles.res +++ b/src/components/custom-icons/LottieFiles.res @@ -27,7 +27,7 @@ let useLottieJson = lottieFileName => { | None => { let fetchLottie = fetchApi(`${prefix}/lottie-files/${lottieFileName}`, ~method_=Get, ()) - ->then(Fetch.Response.json) + ->then(res => res->Fetch.Response.json) ->then(json => { setlottieJson(_ => json) lottieDict->Dict.set(lottieFileName, Loaded(json)) diff --git a/src/components/form/FormRenderer.res b/src/components/form/FormRenderer.res index 888eacadb..07f547adc 100644 --- a/src/components/form/FormRenderer.res +++ b/src/components/form/FormRenderer.res @@ -2,8 +2,8 @@ open InputFields type inputFieldType = { name: string, placeholder: string, - format: option<(. ~value: JSON.t, ~name: string) => JSON.t>, - parse: option<(. ~value: JSON.t, ~name: string) => JSON.t>, + format: option<(~value: JSON.t, ~name: string) => JSON.t>, + parse: option<(~value: JSON.t, ~name: string) => JSON.t>, disabled: bool, isRequired: bool, @as("type") type_: string, @@ -265,7 +265,7 @@ module FieldWrapper = { }} } children - {switch subText->Option.flatMap(LogicUtils.getNonEmptyString) { + {switch subText->Option.flatMap(val => val->LogicUtils.getNonEmptyString) { | Some(subText) =>
{React.string(subText)}
| None => React.null }} @@ -468,7 +468,7 @@ module FieldRenderer = { let isVisible = true if isVisible { - let names = field.inputNames->Array.joinWith("-") + let names = field.inputNames->Array.joinWithUnsafe("-") @@ -706,7 +706,7 @@ module SubmitButton = { `${key->LogicUtils.snakeToTitle}: ${value}` }) - ->Array.joinWith("\n") + ->Array.joinWithUnsafe("\n") if showToolTip && !avoidDisable { strJson->JSON.Decode.string->Option.flatMap(Float.fromString) +let getFloat = strJson => strJson->JSON.Decode.string->Option.flatMap(val => val->Float.fromString) @react.component let make = ( @@ -63,9 +63,9 @@ let make = ( str[0] = str[0]->Option.getOr("")->String.replaceRegExp(%re("/\b0+/g"), "") str[0] = str[0]->Option.getOr("")->LogicUtils.isEmptyString ? "0" : str[0]->Option.getOr("") - str->Array.joinWith(".") + str->Array.joinWithUnsafe(".") } else { - str->Array.joinWith(".") + str->Array.joinWithUnsafe(".") } result | None => "" diff --git a/src/components/modal/ModalContainer.res b/src/components/modal/ModalContainer.res index cb19650d9..66fe08665 100644 --- a/src/components/modal/ModalContainer.res +++ b/src/components/modal/ModalContainer.res @@ -46,7 +46,7 @@ module Modal = { let make = (~children) => { let (openModals, setOpenModals) = Recoil.useRecoilState(ModalsState.openModals) let hideModalAtIndex = React.useCallback1(index => { - setOpenModals(.prevArr => { + setOpenModals(prevArr => { Array.filterWithIndex( prevArr, (_, i) => { diff --git a/src/components/portal/PortalCapture.res b/src/components/portal/PortalCapture.res index 485e840ac..ed786eb4a 100644 --- a/src/components/portal/PortalCapture.res +++ b/src/components/portal/PortalCapture.res @@ -2,7 +2,7 @@ let make = React.memo((~name: string, ~customStyle="") => { let setPortalNodes = Recoil.useSetRecoilState(PortalState.portalNodes) let setDiv = React.useCallback2((elem: Nullable.t) => { - setPortalNodes(. + setPortalNodes( prevDict => { let clonedDict = prevDict diff --git a/src/components/portal/PortalState.res b/src/components/portal/PortalState.res index b66d3ca70..6cb918407 100644 --- a/src/components/portal/PortalState.res +++ b/src/components/portal/PortalState.res @@ -1,3 +1,3 @@ let defaultDict: Dict.t = Dict.make() -let portalNodes = Recoil.atom(. "portalNodes", defaultDict) +let portalNodes = Recoil.atom("portalNodes", defaultDict) diff --git a/src/context/ChartContext.res b/src/context/ChartContext.res index 411ed6678..4cce90a3a 100644 --- a/src/context/ChartContext.res +++ b/src/context/ChartContext.res @@ -66,13 +66,13 @@ let make = (~children, ~chartEntity: DynamicChart.entity, ~chartId="", ~defaultF let (activeTab, activeTabStr) = React.useMemo1(() => { let activeTabOptionalArr = getAllFilter->getOptionStrArrayFromDict(`${chartEntity.moduleName}.tabName`) - (activeTabOptionalArr, activeTabOptionalArr->Option.getOr([])->Array.joinWith(",")) + (activeTabOptionalArr, activeTabOptionalArr->Option.getOr([])->Array.joinWithUnsafe(",")) }, [getAllFilter]) let parentToken = AuthWrapperUtils.useTokenParent(Original) let addLogsAroundFetch = EulerAnalyticsLogUtils.useAddLogsAroundFetchNew() let betaEndPointConfig = React.useContext(BetaEndPointConfigProvider.betaEndPointConfig) - let fetchApi = AuthHooks.useApiFetcher(~betaEndpointConfig=?betaEndPointConfig, ()) + let fetchApi = AuthHooks.useApiFetcher() let jsonTransFormer = switch chartEntity { | {jsonTransformer} => jsonTransformer | _ => (_val, arr) => arr @@ -149,7 +149,7 @@ let make = (~children, ~chartEntity: DynamicChart.entity, ~chartId="", ~defaultF None } }) - ->Array.joinWith("&") + ->Array.joinWithUnsafe("&") (filterSearchParam, getTopLevelChartFilter->getString(customFilterKey, "")) }, [getTopLevelChartFilter]) @@ -248,7 +248,7 @@ let make = (~children, ~chartEntity: DynamicChart.entity, ~chartId="", ~defaultF None }, ( parentToken, - current_granularity->Array.joinWith("-") ++ + current_granularity->Array.joinWithUnsafe("-") ++ granularity->Option.getOr("") ++ cardinalityFromUrl ++ chartTopMetricFromUrl ++ @@ -279,7 +279,7 @@ let make = (~children, ~chartEntity: DynamicChart.entity, ~chartId="", ~defaultF None }, ( parentToken, - current_granularity->Array.joinWith("-") ++ + current_granularity->Array.joinWithUnsafe("-") ++ granularity->Option.getOr("") ++ chartBottomMetricFromUrl ++ startTimeFromUrl ++ @@ -342,6 +342,7 @@ let make = (~children, ~chartEntity: DynamicChart.entity, ~chartId="", ~defaultF (), )->JSON.stringify, ~headers=[("QueryType", "Chart Time Series")]->Dict.fromArray, + ~betaEndpointConfig=?betaEndPointConfig, (), ) ->addLogsAroundFetch(~logTitle=`Chart fetch`) @@ -401,6 +402,7 @@ let make = (~children, ~chartEntity: DynamicChart.entity, ~chartId="", ~defaultF (), )->JSON.stringify, ~headers=[("QueryType", "Chart Legend")]->Dict.fromArray, + ~betaEndpointConfig=?betaEndPointConfig, (), ) ->addLogsAroundFetch(~logTitle=`Chart legend Data`) @@ -469,6 +471,7 @@ let make = (~children, ~chartEntity: DynamicChart.entity, ~chartId="", ~defaultF (), )->JSON.stringify, ~headers=[("QueryType", "Chart Time Series")]->Dict.fromArray, + ~betaEndpointConfig=?betaEndPointConfig, (), ) ->addLogsAroundFetch(~logTitle=`Chart fetch bottomChart`) @@ -525,6 +528,7 @@ let make = (~children, ~chartEntity: DynamicChart.entity, ~chartId="", ~defaultF (), )->JSON.stringify, ~headers=[("QueryType", "Chart Legend")]->Dict.fromArray, + ~betaEndpointConfig=?betaEndPointConfig, (), ) ->addLogsAroundFetch(~logTitle=`Chart legend Data`) @@ -586,7 +590,7 @@ module SDKAnalyticsChartContext = { let parentToken = AuthWrapperUtils.useTokenParent(Original) let addLogsAroundFetch = EulerAnalyticsLogUtils.useAddLogsAroundFetchNew() let betaEndPointConfig = React.useContext(BetaEndPointConfigProvider.betaEndPointConfig) - let fetchApi = AuthHooks.useApiFetcher(~betaEndpointConfig=?betaEndPointConfig, ()) + let fetchApi = AuthHooks.useApiFetcher() let jsonTransFormer = switch chartEntity { | {jsonTransformer} => jsonTransformer | _ => (_val, arr) => arr @@ -652,7 +656,7 @@ module SDKAnalyticsChartContext = { None } }) - ->Array.joinWith("&") + ->Array.joinWithUnsafe("&") (filterSearchParam, getTopLevelChartFilter->getString(customFilterKey, "")) }, [getTopLevelChartFilter]) @@ -733,36 +737,41 @@ module SDKAnalyticsChartContext = { setTopChartFetchWithCurrentDependecyChange, ) = React.useState(_ => false) - React.useEffect4(() => { - let chartType = - getChartCompFilters->getString( - "chartType", - chartEntity.chartTypes->Array.get(0)->Option.getOr(Line)->DynamicChart.chartMapper, - ) - if ( - startTimeFromUrl->isNonEmptyString && - endTimeFromUrl->isNonEmptyString && - parentToken->Option.isSome && - (granularity->Option.isSome || chartType !== "Line Chart") && - current_granularity->Array.includes(granularity->Option.getOr("")) - ) { - setTopChartFetchWithCurrentDependecyChange(_ => false) - } + React.useEffect4( + () => { + let chartType = + getChartCompFilters->getString( + "chartType", + chartEntity.chartTypes->Array.get(0)->Option.getOr(Line)->DynamicChart.chartMapper, + ) + if ( + startTimeFromUrl->isNonEmptyString && + endTimeFromUrl->isNonEmptyString && + parentToken->Option.isSome && + (granularity->Option.isSome || chartType !== "Line Chart") && + current_granularity->Array.includes(granularity->Option.getOr("")) + ) { + setTopChartFetchWithCurrentDependecyChange(_ => false) + } - None - }, ( - parentToken, - current_granularity->Array.joinWith("-") ++ - granularity->Option.getOr("") ++ - cardinalityFromUrl ++ - selectedTrends->Array.joinWith(",") ++ - customFilter ++ - startTimeFromUrl ++ - segmentValue->Option.getOr([])->Array.joinWith(",") ++ - endTimeFromUrl, - filterValueFromUrl, - differentTimeValues->Array.map(item => `${item.fromTime}${item.toTime}`)->Array.joinWith(","), - )) + None + }, + ( + parentToken, + current_granularity->Array.joinWithUnsafe("-") ++ + granularity->Option.getOr("") ++ + cardinalityFromUrl ++ + selectedTrends->Array.joinWithUnsafe(",") ++ + customFilter ++ + startTimeFromUrl ++ + segmentValue->Option.getOr([])->Array.joinWithUnsafe(",") ++ + endTimeFromUrl, + filterValueFromUrl, + differentTimeValues + ->Array.map(item => `${item.fromTime}${item.toTime}`) + ->Array.joinWithUnsafe(","), + ), + ) React.useEffect2(() => { if !topChartFetchWithCurrentDependecyChange && topChartVisible { @@ -809,6 +818,7 @@ module SDKAnalyticsChartContext = { (), )->JSON.stringify, ~headers=[("QueryType", "Chart Time Series")]->Dict.fromArray, + ~betaEndpointConfig=?betaEndPointConfig, (), ) ->addLogsAroundFetch(~logTitle=`Chart fetch`) @@ -826,7 +836,7 @@ module SDKAnalyticsChartContext = { : None }, ) - ->Array.joinWith("-dimension-") + ->Array.joinWithUnsafe("-dimension-") }, ) @@ -849,6 +859,7 @@ module SDKAnalyticsChartContext = { (), )->JSON.stringify, ~headers=[("QueryType", "Chart Time Series")]->Dict.fromArray, + ~betaEndpointConfig=?betaEndPointConfig, (), ) ->addLogsAroundFetch(~logTitle=`Chart fetch`) @@ -873,7 +884,7 @@ module SDKAnalyticsChartContext = { : None }, ) - ->Array.joinWith("-dimension-") + ->Array.joinWithUnsafe("-dimension-") groupedArr->Array.includes(origDictArr) ? Some( @@ -979,6 +990,7 @@ module SDKAnalyticsChartContext = { // (), // )->JSON.stringify, // ~headers=[("QueryType", "Chart Time Series")]->Dict.fromArray, + // ~betaEndpointConfig=?betaEndPointConfig, // (), // ) // ->addLogsAroundFetch(~logTitle=`Chart fetch`) diff --git a/src/context/FilterContext.res b/src/context/FilterContext.res index 5fcefc4b4..a9cef4373 100644 --- a/src/context/FilterContext.res +++ b/src/context/FilterContext.res @@ -37,8 +37,8 @@ let make = (~index: string, ~children) => { let (filterDict, setfilterDict) = React.useState(_ => searcParamsToDict) let clearSessionStorage = () => { - sessionStorage.removeItem(. index) - sessionStorage.removeItem(. `${index}-list`) + sessionStorage.removeItem(index) + sessionStorage.removeItem(`${index}-list`) setfilterKeys(_ => []) } @@ -118,12 +118,12 @@ let make = (~index: string, ~children) => { }, (filterDict, setfilterDict, filterKeys)) React.useEffect0(() => { - switch sessionStorage.getItem(. index)->Nullable.toOption { + switch sessionStorage.getItem(index)->Nullable.toOption { | Some(value) => value->FilterUtils.parseFilterString->updateFilter.updateExistingKeys | None => () } let keys = [] - switch sessionStorage.getItem(. `${index}-list`)->Nullable.toOption { + switch sessionStorage.getItem(`${index}-list`)->Nullable.toOption { | Some(value) => switch value->JSON.parseExn->JSON.Decode.array { | Some(arr) => @@ -144,10 +144,10 @@ let make = (~index: string, ~children) => { React.useEffect2(() => { if !(query.contents->String.length < 1) { - sessionStorage.setItem(. index, query.contents) + sessionStorage.setItem(index, query.contents) } - sessionStorage.setItem(. + sessionStorage.setItem( `${index}-list`, filterKeys->Array.map(item => item->JSON.Encode.string)->JSON.Encode.array->JSON.stringify, ) diff --git a/src/context/MatchMedia.res b/src/context/MatchMedia.res index e72c7c347..12e3457de 100644 --- a/src/context/MatchMedia.res +++ b/src/context/MatchMedia.res @@ -12,9 +12,9 @@ let useMatchMedia = mediaQuery => { let matched = ev.matches setIsMatched(_prev => matched) } - mediaQueryList.addListener(. screenTest) + mediaQueryList.addListener(screenTest) - Some(() => mediaQueryList.removeListener(. screenTest)) + Some(() => mediaQueryList.removeListener(screenTest)) }, [mediaQueryList]) isMatched } diff --git a/src/context/SingleStatContext.res b/src/context/SingleStatContext.res index a0270bcb4..a91dd4b0b 100644 --- a/src/context/SingleStatContext.res +++ b/src/context/SingleStatContext.res @@ -56,7 +56,7 @@ let make = ( let parentToken = AuthWrapperUtils.useTokenParent(Original) let addLogsAroundFetch = EulerAnalyticsLogUtils.useAddLogsAroundFetchNew() let betaEndPointConfig = React.useContext(BetaEndPointConfigProvider.betaEndPointConfig) - let fetchApi = AuthHooks.useApiFetcher(~betaEndpointConfig=?betaEndPointConfig, ()) + let fetchApi = AuthHooks.useApiFetcher() let getTopLevelSingleStatFilter = React.useMemo1(() => { getAllFilter @@ -96,7 +96,7 @@ let make = ( None } }) - ->Array.joinWith("&") + ->Array.joinWithUnsafe("&") ( filterSearchParam, @@ -260,6 +260,7 @@ let make = ( (), )->JSON.stringify, ~headers=[("QueryType", "SingleStatHistoric")]->Dict.fromArray, + ~betaEndpointConfig=?betaEndPointConfig, (), ) ->addLogsAroundFetch( @@ -311,6 +312,7 @@ let make = ( (), )->JSON.stringify, ~headers=[("QueryType", "SingleStat")]->Dict.fromArray, + ~betaEndpointConfig=?betaEndPointConfig, (), ) ->addLogsAroundFetch(~logTitle=`SingleStat data for metrics ${metrics->metrixMapper}`) @@ -361,6 +363,7 @@ let make = ( (), )->JSON.stringify, ~headers=[("QueryType", "SingleStat Time Series")]->Dict.fromArray, + ~betaEndpointConfig=?betaEndPointConfig, (), ) ->addLogsAroundFetch( diff --git a/src/context/ThemeUtils.res b/src/context/ThemeUtils.res index 81683fef9..92f5ff7d2 100644 --- a/src/context/ThemeUtils.res +++ b/src/context/ThemeUtils.res @@ -4,7 +4,7 @@ let useThemeFromEvent = () => { React.useEffect0(() => { let setEventThemeVal = (eventName, dict) => { if eventName === "AuthenticationDetails" { - let payloadDict = dict->Dict.get("payload")->Option.flatMap(JSON.Decode.object) + let payloadDict = dict->Dict.get("payload")->Option.flatMap(obj => obj->JSON.Decode.object) let theme = payloadDict->Option.mapOr("", finalDict => LogicUtils.getString(finalDict, "theme", "")) setEventTheme(_ => Some(theme)) @@ -20,7 +20,8 @@ let useThemeFromEvent = () => { let optionalDict = HandlingEvents.getEventDict(ev) switch optionalDict { | Some(dict) => { - let optionalEventName = dict->Dict.get("eventType")->Option.flatMap(JSON.Decode.string) + let optionalEventName = + dict->Dict.get("eventType")->Option.flatMap(obj => obj->JSON.Decode.string) switch optionalEventName { | Some(eventName) => setEventThemeVal(eventName, dict) | None => Js.log2("Event Data is not found", dict) diff --git a/src/context/UserPrefContext.res b/src/context/UserPrefContext.res index a9326932c..10a2c68e0 100644 --- a/src/context/UserPrefContext.res +++ b/src/context/UserPrefContext.res @@ -51,7 +51,10 @@ let make = (~children) => { } let (userPref, setUserPref) = React.useState(_ => userPrefInitialVal) let url = RescriptReactRouter.useUrl() - let urlPathConcationation = `/${url.path->LogicUtils.stripV4->List.toArray->Array.joinWith("/")}` + let urlPathConcationation = `/${url.path + ->LogicUtils.stripV4 + ->List.toArray + ->Array.joinWithUnsafe("/")}` // UPDATE THE LAST VISITED TAB React.useEffect2(() => { if urlPathConcationation !== "/" { @@ -104,7 +107,7 @@ let make = (~children) => { `${key}=${value}` }, ) - ->Array.joinWith("&") + ->Array.joinWithUnsafe("&") let isMarketplaceApp = urlPathConcationation == "/marketplace" moduleWisePref->Dict.set( urlPathConcationation, diff --git a/src/entities/analytics/AnalyticsUtils.res b/src/entities/analytics/AnalyticsUtils.res index f7adf0762..2021ac769 100644 --- a/src/entities/analytics/AnalyticsUtils.res +++ b/src/entities/analytics/AnalyticsUtils.res @@ -282,14 +282,11 @@ let getFilterRequestBody = ( let filterBody = (filterBodyEntity: filterBodyEntity) => { let (startTime, endTime) = try { ( - (filterBodyEntity.startTime->DayJs.getDayJsForString).subtract(. + (filterBodyEntity.startTime->DayJs.getDayJsForString).subtract( 1, "day", - ).toDate(.)->Date.toISOString, - (filterBodyEntity.endTime->DayJs.getDayJsForString).add(. - 1, - "day", - ).toDate(.)->Date.toISOString, + ).toDate()->Date.toISOString, + (filterBodyEntity.endTime->DayJs.getDayJsForString).add(1, "day").toDate()->Date.toISOString, ) } catch { | _ => (filterBodyEntity.startTime, filterBodyEntity.endTime) @@ -309,12 +306,12 @@ let deltaDate = (~fromTime: string, ~_toTime: string, ~typeTime: string) => { let nowtime = Date.make()->Date.toString->DayJs.getDayJsForString let dateTimeFormat = "YYYY-MM-DDTHH:mm:ss[Z]" if typeTime == "last7" { - let last7FromTime = (fromTime->DayJs.getDayJsForString).subtract(. 7, "day") - let last7ToTime = (fromTime->DayJs.getDayJsForString).subtract(. 1, "day") + let last7FromTime = (fromTime->DayJs.getDayJsForString).subtract(7, "day") + let last7ToTime = (fromTime->DayJs.getDayJsForString).subtract(1, "day") let timeArray = Dict.fromArray([ - ("fromTime", last7FromTime.format(. dateTimeFormat)), - ("toTime", last7ToTime.format(. dateTimeFormat)), + ("fromTime", last7FromTime.format(dateTimeFormat)), + ("toTime", last7ToTime.format(dateTimeFormat)), ]) [timeArray] @@ -322,7 +319,7 @@ let deltaDate = (~fromTime: string, ~_toTime: string, ~typeTime: string) => { let yesterdayFromTime = Js.Date.fromFloat( Js.Date.setHoursMS( - nowtime.subtract(. 1, "day").toDate(.), + nowtime.subtract(1, "day").toDate(), ~hours=0.0, ~minutes=0.0, ~seconds=0.0, @@ -332,7 +329,7 @@ let deltaDate = (~fromTime: string, ~_toTime: string, ~typeTime: string) => { let yesterdayToTime = Js.Date.fromFloat( Js.Date.setHoursMS( - nowtime.subtract(. 1, "day").toDate(.), + nowtime.subtract(1, "day").toDate(), ~hours=23.0, ~minutes=59.0, ~seconds=59.0, @@ -341,8 +338,8 @@ let deltaDate = (~fromTime: string, ~_toTime: string, ~typeTime: string) => { )->DayJs.getDayJsForJsDate let timeArray = Dict.fromArray([ - ("fromTime", yesterdayFromTime.format(. dateTimeFormat)), - ("toTime", yesterdayToTime.format(. dateTimeFormat)), + ("fromTime", yesterdayFromTime.format(dateTimeFormat)), + ("toTime", yesterdayToTime.format(dateTimeFormat)), ]) [timeArray] @@ -356,8 +353,8 @@ let deltaDate = (~fromTime: string, ~_toTime: string, ~typeTime: string) => { ->DayJs.getDayJsForString let currentMonthToTime = nowtime let timeArray = Dict.fromArray([ - ("fromTime", currentMonthFromTime.format(. dateTimeFormat)), - ("toTime", currentMonthToTime.format(. dateTimeFormat)), + ("fromTime", currentMonthFromTime.format(dateTimeFormat)), + ("toTime", currentMonthToTime.format(dateTimeFormat)), ]) [timeArray] @@ -366,8 +363,8 @@ let deltaDate = (~fromTime: string, ~_toTime: string, ~typeTime: string) => { let currentWeekToTime = Date.make()->DayJs.getDayJsForJsDate let timeArray = Dict.fromArray([ - ("fromTime", currentWeekFromTime.format(. dateTimeFormat)), - ("toTime", currentWeekToTime.format(. dateTimeFormat)), + ("fromTime", currentWeekFromTime.format(dateTimeFormat)), + ("toTime", currentWeekToTime.format(dateTimeFormat)), ]) [timeArray] @@ -587,7 +584,7 @@ let generateTablePayload = ( tableBody } -let singlestatDeltaTooltipFormat = (value: float, timeRanges: timeRanges, statType: string) => { +let singlestatDeltaTooltipFormat = (value: float, timeRanges: timeRanges) => (statType: string) => { let timeText = if timeRanges.fromTime->isNonEmptyString && timeRanges.toTime->isNonEmptyString { `${"\n"} ${timeRanges.fromTime ->Date.fromString diff --git a/src/entities/analytics/EulerAnalyticsLogUtils.res b/src/entities/analytics/EulerAnalyticsLogUtils.res index 4cddbc79b..8fce7ef02 100644 --- a/src/entities/analytics/EulerAnalyticsLogUtils.res +++ b/src/entities/analytics/EulerAnalyticsLogUtils.res @@ -32,7 +32,7 @@ let useAddLogsAroundFetch = () => { resolve(resp) } }) - ->then(Fetch.Response.json) + ->then(res => res->(res => res->Fetch.Response.json)) ->thenResolve(json => { json }) @@ -76,7 +76,7 @@ let useAddLogsAroundFetchNew = () => { resolve(resp) } }) - ->then(Fetch.Response.text) + ->then(res => res->Fetch.Response.text) ->thenResolve(text => { // will add the check for n line saperated is the length is 0 then no data // if ( diff --git a/src/entryPoints/AuthModule/BasicAuth/BasicAuth.res b/src/entryPoints/AuthModule/BasicAuth/BasicAuth.res index 350e7b923..b40a1922c 100644 --- a/src/entryPoints/AuthModule/BasicAuth/BasicAuth.res +++ b/src/entryPoints/AuthModule/BasicAuth/BasicAuth.res @@ -176,7 +176,7 @@ let make = (~authType, ~setAuthType) => { let body = email->getEmailBody() setForgetPassword(body) - | _ => Promise.make((resolve, _) => resolve(. Nullable.null)) + | _ => Promise.make((resolve, _) => resolve(Nullable.null)) } } ) diff --git a/src/entryPoints/AuthModule/Common/CommonAuthUtils.res b/src/entryPoints/AuthModule/Common/CommonAuthUtils.res index 596c64636..5af90b435 100644 --- a/src/entryPoints/AuthModule/Common/CommonAuthUtils.res +++ b/src/entryPoints/AuthModule/Common/CommonAuthUtils.res @@ -25,7 +25,7 @@ let passwordKeyValidation = (value, key, keyVal, errors) => { Dict.set( errors, key, - `Your password is not strong enough. A good password must contain atleast ${mustHave->Array.joinWith( + `Your password is not strong enough. A good password must contain atleast ${mustHave->Array.joinWithUnsafe( ",", )} character`->JSON.Encode.string, ) @@ -38,11 +38,7 @@ let confirmPasswordCheck = (value, key, confirmKey, passwordKey, valuesDict, err if ( key === confirmKey && value->LogicUtils.isNonEmptyString && - !Js.Option.equal( - (. a, b) => a == b, - Dict.get(valuesDict, passwordKey), - Dict.get(valuesDict, key), - ) + !Option.equal(Dict.get(valuesDict, passwordKey), Dict.get(valuesDict, key), (a, b) => a == b) ) { Dict.set(errors, key, "The New password does not match!"->JSON.Encode.string) } diff --git a/src/entryPoints/AuthModule/Common/CommonInputFields.res b/src/entryPoints/AuthModule/Common/CommonInputFields.res index 4cb94120a..8463cd094 100644 --- a/src/entryPoints/AuthModule/Common/CommonInputFields.res +++ b/src/entryPoints/AuthModule/Common/CommonInputFields.res @@ -4,7 +4,7 @@ let emailField = FormRenderer.makeFieldInfo( ~placeholder="Enter your Email", ~isRequired=false, ~customInput=(~input, ~placeholder as _) => - InputFields.textInput( + InputFields.textInput(~autoComplete="off", ())( ~input={ ...input, onChange: event => @@ -14,8 +14,6 @@ let emailField = FormRenderer.makeFieldInfo( ->input.onChange, }, ~placeholder="Enter your Email", - ~autoComplete="off", - (), ), (), ) diff --git a/src/entryPoints/AuthModule/TwoFaAuth/TwoFaAuth.res b/src/entryPoints/AuthModule/TwoFaAuth/TwoFaAuth.res index 754c896fd..d75048602 100644 --- a/src/entryPoints/AuthModule/TwoFaAuth/TwoFaAuth.res +++ b/src/entryPoints/AuthModule/TwoFaAuth/TwoFaAuth.res @@ -178,7 +178,7 @@ let make = (~setAuthStatus, ~authType, ~setAuthType) => { let body = email->getEmailBody() resendVerifyEmail(body) } else { - Promise.make((resolve, _) => resolve(. Nullable.null)) + Promise.make((resolve, _) => resolve(Nullable.null)) } } @@ -189,7 +189,7 @@ let make = (~setAuthStatus, ~authType, ~setAuthType) => { setForgetPassword(body) } else { - Promise.make((resolve, _) => resolve(. Nullable.null)) + Promise.make((resolve, _) => resolve(Nullable.null)) } } @@ -200,7 +200,14 @@ let make = (~setAuthStatus, ~authType, ~setAuthType) => { let body = getResetpasswordBodyJson(password, password_reset_token) setResetPassword(body) } - | _ => Promise.make((resolve, _) => resolve(. Nullable.null)) + | _ => + switch (featureFlagValues.email, authType) { + | (true, ForgetPassword) => + let body = email->getEmailBody() + + setForgetPassword(body) + | _ => Promise.make((resolve, _) => resolve(Nullable.null)) + } } ) } catch { diff --git a/src/entryPoints/HyperSwitchApp.res b/src/entryPoints/HyperSwitchApp.res index 787174ca1..3b8f3130e 100644 --- a/src/entryPoints/HyperSwitchApp.res +++ b/src/entryPoints/HyperSwitchApp.res @@ -116,7 +116,7 @@ let make = () => { response->getArrayFromJson([])->Array.map(ele => ele->JSON.Decode.string->Option.getOr("")) let permissionJson = permissionsValue->Array.map(ele => ele->mapStringToPermissionType)->getPermissionJson - setuserPermissionJson(._ => permissionJson) + setuserPermissionJson(_ => permissionJson) permissionJson } catch { | Exn.Error(e) => { @@ -451,7 +451,7 @@ let make = () => { entityName="PaymentSettings" remainingPath renderList={() => } - renderShow={profileId => + renderShow={_profileId => } /> | list{"recon"} => @@ -484,7 +484,7 @@ let make = () => { entityName="ConfigurePMTs" remainingPath renderList={() => } - renderShow={value => + renderShow={_value => } @@ -508,7 +508,7 @@ let make = () => { entityName="ConfigurePMTs" remainingPath renderList={() => } - renderShow={profileId => + renderShow={_profileId => } /> diff --git a/src/entryPoints/HyperSwitchEntry.res b/src/entryPoints/HyperSwitchEntry.res index b1ca20154..e70a1ef6d 100644 --- a/src/entryPoints/HyperSwitchEntry.res +++ b/src/entryPoints/HyperSwitchEntry.res @@ -75,7 +75,7 @@ module HyperSwitchEntryComponent = { let apiURL = `${HSwitchGlobalVars.getHostUrlWithBasePath}/config/merchant-config?domain=${domain}` let res = await fetchDetails(apiURL) let featureFlags = res->FeatureFlagUtils.featureFlagType - setFeatureFlag(._ => featureFlags) + setFeatureFlag(_ => featureFlags) let _ = res->configTheme let _ = res->configURL // Delay added on Expecting feature flag recoil gets updated @@ -112,7 +112,7 @@ module HyperSwitchEntryComponent = { let userId = MixPanel.getDistinctId() LocalStorage.setItem("deviceid", userId) MixPanel.identify(userId) - MixPanel.mixpanel.people.set(. mixpanelUserInfo) + MixPanel.mixpanel.people.set(mixpanelUserInfo) }, }, ) diff --git a/src/entryPoints/HyperSwitchEntryUtils.res b/src/entryPoints/HyperSwitchEntryUtils.res index 1784ad311..c256f6232 100644 --- a/src/entryPoints/HyperSwitchEntryUtils.res +++ b/src/entryPoints/HyperSwitchEntryUtils.res @@ -3,13 +3,13 @@ open LogicUtils let setSessionData = (~key, ~searchParams) => { let result = searchParams->getDictFromUrlSearchParams->Dict.get(key) switch result { - | Some(data) => sessionStorage.setItem(. key, data) + | Some(data) => sessionStorage.setItem(key, data) | None => () } } let getSessionData = (~key, ~defaultValue="", ()) => { - let result = sessionStorage.getItem(. key)->Nullable.toOption->Option.getOr("")->getNonEmptyString + let result = sessionStorage.getItem(key)->Nullable.toOption->Option.getOr("")->getNonEmptyString switch result { | Some(data) => data | None => defaultValue diff --git a/src/entryPoints/WooCommerce/WooCommerce.res b/src/entryPoints/WooCommerce/WooCommerce.res index 9b8c25aaa..e414c5863 100644 --- a/src/entryPoints/WooCommerce/WooCommerce.res +++ b/src/entryPoints/WooCommerce/WooCommerce.res @@ -218,7 +218,7 @@ module ConfigureWebHook = { @react.component let make = () => { - let usePostEnumDetails = EnumVariantHook.usePostEnumDetails() + let postEnumDetails = EnumVariantHook.usePostEnumDetails() let enumDetails = Recoil.useRecoilValueFromAtom(HyperswitchAtom.enumVariantAtom) let (selectedConnector, setSelectedConnector) = React.useState(_ => UnknownConnector("")) let (initialValues, setInitialValues) = React.useState(_ => Dict.make()->JSON.Encode.object) @@ -245,7 +245,7 @@ let make = () => { try { if forward && !(stepInView->enumToValueMapper(enums)) { let currentStepVariant = stepInView->variantToEnumMapper - let _ = await Boolean(true)->usePostEnumDetails(currentStepVariant) + let _ = await Boolean(true)->postEnumDetails(currentStepVariant) setStepInView(prev => { switch prev { | PLUGIN_INSTALL => forward ? PLUGIN_CONFIGURE : PLUGIN_INSTALL diff --git a/src/entryPoints/WooCommerce/WooCommerceUIUtils.res b/src/entryPoints/WooCommerce/WooCommerceUIUtils.res index 532093ad5..10100fce7 100644 --- a/src/entryPoints/WooCommerce/WooCommerceUIUtils.res +++ b/src/entryPoints/WooCommerce/WooCommerceUIUtils.res @@ -9,7 +9,7 @@ module SelectProcessor = { ) => { let url = RescriptReactRouter.useUrl() let connectorName = selectedConnector->ConnectorUtils.getConnectorNameString - let basePath = url.path->List.toArray->Array.joinWith("/") + let basePath = url.path->List.toArray->Array.joinWithUnsafe("/") { } body->then(body => { - setReqProgress(. p => p + 1) + setReqProgress(p => p + 1) Fetch.fetchWithInit( uri, Fetch.RequestInit.make( @@ -88,13 +88,13 @@ let useApiFetcher = () => { ) ->catch( err => { - setReqProgress(. p => p - 1) + setReqProgress(p => p - 1) reject(err) }, ) ->then( resp => { - setReqProgress(. p => p - 1) + setReqProgress(p => p - 1) if resp->Fetch.Response.status === 401 { switch authStatus { | LoggedIn(_) => diff --git a/src/hooks/DateRefreshHooks.res b/src/hooks/DateRefreshHooks.res index 0c0b49f02..73002e7c2 100644 --- a/src/hooks/DateRefreshHooks.res +++ b/src/hooks/DateRefreshHooks.res @@ -6,8 +6,8 @@ let useConstructQueryOnBasisOfOpt = () => { let isoStringToCustomTimezoneInFloat = TimeZoneHook.useIsoStringToCustomTimeZoneInFloat() let todayDayJsObj = Date.make()->Date.toString->getDayJsForString - let todayDate = todayDayJsObj.format(. "YYYY-MM-DD") - let todayTime = todayDayJsObj.format(. "HH:mm:ss") + let todayDate = todayDayJsObj.format("YYYY-MM-DD") + let todayTime = todayDayJsObj.format("HH:mm:ss") (~queryString, ~disableFutureDates, ~disablePastDates, ~startKey, ~endKey, ~optKey) => { if queryString->String.includes(optKey) { try { @@ -68,7 +68,7 @@ let useConstructQueryOnBasisOfOpt = () => { x } ) - updatedArr->Array.joinWith("&") + updatedArr->Array.joinWithUnsafe("&") } catch { | _error => queryString } diff --git a/src/hooks/ModalsState.res b/src/hooks/ModalsState.res index 21bbc62ec..02abcde6c 100644 --- a/src/hooks/ModalsState.res +++ b/src/hooks/ModalsState.res @@ -7,4 +7,4 @@ type modalProps = { let defaultOpenModals: array = [] -let openModals = Recoil.atom(. "openModals", defaultOpenModals) +let openModals = Recoil.atom("openModals", defaultOpenModals) diff --git a/src/hooks/PopUpState.res b/src/hooks/PopUpState.res index 1e6979185..c88fd2125 100644 --- a/src/hooks/PopUpState.res +++ b/src/hooks/PopUpState.res @@ -19,12 +19,12 @@ type popUpProps = { let defaultOpenPopUp: array = [] -let openPopUp = Recoil.atom(. "openPopUp", defaultOpenPopUp) +let openPopUp = Recoil.atom("openPopUp", defaultOpenPopUp) let useShowPopUp = () => { let setOpenPopUp = Recoil.useSetRecoilState(openPopUp) React.useCallback1((popUpProps: popUpProps) => { - setOpenPopUp(.prevArr => prevArr->Array.concat([popUpProps])) + setOpenPopUp(prevArr => prevArr->Array.concat([popUpProps])) }, [setOpenPopUp]) } diff --git a/src/hooks/SnackBarState.res b/src/hooks/SnackBarState.res index d0c535f61..61938895c 100644 --- a/src/hooks/SnackBarState.res +++ b/src/hooks/SnackBarState.res @@ -16,7 +16,7 @@ type snackbarProps = { let defaultOpenSnackbar: array = [] -let openSnackbar = Recoil.atom(. "openSnackbar", defaultOpenSnackbar) +let openSnackbar = Recoil.atom("openSnackbar", defaultOpenSnackbar) type showSnackbarFn = ( ~heading: string, diff --git a/src/hooks/TimeZoneHook.res b/src/hooks/TimeZoneHook.res index 9cb51e3ba..7d36f96da 100644 --- a/src/hooks/TimeZoneHook.res +++ b/src/hooks/TimeZoneHook.res @@ -51,7 +51,7 @@ let dateTimeStringToDateTimeFloat = (dateTime: dateTimeString) => { } let formattedDateTimeFloat = (dateTime: dateTimeFloat, format: string) => { - (dateTime->dateTimeObjectToDate->Date.toString->DayJs.getDayJsForString).format(. format) + (dateTime->dateTimeObjectToDate->Date.toString->DayJs.getDayJsForString).format(format) } let formattedDateTimeString = (dateTime: dateTimeString, format: string) => { diff --git a/src/hooks/ToastState.res b/src/hooks/ToastState.res index 972412789..65a4b86cb 100644 --- a/src/hooks/ToastState.res +++ b/src/hooks/ToastState.res @@ -49,7 +49,7 @@ let makeToastProps = ( let defaultOpenToasts: array = [] -let openToasts = Recoil.atom(. "openToasts", defaultOpenToasts) +let openToasts = Recoil.atom("openToasts", defaultOpenToasts) type showToastFn = ( ~message: string, @@ -64,9 +64,8 @@ type showToastFn = ( let useShowToast = (): showToastFn => { let setOpenToasts = Recoil.useSetRecoilState(openToasts) - React.useMemo1( + React.useMemo1(() => { ( - (), ~message, ~toastType: toastType, ~toastDuration=0, @@ -87,8 +86,7 @@ let useShowToast = (): showToastFn => { (), ) - setOpenToasts(.prevArr => prevArr->Array.concat([toastProps])) - }, - [setOpenToasts], - ) + setOpenToasts(prevArr => prevArr->Array.concat([toastProps])) + } + }, [setOpenToasts]) } diff --git a/src/libraries/CsvToJson.res b/src/libraries/CsvToJson.res index 294e3f78b..b19a4c055 100644 --- a/src/libraries/CsvToJson.res +++ b/src/libraries/CsvToJson.res @@ -1,5 +1,5 @@ -type csvjson = {csv2json: (. string) => JSON.t} -type jsoncsv = {json2csv: (. JSON.t) => string} +type csvjson = {csv2json: string => JSON.t} +type jsoncsv = {json2csv: JSON.t => string} @module @val external csvtojson: csvjson = "csvjson-csv2json" diff --git a/src/libraries/DayJs.res b/src/libraries/DayJs.res index a56c3ddd6..e12ae39ff 100644 --- a/src/libraries/DayJs.res +++ b/src/libraries/DayJs.res @@ -10,23 +10,23 @@ external isToday: relativeTime = "default" external customParseFormat: relativeTime = "default" type rec dayJs = { - isValid: (. unit) => bool, - toString: (. unit) => string, - toDate: (. unit) => Date.t, - add: (. int, string) => dayJs, - isSame: (. string, string) => bool, - subtract: (. int, string) => dayJs, - diff: (. string, string) => int, - year: (. unit) => int, - date: (. int) => dayJs, - endOf: (. string) => dayJs, - format: (. string) => string, - fromNow: (. unit) => string, - month: (. unit) => int, - isToday: (. unit) => bool, + isValid: unit => bool, + toString: unit => string, + toDate: unit => Date.t, + add: (int, string) => dayJs, + isSame: (string, string) => bool, + subtract: (int, string) => dayJs, + diff: (string, string) => int, + year: unit => int, + date: int => dayJs, + endOf: string => dayJs, + format: string => string, + fromNow: unit => string, + month: unit => int, + isToday: unit => bool, } -type extendable = {extend: (. relativeTime) => unit} +type extendable = {extend: relativeTime => unit} @module("dayjs") external dayJs: extendable = "default" diff --git a/src/libraries/Document.res b/src/libraries/Document.res index d97c64a66..2f2dd55fd 100644 --- a/src/libraries/Document.res +++ b/src/libraries/Document.res @@ -1,6 +1,6 @@ type domElement -type document = {querySelectorAll: (. string) => array} +type document = {querySelectorAll: string => array} @val external document: document = "document" @val @scope("document") diff --git a/src/libraries/FileReader.res b/src/libraries/FileReader.res index 65ac06da1..c38d4a95d 100644 --- a/src/libraries/FileReader.res +++ b/src/libraries/FileReader.res @@ -4,9 +4,9 @@ type file type read = { mutable onload: arg => unit, - readAsText: (. string) => unit, - readAsBinaryString: (. string) => unit, - readAsDataURL: (. file) => unit, + readAsText: string => unit, + readAsBinaryString: string => unit, + readAsDataURL: file => unit, result: string, onerror: string => unit, } diff --git a/src/libraries/GoogleAnalytics.res b/src/libraries/GoogleAnalytics.res index 596c4fdef..8f2534ee2 100644 --- a/src/libraries/GoogleAnalytics.res +++ b/src/libraries/GoogleAnalytics.res @@ -7,14 +7,14 @@ type eventType = { type pageViewType = {hitType: string, page: string} type analyticsType = { - initialize: (. string) => unit, - event: (. eventType) => unit, - send: (. pageViewType) => unit, + initialize: string => unit, + event: eventType => unit, + send: pageViewType => unit, } @module("react-ga4") external analytics: analyticsType = "default" let send = object => { - analytics.send(. object) + analytics.send(object) } diff --git a/src/libraries/HeadlessUI.res b/src/libraries/HeadlessUI.res index 05224e1d6..bf26b7384 100644 --- a/src/libraries/HeadlessUI.res +++ b/src/libraries/HeadlessUI.res @@ -460,9 +460,9 @@ module SelectBoxHeadlessUI = { }
- {menuProps => + {_menuProps =>
- {buttonProps => children} + {_buttonProps => children} - {props => + {_props => transformedOptions ->Array.mapWithIndex((option, index) => { let selected = switch value { diff --git a/src/libraries/Highcharts.res b/src/libraries/Highcharts.res index 6474bed96..03936d108 100644 --- a/src/libraries/Highcharts.res +++ b/src/libraries/Highcharts.res @@ -51,7 +51,7 @@ external makeSomethingSeries: (~\"type": string, ~something: (float, int, string let x = makeAreaSeries(~\"type"="hello", ~something=false) let y = makeSomethingSeries(~\"type"="hello", ~something=(2., 1, "heloo")) -type gridLine = {attr: (. JSON.t) => unit} +type gridLine = {attr: JSON.t => unit} type pos type tick = { gridLine: gridLine, @@ -59,7 +59,8 @@ type tick = { } type eventYaxis = {ticks: Dict.t} type chartEventOnload = {yAxis: array} -type chartEvent = {render: option unit>>} +@val external thisChartEventOnLoad: chartEventOnload = "this" +type chartEvent = {render: unit => unit} type chart = { "type": string, "zoomType": string, diff --git a/src/libraries/HighchartsGanttChartLazy.res b/src/libraries/HighchartsGanttChartLazy.res index b1fd6f394..e2ee39e97 100644 --- a/src/libraries/HighchartsGanttChartLazy.res +++ b/src/libraries/HighchartsGanttChartLazy.res @@ -7,4 +7,4 @@ type props = { constructorType: string, } -let make: props => React.element = reactLazy(.() => import_("highcharts-react-official")) +let make: props => React.element = reactLazy(() => import_("highcharts-react-official")) diff --git a/src/libraries/HighchartsHorizontalBarChart.res b/src/libraries/HighchartsHorizontalBarChart.res index 6e3b975e9..3f629dc81 100644 --- a/src/libraries/HighchartsHorizontalBarChart.res +++ b/src/libraries/HighchartsHorizontalBarChart.res @@ -1,7 +1,8 @@ type title = {text: string, align?: string, useHTML?: bool} type tooltipRecord = {category: string, y: int} +external asTooltipPointFormatter: Js_OO.Callback.arity1<'a> => tooltipRecord => string = "%identity" type tooltip = { - pointFormatter: Js_OO.Callback.arity1 string>, + pointFormatter: tooltipRecord => string, useHTML: bool, backgroundColor: string, borderColor: string, @@ -16,9 +17,11 @@ type series = { \"type": string, } type yAxisRecord = {series: series, x: string, y: int} +external asDataLabelFormatter: Js_OO.Callback.arity1<'a> => yAxisRecord => string = "%identity" + type dataLabels = { enabled: bool, - formatter?: Js_OO.Callback.arity1 string>, + formatter?: yAxisRecord => string, useHTML: bool, } @@ -35,9 +38,10 @@ type credits = {enabled: bool} type chart = {\"type": string, backgroundColor: string} type axis = {series: array, categories: array} type xAxisRecord = {axis: axis, value: string} +external asXLabelFormatter: Js_OO.Callback.arity1<'a> => xAxisRecord => string = "%identity" type labels = { enabled: bool, - formatter?: Js_OO.Callback.arity1 string>, + formatter?: xAxisRecord => string, useHTML?: bool, } type xAxis = {categories: array, lineWidth: int, opposite: bool, labels: labels} diff --git a/src/libraries/HighchartsPieChart.res b/src/libraries/HighchartsPieChart.res index 80c57d1e5..bf7c519eb 100644 --- a/src/libraries/HighchartsPieChart.res +++ b/src/libraries/HighchartsPieChart.res @@ -3,17 +3,19 @@ type point = {name: string, percentage: float} type yAxisRecord = {point: point} type tooltipRecord = {name: string, y: int} type style = {color: string, opacity: string} +external asTooltipPointFormatter: Js_OO.Callback.arity1<'a> => tooltipRecord => string = "%identity" type tooltip = { - pointFormatter: Js_OO.Callback.arity1 string>, + pointFormatter: tooltipRecord => string, useHTML: bool, backgroundColor: string, borderColor: string, headerFormat: string, } +external asDataLabelFormatter: Js_OO.Callback.arity1<'a> => yAxisRecord => string = "%identity" type dataLabels = { enabled: bool, connectorShape: string, - formatter: Js_OO.Callback.arity1 string>, + formatter: yAxisRecord => string, style: style, useHTML: bool, } diff --git a/src/libraries/HtmlToImage.res b/src/libraries/HtmlToImage.res index 2e4976134..279dcbe97 100644 --- a/src/libraries/HtmlToImage.res +++ b/src/libraries/HtmlToImage.res @@ -110,7 +110,7 @@ module T = { // fetchRequestInit?: 'a, //todo } - type t = (. ~node: Webapi.Dom.Element.t, ~options: options) => Promise.t + type t = (~node: Webapi.Dom.Element.t, ~options: options) => Promise.t } // not utilizing this // module Utils = { diff --git a/src/libraries/JsDatePicker.res b/src/libraries/JsDatePicker.res index 5fb698acf..e6cc40e3b 100644 --- a/src/libraries/JsDatePicker.res +++ b/src/libraries/JsDatePicker.res @@ -1,9 +1,9 @@ type input = {mutable value: string} -type date = {toLocaleDateString: (. unit) => string} +type date = {toLocaleDateString: unit => string} type instance type options = { formatter?: (input, date, instance) => unit, position?: [#tr | #tl | #br | #bl | #c], } @module("js-datepicker") -external datepicker: (. string, options) => unit = "default" +external datepicker: (string, options) => unit = "default" diff --git a/src/libraries/Lottie.res b/src/libraries/Lottie.res index 3c596e0ea..82ac8b296 100644 --- a/src/libraries/Lottie.res +++ b/src/libraries/Lottie.res @@ -8,4 +8,4 @@ type props = { initialSegment?: array, } -let make: props => React.element = reactLazy(.() => import_("lottie-react")) +let make: props => React.element = reactLazy(() => import_("lottie-react")) diff --git a/src/libraries/MixPanel.res b/src/libraries/MixPanel.res index ee8ee21b1..4d6b6c172 100644 --- a/src/libraries/MixPanel.res +++ b/src/libraries/MixPanel.res @@ -1,4 +1,4 @@ -type people = {set: (. JSON.t) => unit} +type people = {set: JSON.t => unit} type mixpanel = {people: people} @@ -6,10 +6,10 @@ type mixpanel = {people: people} external mixpanel: mixpanel = "default" @send external distinctIdWrapper: (mixpanel, unit) => string = "get_distinct_id" -let getDistinctId = distinctIdWrapper(mixpanel) +let getDistinctId = distinctIdWrapper(mixpanel, _) @send external identifyWrapper: (mixpanel, string) => unit = "identify" -let identify = identifyWrapper(mixpanel) +let identify = identifyWrapper(mixpanel, ...) let wasInitialied = ref(false) diff --git a/src/libraries/MonacoEditor.res b/src/libraries/MonacoEditor.res index 0e234bcfa..f3a1882cc 100644 --- a/src/libraries/MonacoEditor.res +++ b/src/libraries/MonacoEditor.res @@ -23,6 +23,6 @@ type props = { onMount?: Monaco.Editor.IStandaloneCodeEditor.t => unit, } -let make: props => React.element = reactLazy(.() => { +let make: props => React.element = reactLazy(() => { import_("@monaco-editor/react") }) diff --git a/src/libraries/PDFViewer/ReactPDFViewerSinglePageLazy.res b/src/libraries/PDFViewer/ReactPDFViewerSinglePageLazy.res index 241e36025..31cf8b109 100644 --- a/src/libraries/PDFViewer/ReactPDFViewerSinglePageLazy.res +++ b/src/libraries/PDFViewer/ReactPDFViewerSinglePageLazy.res @@ -9,4 +9,4 @@ type props = { error?: React.element, } -let make: props => React.element = reactLazy(.() => import_("./ReactPDFViewerSinglePage.bs.js")) +let make: props => React.element = reactLazy(() => import_("./ReactPDFViewerSinglePage.bs.js")) diff --git a/src/libraries/RRule.res b/src/libraries/RRule.res index 5ae5f45ae..deda33024 100644 --- a/src/libraries/RRule.res +++ b/src/libraries/RRule.res @@ -159,17 +159,17 @@ let isScheduled: (scheduleRuleRecipe, Date.t, Date.t, Date.t) => bool = ( | Yearly => mod(getYear(currentTime) - getYear(startTime), recur.interval) == 0 | Monthly => mod( - (currentTime->DayJs.getDayJsForJsDate).diff(. Date.toString(startTime), "month"), + (currentTime->DayJs.getDayJsForJsDate).diff(Date.toString(startTime), "month"), recur.interval, ) == 0 | Weekly => mod( - (currentTime->DayJs.getDayJsForJsDate).diff(. Date.toString(startTime), "week"), + (currentTime->DayJs.getDayJsForJsDate).diff(Date.toString(startTime), "week"), recur.interval, ) == 0 | Daily => mod( - (currentTime->DayJs.getDayJsForJsDate).diff(. Date.toString(startTime), "day"), + (currentTime->DayJs.getDayJsForJsDate).diff(Date.toString(startTime), "day"), recur.interval, ) == 0 } diff --git a/src/libraries/ReactFinalForm.res b/src/libraries/ReactFinalForm.res index afe7d5202..bfe6e350b 100644 --- a/src/libraries/ReactFinalForm.res +++ b/src/libraries/ReactFinalForm.res @@ -173,13 +173,13 @@ module Field = { ~component: string=?, ~data: bool=?, ~defaultValue: bool=?, - ~format: (. ~value: JSON.t, ~name: string) => JSON.t=?, + ~format: (~value: JSON.t, ~name: string) => JSON.t=?, ~formatOnBlur: bool=?, ~initialValue: bool=?, ~isEqual: bool=?, ~multiple: bool=?, ~name: string, - ~parse: (. ~value: JSON.t, ~name: string) => JSON.t=?, + ~parse: (~value: JSON.t, ~name: string) => JSON.t=?, ~ref: bool=?, ~render: fieldRenderProps => React.element=?, ~subscription: bool=?, @@ -226,8 +226,8 @@ type useFieldOption @obj external makeUseFieldOption: ( - ~format: (. ~value: JSON.t, ~name: string) => JSON.t=?, - ~parse: (. ~value: JSON.t, ~name: string) => JSON.t=?, + ~format: (~value: JSON.t, ~name: string) => JSON.t=?, + ~parse: (~value: JSON.t, ~name: string) => JSON.t=?, unit, ) => useFieldOption = "" diff --git a/src/libraries/Recoil.res b/src/libraries/Recoil.res index 4d75ec19b..216beda03 100644 --- a/src/libraries/Recoil.res +++ b/src/libraries/Recoil.res @@ -7,14 +7,14 @@ type recoilAtom<'v> = RecoilAtom('v) type recoilSelector<'v> = RecoilSelector('v) @module("./recoil") -external atom: (. string, 'v) => recoilAtom<'v> = "atom" +external atom: (string, 'v) => recoilAtom<'v> = "atom" @module("recoil") -external useRecoilState: recoilAtom<'valueT> => ('valueT, (. 'valueT => 'valueT) => unit) = +external useRecoilState: recoilAtom<'valueT> => ('valueT, ('valueT => 'valueT) => unit) = "useRecoilState" @module("recoil") -external useSetRecoilState: recoilAtom<'valueT> => (. 'valueT => 'valueT) => unit = +external useSetRecoilState: recoilAtom<'valueT> => ('valueT => 'valueT) => unit = "useSetRecoilState" @module("recoil") diff --git a/src/libraries/SessionStorage.res b/src/libraries/SessionStorage.res index 5eb55d10f..cee2e54e8 100644 --- a/src/libraries/SessionStorage.res +++ b/src/libraries/SessionStorage.res @@ -1,7 +1,7 @@ type sessionStorage = { - getItem: (. string) => Nullable.t, - setItem: (. string, string) => unit, - removeItem: (. string) => unit, + getItem: string => Nullable.t, + setItem: (string, string) => unit, + removeItem: string => unit, } @val external sessionStorage: sessionStorage = "sessionStorage" diff --git a/src/libraries/Window.res b/src/libraries/Window.res index 347627478..ffa2f4cfe 100644 --- a/src/libraries/Window.res +++ b/src/libraries/Window.res @@ -106,8 +106,8 @@ module MatchMedia = { type queryResponse = { matches: bool, - addListener: (. matchEvent => unit) => unit, - removeListener: (. matchEvent => unit) => unit, + addListener: (matchEvent => unit) => unit, + removeListener: (matchEvent => unit) => unit, } } @@ -173,16 +173,16 @@ module Screen = { external screenWidth: string = "width" } -type date = {getTimezoneOffset: (. unit) => float} +type date = {getTimezoneOffset: unit => float} @new external date: unit => date = "Date" let date = date() -let timeZoneOffset = date.getTimezoneOffset(.)->Float.toString +let timeZoneOffset = date.getTimezoneOffset()->Float.toString type options = {timeZone: string} -type dateTimeFormat = {resolvedOptions: (. unit) => options} +type dateTimeFormat = {resolvedOptions: unit => options} @val @scope("Intl") -external dateTimeFormat: (. unit) => dateTimeFormat = "DateTimeFormat" +external dateTimeFormat: unit => dateTimeFormat = "DateTimeFormat" module History = { @val @scope(("window", "history")) diff --git a/src/libraries/bsfetch/Fetch.res b/src/libraries/bsfetch/Fetch.res new file mode 100644 index 000000000..6c5b1bed4 --- /dev/null +++ b/src/libraries/bsfetch/Fetch.res @@ -0,0 +1,499 @@ +type body +type bodyInit +type headers +type headersInit +type response +type request +type requestInit +type abortController +type signal + +/* external */ +type arrayBuffer /* TypedArray */ +type bufferSource /* Web IDL, either an arrayBuffer or arrayBufferView */ +type formData /* XMLHttpRequest */ +type readableStream /* Streams */ +type urlSearchParams /* URL */ + +type blob +type file + +module AbortController = { + type t = abortController + + @get external signal: t => signal = "signal" + @send external abort: t => unit = "abort" + @new external make: unit => t = "AbortController" +} + +type requestMethod = + | Get + | Head + | Post + | Put + | Delete + | Connect + | Options + | Trace + | Patch + | Other(string) +let encodeRequestMethod = x => + /* internal */ + + switch x { + | Get => "GET" + | Head => "HEAD" + | Post => "POST" + | Put => "PUT" + | Delete => "DELETE" + | Connect => "CONNECT" + | Options => "OPTIONS" + | Trace => "TRACE" + | Patch => "PATCH" + | Other(method_) => method_ + } +let decodeRequestMethod = x => + /* internal */ + + switch x { + | "GET" => Get + | "HEAD" => Head + | "POST" => Post + | "PUT" => Put + | "DELETE" => Delete + | "CONNECT" => Connect + | "OPTIONS" => Options + | "TRACE" => Trace + | "PATCH" => Patch + | method_ => Other(method_) + } + +type referrerPolicy = + | None + | NoReferrer + | NoReferrerWhenDowngrade + | SameOrigin + | Origin + | StrictOrigin + | OriginWhenCrossOrigin + | StrictOriginWhenCrossOrigin + | UnsafeUrl +let encodeReferrerPolicy = x => + /* internal */ + + switch x { + | NoReferrer => "no-referrer" + | None => "" + | NoReferrerWhenDowngrade => "no-referrer-when-downgrade" + | SameOrigin => "same-origin" + | Origin => "origin" + | StrictOrigin => "strict-origin" + | OriginWhenCrossOrigin => "origin-when-cross-origin" + | StrictOriginWhenCrossOrigin => "strict-origin-when-cross-origin" + | UnsafeUrl => "unsafe-url" + } +let decodeReferrerPolicy = x => + /* internal */ + + switch x { + | "no-referrer" => NoReferrer + | "" => None + | "no-referrer-when-downgrade" => NoReferrerWhenDowngrade + | "same-origin" => SameOrigin + | "origin" => Origin + | "strict-origin" => StrictOrigin + | "origin-when-cross-origin" => OriginWhenCrossOrigin + | "strict-origin-when-cross-origin" => StrictOriginWhenCrossOrigin + | "unsafe-url" => UnsafeUrl + | e => raise(Failure("Unknown referrerPolicy: " ++ e)) + } + +type requestType = + | None /* default? unknown? just empty string in spec */ + | Audio + | Font + | Image + | Script + | Style + | Track + | Video +let decodeRequestType = x => + /* internal */ + + switch x { + | "audio" => Audio + | "" => None + | "font" => Font + | "image" => Image + | "script" => Script + | "style" => Style + | "track" => Track + | "video" => Video + | e => raise(Failure("Unknown requestType: " ++ e)) + } + +type requestDestination = + | None /* default? unknown? just empty string in spec */ + | Document + | Embed + | Font + | Image + | Manifest + | Media + | Object + | Report + | Script + | ServiceWorker + | SharedWorker + | Style + | Worker + | Xslt +let decodeRequestDestination = x => + /* internal */ + + switch x { + | "document" => Document + | "" => None + | "embed" => Embed + | "font" => Font + | "image" => Image + | "manifest" => Manifest + | "media" => Media + | "object" => Object + | "report" => Report + | "script" => Script + | "serviceworker" => ServiceWorker + | "sharedworder" => SharedWorker + | "style" => Style + | "worker" => Worker + | "xslt" => Xslt + | e => raise(Failure("Unknown requestDestination: " ++ e)) + } + +type requestMode = + | Navigate + | SameOrigin + | NoCORS + | CORS +let encodeRequestMode = x => + /* internal */ + + switch x { + | Navigate => "navigate" + | SameOrigin => "same-origin" + | NoCORS => "no-cors" + | CORS => "cors" + } +let decodeRequestMode = x => + /* internal */ + + switch x { + | "navigate" => Navigate + | "same-origin" => SameOrigin + | "no-cors" => NoCORS + | "cors" => CORS + | e => raise(Failure("Unknown requestMode: " ++ e)) + } + +type requestCredentials = + | Omit + | SameOrigin + | Include +let encodeRequestCredentials = x => + /* internal */ + + switch x { + | Omit => "omit" + | SameOrigin => "same-origin" + | Include => "include" + } +let decodeRequestCredentials = x => + /* internal */ + + switch x { + | "omit" => Omit + | "same-origin" => SameOrigin + | "include" => Include + | e => raise(Failure("Unknown requestCredentials: " ++ e)) + } + +type requestCache = + | Default + | NoStore + | Reload + | NoCache + | ForceCache + | OnlyIfCached +let encodeRequestCache = x => + /* internal */ + + switch x { + | Default => "default" + | NoStore => "no-store" + | Reload => "reload" + | NoCache => "no-cache" + | ForceCache => "force-cache" + | OnlyIfCached => "only-if-cached" + } +let decodeRequestCache = x => + /* internal */ + + switch x { + | "default" => Default + | "no-store" => NoStore + | "reload" => Reload + | "no-cache" => NoCache + | "force-cache" => ForceCache + | "only-if-cached" => OnlyIfCached + | e => raise(Failure("Unknown requestCache: " ++ e)) + } + +type requestRedirect = + | Follow + | Error + | Manual +let encodeRequestRedirect = x => + /* internal */ + + switch x { + | Follow => "follow" + | Error => "error" + | Manual => "manual" + } +let decodeRequestRedirect = x => + /* internal */ + + switch x { + | "follow" => Follow + | "error" => Error + | "manual" => Manual + | e => raise(Failure("Unknown requestRedirect: " ++ e)) + } + +module HeadersInit = { + type t = headersInit + + external make: {..} => t = "%identity" + external makeWithDict: Js.Dict.t => t = "%identity" + external makeWithArray: array<(string, string)> => t = "%identity" +} + +module Headers = { + type t = headers + + @new external make: t = "Headers" + @new external makeWithInit: headersInit => t = "Headers" + + @send external append: (t, string, string) => unit = "append" + @send + external delete: (t, string) => unit = "delete" /* entries */ /* very experimental */ + @send @return({null_to_opt: null_to_opt}) + external get: (t, string) => option = "get" + @send external has: (t, string) => bool = "has" /* keys */ /* very experimental */ + @send + external set: (t, string, string) => unit = "set" /* values */ /* very experimental */ +} + +module BodyInit = { + type t = bodyInit + + external make: string => t = "%identity" + external makeWithBlob: blob => t = "%identity" + external makeWithBufferSource: bufferSource => t = "%identity" + external makeWithFormData: formData => t = "%identity" + external makeWithUrlSearchParams: urlSearchParams => t = "%identity" +} + +module Body = { + module Impl = ( + T: { + type t + }, + ) => { + @get external body: T.t => readableStream = "body" + @get external bodyUsed: T.t => bool = "bodyUsed" + + @send + external arrayBuffer: T.t => Js.Promise.t = "arrayBuffer" + @send external blob: T.t => Js.Promise.t = "blob" + @send + external formData: T.t => Js.Promise.t = "formData" + @send external json: T.t => Js.Promise.t = "json" + @send external text: T.t => Js.Promise.t = "text" + } + + type t = body + include Impl({ + type t = t + }) +} + +module RequestInit = { + type t = requestInit + + let map = (f, x) => + /* internal */ + switch x { + | Some(v) => Some(f(v)) + | None => None + } + + @obj + external make: ( + ~method: string=?, + ~headers: headersInit=?, + ~body: bodyInit=?, + ~referrer: string=?, + ~referrerPolicy: string=?, + ~mode: string=?, + ~credentials: string=?, + ~cache: string=?, + ~redirect: string=?, + ~integrity: string=?, + ~keepalive: bool=?, + ~signal: signal=?, + ) => requestInit = "" + let make = ( + ~method_: option=?, + ~headers: option=?, + ~body: option=?, + ~referrer: option=?, + ~referrerPolicy: referrerPolicy=None, + ~mode: option=?, + ~credentials: option=?, + ~cache: option=?, + ~redirect: option=?, + ~integrity: string="", + ~keepalive: option=?, + ~signal: option=?, + (), + ) => + make( + ~method=?map(encodeRequestMethod, method_), + ~headers?, + ~body?, + ~referrer?, + ~referrerPolicy=encodeReferrerPolicy(referrerPolicy), + ~mode=?map(encodeRequestMode, mode), + ~credentials=?map(encodeRequestCredentials, credentials), + ~cache=?map(encodeRequestCache, cache), + ~redirect=?map(encodeRequestRedirect, redirect), + ~integrity, + ~keepalive?, + ~signal?, + ) +} + +module Request = { + type t = request + + include Body.Impl({ + type t = t + }) + + @new external make: string => t = "Request" + @new external makeWithInit: (string, requestInit) => t = "Request" + @new external makeWithRequest: t => t = "Request" + @new external makeWithRequestInit: (t, requestInit) => t = "Request" + + @get external method__: t => string = "method" + let method_: t => requestMethod = self => decodeRequestMethod(method__(self)) + @get external url: t => string = "url" + @get external headers: t => headers = "headers" + @get external type_: t => string = "type" + let type_: t => requestType = self => decodeRequestType(type_(self)) + @get external destination: t => string = "destination" + let destination: t => requestDestination = self => decodeRequestDestination(destination(self)) + @get external referrer: t => string = "referrer" + @get external referrerPolicy: t => string = "referrerPolicy" + let referrerPolicy: t => referrerPolicy = self => decodeReferrerPolicy(referrerPolicy(self)) + @get external mode: t => string = "mode" + let mode: t => requestMode = self => decodeRequestMode(mode(self)) + @get external credentials: t => string = "credentials" + let credentials: t => requestCredentials = self => decodeRequestCredentials(credentials(self)) + @get external cache: t => string = "cache" + let cache: t => requestCache = self => decodeRequestCache(cache(self)) + @get external redirect: t => string = "redirect" + let redirect: t => requestRedirect = self => decodeRequestRedirect(redirect(self)) + @get external integrity: t => string = "integrity" + @get external keepalive: t => bool = "keepalive" + @get external signal: t => signal = "signal" +} + +module Response = { + type t = response + + include Body.Impl({ + type t = t + }) + + @val external error: unit => t = "error" + @val external redirect: string => t = "redirect" + @val + external redirectWithStatus: (string, int /* enum-ish */) => t = "redirect" + @get external headers: t => headers = "headers" + @get external ok: t => bool = "ok" + @get external redirected: t => bool = "redirected" + @get external status: t => int = "status" + @get external statusText: t => string = "statusText" + @get external type_: t => string = "type" + @get external url: t => string = "url" + + @send external clone: t => t = "clone" +} + +module FormData = { + module EntryValue = { + type t + + let classify: t => [> #String(string) | #File(file)] = t => + if Js.typeof(t) == "string" { + #String(Obj.magic(t)) + } else { + #File(Obj.magic(t)) + } + } + + module Iterator = Fetch__Iterator + type t = formData + + @new external make: unit => t = "FormData" + @send external append: (t, string, string) => unit = "append" + @send external delete: (t, string) => unit = "delete" + @send external get: (t, string) => option = "get" + @send + external getAll: (t, string) => array = "getAll" + @send external set: (t, string, string) => unit = "set" + @send external has: (t, string) => bool = "has" + @send external keys: t => Iterator.t = "keys" + @send external values: t => Iterator.t = "values" + + @send + external appendObject: (t, string, {..}, ~filename: string=?) => unit = "append" + + @send + external appendBlob: (t, string, blob, ~filename: string=?) => unit = "append" + + @send + external appendFile: (t, string, file, ~filename: string=?) => unit = "append" + + @send + external setObject: (t, string, {..}, ~filename: string=?) => unit = "set" + + @send + external setBlob: (t, string, blob, ~filename: string=?) => unit = "set" + + @send + external setFile: (t, string, file, ~filename: string=?) => unit = "set" + + @send + external entries: t => Iterator.t<(string, EntryValue.t)> = "entries" +} + +@val external fetch: string => Js.Promise.t = "fetch" +@val +external fetchWithInit: (string, requestInit) => Js.Promise.t = "fetch" +@val +external fetchWithRequest: request => Js.Promise.t = "fetch" +@val +external fetchWithRequestInit: (request, requestInit) => Js.Promise.t = "fetch" diff --git a/src/libraries/bsfetch/Fetch__Iterator.ml b/src/libraries/bsfetch/Fetch__Iterator.ml new file mode 100644 index 000000000..b8651479a --- /dev/null +++ b/src/libraries/bsfetch/Fetch__Iterator.ml @@ -0,0 +1,20 @@ +module Next = struct + type 'a t + + external done_ : _ t -> bool option = "done" [@@bs.get] + external value : 'a t -> 'a option = "value" [@@bs.get] [@@bs.return nullable] +end + +type 'a t + +external next : 'a t -> 'a Next.t = "next" [@@bs.send] + +let rec forEach ~f t = + let item = next t in + match Next.(done_ item, value item) with + | Some true, Some value -> f value [@bs] + | Some true, None -> () + | (Some false | None), Some value -> + f value [@bs]; + forEach ~f t + | (Some false | None), None -> forEach ~f t diff --git a/src/libraries/bsfetch/Fetch__Iterator.mli b/src/libraries/bsfetch/Fetch__Iterator.mli new file mode 100644 index 000000000..6dd2df36b --- /dev/null +++ b/src/libraries/bsfetch/Fetch__Iterator.mli @@ -0,0 +1,20 @@ +(** We need to bind to JavaScript Iterators for FormData functionality. + But ideally this binding should be moved into BuckleScript itself. + + @see {{: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols}} *) + +module Next : sig + type 'a t + + external done_ : _ t -> bool option = "done" [@@bs.get] + external value : 'a t -> 'a option = "value" [@@bs.get] [@@bs.return nullable] +end + +type 'a t + +val forEach : f:('a -> unit [@bs]) -> 'a t -> unit +(** [forEach ~f iterator] runs [f] on each item returned by the + [iterator]. This is not defined by the platform but a convenience + function. *) + +external next : 'a t -> 'a Next.t = "next" [@@bs.send] diff --git a/src/screens/APIUtils/APIUtils.res b/src/screens/APIUtils/APIUtils.res index b2e5ebef4..bf5d458c2 100644 --- a/src/screens/APIUtils/APIUtils.res +++ b/src/screens/APIUtils/APIUtils.res @@ -357,13 +357,13 @@ let responseHandler = async ( ~res, ~showToast: ToastState.showToastFn, ~showErrorToast: bool, - ~showPopUp: React.callback, + ~showPopUp: PopUpState.popUpProps => unit, ~isPlayground, ~popUpCallBack, ~handleLogout, ) => { let json = try { - await res->Fetch.Response.json + await res->(res => res->Fetch.Response.json) } catch { | _ => JSON.Encode.null } @@ -476,15 +476,7 @@ let useGetMethod = (~showErrorToast=true, ()) => { ) } catch { | Exn.Error(e) => - catchHandler( - ~err={e}, - ~requestMethod={Fetch.Get}, - ~showErrorToast, - ~showToast, - ~showPopUp, - ~isPlayground, - ~popUpCallBack, - ) + catchHandler(~err={e}, ~showErrorToast, ~showToast, ~isPlayground, ~popUpCallBack) | _ => Exn.raiseError("Something went wrong") } } @@ -542,14 +534,7 @@ let useUpdateMethod = (~showErrorToast=true, ()) => { ) } catch { | Exn.Error(e) => - catchHandler( - ~err={e}, - ~requestMethod={method}, - ~showErrorToast, - ~showToast, - ~isPlayground, - ~popUpCallBack, - ) + catchHandler(~err={e}, ~showErrorToast, ~showToast, ~isPlayground, ~popUpCallBack) | _ => Exn.raiseError("Something went wrong") } } diff --git a/src/screens/Analytics/Analytics.res b/src/screens/Analytics/Analytics.res index 91ccded83..f1a759be0 100644 --- a/src/screens/Analytics/Analytics.res +++ b/src/screens/Analytics/Analytics.res @@ -90,7 +90,7 @@ module TableWrapper = { ~deltaMetrics: array, ~deltaArray: array, ~tableUpdatedHeading as _: option< - (~item: option<'t>, ~dateObj: option, 'colType) => Table.header, + (~item: option<'t>, ~dateObj: option) => 'colType => Table.header, >, ~tableGlobalFilter: option<(array>, JSON.t) => array>>, ~moduleName, @@ -108,7 +108,7 @@ module TableWrapper = { let (_, setDefaultFilter) = Recoil.useRecoilState(AnalyticsHooks.defaultFilter) let (showTable, setShowTable) = React.useState(_ => false) let {getHeading, allColumns, defaultColumns} = tableEntity - let activeTabStr = activeTab->Option.getOr([])->Array.joinWith("-") + let activeTabStr = activeTab->Option.getOr([])->Array.joinWithUnsafe("-") let (startTimeFilterKey, endTimeFilterKey) = dateKeys let (tableDataLoading, setTableDataLoading) = React.useState(_ => true) let (tableData, setTableData) = React.useState(_ => []->Array.map(Nullable.make)) @@ -149,7 +149,7 @@ module TableWrapper = { None } }) - ->Array.joinWith("&") + ->Array.joinWithUnsafe("&") filterSearchParam }, [getTopLevelFilter]) @@ -325,7 +325,7 @@ module TableWrapper = { }, [activeTabStr]) let transactionTableDefaultCols = React.useMemo2(() => { - Recoil.atom(. `${moduleName}DefaultCols${activeTabStr}`, newDefaultCols) + Recoil.atom(`${moduleName}DefaultCols${activeTabStr}`, newDefaultCols) }, (newDefaultCols, `${moduleName}DefaultCols${activeTabStr}`)) let timeRange = @@ -351,7 +351,7 @@ module TableWrapper = { ("filter", defaultFilters->JSON.Encode.object), ]->Dict.fromArray - setDefaultFilter(._ => dict->JSON.Encode.object->JSON.stringify) + setDefaultFilter(_ => dict->JSON.Encode.object->JSON.stringify) let modifyData = data => { switch formatData { @@ -403,7 +403,7 @@ module TabDetails = { ~deltaMetrics: array, ~deltaArray: array, ~tableUpdatedHeading: option< - (~item: option<'t>, ~dateObj: option, 'colType) => Table.header, + (~item: option<'t>, ~dateObj: option) => 'colType => Table.header, >, ~tableGlobalFilter: option<(array>, JSON.t) => array>>, ~moduleName, @@ -510,7 +510,7 @@ let make = ( ~singleStatEntity: DynamicSingleStat.entityType<'singleStatColType, 'b, 'b2>, ~filterUri: option, ~tableUpdatedHeading: option< - (~item: option<'t>, ~dateObj: option, 'colType) => Table.header, + (~item: option<'t>, ~dateObj: option) => 'colType => Table.header, >=?, ~tableGlobalFilter: option<(array>, JSON.t) => array>>=?, ~moduleName: string, @@ -605,7 +605,7 @@ let make = ( source: "BATCH", } AnalyticsUtils.filterBody(filterBodyEntity) - }, (startTimeVal, endTimeVal, filteredTabKeys->Array.joinWith(","))) + }, (startTimeVal, endTimeVal, filteredTabKeys->Array.joinWithUnsafe(","))) open APIUtils open Promise diff --git a/src/screens/Analytics/GlobalSearch/GlobalSearchBar.res b/src/screens/Analytics/GlobalSearch/GlobalSearchBar.res index 1e1d04b40..ca0dabcaa 100644 --- a/src/screens/Analytics/GlobalSearch/GlobalSearchBar.res +++ b/src/screens/Analytics/GlobalSearch/GlobalSearchBar.res @@ -229,7 +229,7 @@ let make = () => { let remote_results = response->parseResponse - setGLobalSearchResults(._ => { + setGLobalSearchResults(_ => { local_results, remote_results, searchText, diff --git a/src/screens/Analytics/Logs/PaymentLogs/PaymentLogs.res b/src/screens/Analytics/Logs/PaymentLogs/PaymentLogs.res index 399af7b2c..a4383c065 100644 --- a/src/screens/Analytics/Logs/PaymentLogs/PaymentLogs.res +++ b/src/screens/Analytics/Logs/PaymentLogs/PaymentLogs.res @@ -9,16 +9,15 @@ let make = (~paymentId, ~createdAt) => { let startTime = startTime->Js.Date.fromFloat->Date.toISOString let endTime = createdAt->Date.fromString->Date.getTime +. 1000. *. 60. *. 60. *. 3. let endTime = endTime->Js.Date.fromFloat->Date.toISOString - let sdkPostBody = - [ - ("paymentId", paymentId->JSON.Encode.string), - ( - "timeRange", - [("startTime", startTime->JSON.Encode.string), ("endTime", endTime->JSON.Encode.string)] - ->Dict.fromArray - ->JSON.Encode.object, - ), - ]->LogicUtils.getJsonFromArrayOfJson + let sdkPostBody = [ + ("paymentId", paymentId->JSON.Encode.string), + ( + "timeRange", + [("startTime", startTime->JSON.Encode.string), ("endTime", endTime->JSON.Encode.string)] + ->Dict.fromArray + ->JSON.Encode.object, + ), + ]->LogicUtils.getJsonFromArrayOfJson let webhookLogsUrl = getURL( ~entityName=WEBHOOKS_EVENT_LOGS, ~methodType=Get, diff --git a/src/screens/Analytics/SystemMetrics/SystemMetricsAnalytics.res b/src/screens/Analytics/SystemMetrics/SystemMetricsAnalytics.res index f572514b6..670d9fc0e 100644 --- a/src/screens/Analytics/SystemMetrics/SystemMetricsAnalytics.res +++ b/src/screens/Analytics/SystemMetrics/SystemMetricsAnalytics.res @@ -261,7 +261,7 @@ module SystemMetricsAnalytics = { source: "BATCH", } AnalyticsUtils.filterBody(filterBodyEntity) - }, (startTimeVal, endTimeVal, filteredTabKeys->Array.joinWith(","))) + }, (startTimeVal, endTimeVal, filteredTabKeys->Array.joinWithUnsafe(","))) open APIUtils open Promise diff --git a/src/screens/ConfigurePMTs/PaymentMethodConfig.res b/src/screens/ConfigurePMTs/PaymentMethodConfig.res index 224280039..c6b6e3bf2 100644 --- a/src/screens/ConfigurePMTs/PaymentMethodConfig.res +++ b/src/screens/ConfigurePMTs/PaymentMethodConfig.res @@ -43,8 +43,7 @@ module PmtConfigInp = { } } -let renderValueInp = ( - options: array, +let renderValueInp = (options: array) => ( fieldsArray: array, ) => { diff --git a/src/screens/Connectors/ConnectPayPalFlow/ConnectPayPal.res b/src/screens/Connectors/ConnectPayPalFlow/ConnectPayPal.res index e5ccfd695..8202e5dea 100644 --- a/src/screens/Connectors/ConnectPayPalFlow/ConnectPayPal.res +++ b/src/screens/Connectors/ConnectPayPalFlow/ConnectPayPal.res @@ -157,7 +157,7 @@ module RedirectionToPayPalFlow = { open HSwitchGlobalVars let getURL = useGetURL() let url = RescriptReactRouter.useUrl() - let path = url.path->List.toArray->Array.joinWith("/") + let path = url.path->List.toArray->Array.joinWithUnsafe("/") let connectorId = HSwitchUtils.getConnectorIDFromUrl(url.path->List.toArray, "") let updateDetails = useUpdateMethod(~showErrorToast=false, ()) let (screenState, setScreenState) = React.useState(_ => PageLoaderWrapper.Loading) @@ -344,7 +344,7 @@ let make = ( let _ = await updateConnectorDetails(values) switch configuartionType { - | Automatic => setSetupAccountStatus(._ => Redirecting_to_paypal) + | Automatic => setSetupAccountStatus(_ => Redirecting_to_paypal) | Manual | _ => setCurrentStep(_ => ConnectorTypes.IntegFields) } setScreenState(_ => Success) @@ -364,7 +364,7 @@ let make = ( switch configuartionType { | Automatic => { await updateConnectorDetails(values) - setSetupAccountStatus(._ => Redirecting_to_paypal) + setSetupAccountStatus(_ => Redirecting_to_paypal) } | Manual | _ => { @@ -412,7 +412,7 @@ let make = ( ) setCurrentStep(_ => ConnectorTypes.AutomaticFlow) - setSetupAccountStatus(._ => Connect_paypal_landing) + setSetupAccountStatus(_ => Connect_paypal_landing) setScreenState(_ => Success) } else { showToast( @@ -440,7 +440,7 @@ let make = (