diff --git a/package.json b/package.json index c22650845..b2d3d4723 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "@juspay-tech/hyper-js": "^1.0.0", "@juspay-tech/react-hyper-js": "^1.0.1", "@monaco-editor/react": "^4.4.5", - "@rescript/core": "^0.5.0", + "@rescript/core": "^0.6.0", "@rescript/react": "^0.11.0", "@ryyppy/rescript-promise": "^2.1.0", "bs-fetch": "^0.6.2", diff --git a/src/components/AdvancedSearchComponent.res b/src/components/AdvancedSearchComponent.res index ffdad215d..a37dc4ef4 100644 --- a/src/components/AdvancedSearchComponent.res +++ b/src/components/AdvancedSearchComponent.res @@ -20,7 +20,7 @@ let make = ( ) => { let {getObjects, searchUrl: url} = entity let fetchApi = AuthHooks.useApiFetcher() - let initialValueJson = Js.Json.object_(Js.Dict.empty()) + let initialValueJson = Js.Json.object_(Dict.make()) let showToast = ToastState.useShowToast() let (showModal, setShowModal) = React.useState(_ => false) diff --git a/src/components/Button.res b/src/components/Button.res index 5123f11c8..e0c5f1d1e 100644 --- a/src/components/Button.res +++ b/src/components/Button.res @@ -385,9 +385,7 @@ let make = ( } let buttonSize: buttonSize = - buttonSize->Option.getWithDefault( - MatchMedia.useMatchMedia("(max-width: 800px)") ? Small : Medium, - ) + buttonSize->Option.getOr(MatchMedia.useMatchMedia("(max-width: 800px)") ? Small : Medium) let lengthStyle = if fullLength { "w-full justify-between" @@ -422,7 +420,7 @@ let make = ( } } - let heightClass = customHeightClass->Option.getWithDefault({ + let heightClass = customHeightClass->Option.getOr({ switch buttonSize { | XSmall => "h-fit" | Small => "h-fit" @@ -436,7 +434,7 @@ let make = ( | _ => "cursor-pointer" } - let paddingClass = customPaddingClass->Option.getWithDefault( + let paddingClass = customPaddingClass->Option.getOr( switch buttonSize { | XSmall => "py-3 px-4" | Small => @@ -450,7 +448,7 @@ let make = ( }, ) - let textPaddingClass = customTextPaddingClass->Option.getWithDefault( + let textPaddingClass = customTextPaddingClass->Option.getOr( switch buttonSize { | XSmall => "px-1" | Small => "px-1" @@ -459,7 +457,7 @@ let make = ( }, ) - let textSize = customTextSize->Option.getWithDefault( + let textSize = customTextSize->Option.getOr( switch buttonSize { | XSmall => "text-fs-11" | Small => "text-fs-13" @@ -471,7 +469,7 @@ let make = ( let ellipsisClass = ellipsisOnly ? "truncate" : "" let ellipsisParentClass = ellipsisOnly ? "max-w-[250px] md:max-w-xs" : "" - let iconSize = customIconSize->Option.getWithDefault( + let iconSize = customIconSize->Option.getOr( switch buttonSize { | XSmall => 12 | Small => 14 @@ -496,7 +494,7 @@ let make = ( | Large => "" } - let iconMargin = customIconMargin->Option.getWithDefault( + let iconMargin = customIconMargin->Option.getOr( switch buttonSize { | XSmall | Small => "ml-1" @@ -673,7 +671,7 @@ let make = ( | _ => "text-sm font-medium leading-5" } - let textId = text->Option.getWithDefault("") + let textId = text->Option.getOr("") let iconId = switch leftIcon { | FontAwesome(iconName) | Euler(iconName) => iconName @@ -695,9 +693,9 @@ let make = ( let relativeClass = isRelative ? "relative" : "" let conditionalButtonStyles = `${allowButtonTextMinWidth ? "min-w-min" - : ""} ${customBackColor->Option.getWithDefault( - backColor, - )} ${customRoundedClass->Option.getWithDefault(roundedClass)}` + : ""} ${customBackColor->Option.getOr(backColor)} ${customRoundedClass->Option.getOr( + roundedClass, + )}` let customJustifyStyle = customButtonStyle->String.includes("justify") ? "" : "justify-center" @@ -752,7 +750,7 @@ let make = ( if showBtnTextToolTip {
Option.getWithDefault("")} + description={tooltipText->Option.getOr("")} toolTipFor=btnContent contentAlign=Default justifyClass="justify-start" diff --git a/src/components/Calendar.res b/src/components/Calendar.res index 0200ee39d..b19e60905 100644 --- a/src/components/Calendar.res +++ b/src/components/Calendar.res @@ -21,7 +21,7 @@ module TableRow = { switch obj { | Some(a) => { let day = String.split(a, "-") - React.string(day[2]->Option.getWithDefault("")) + React.string(day[2]->Option.getOr("")) } | None => React.string("") @@ -53,7 +53,7 @@ module TableRow = { let highlight = cellHighlighter { - if item == Belt.Array.make(7, "") { + if item == Array.make(~length=7, "") { } else { @@ -149,11 +149,11 @@ module TableRow = { } let getDate = date => { let datevalue = Js.Date.makeWithYMD( - ~year=Js.Float.fromString(date[0]->Option.getWithDefault("")), + ~year=Js.Float.fromString(date[0]->Option.getOr("")), ~month=Js.Float.fromString( - String.make(Js.Float.fromString(date[1]->Option.getWithDefault("")) -. 1.0), + String.make(Js.Float.fromString(date[1]->Option.getOr("")) -. 1.0), ), - ~date=Js.Float.fromString(date[2]->Option.getWithDefault("")), + ~date=Js.Float.fromString(date[2]->Option.getOr("")), (), ) datevalue @@ -351,7 +351,7 @@ let make = ( } // creating row info - let dummyRow = Belt.Array.make(6, Belt.Array.make(7, "")) + let dummyRow = Array.make(~length=6, Array.make(~length=7, "")) let rowMapper = (row, indexRow) => { Array.mapWithIndex(row, (_item, index) => { diff --git a/src/components/CalendarList.res b/src/components/CalendarList.res index 4ab53c226..4a372feee 100644 --- a/src/components/CalendarList.res +++ b/src/components/CalendarList.res @@ -30,7 +30,7 @@ let make = ( // check whether month and date has value let getMonthFromFloat = value => { let valueInt = value->Belt.Float.toInt - months[valueInt]->Option.getWithDefault(Jan) + months[valueInt]->Option.getOr(Jan) } let getMonthInFloat = mon => { Array.indexOf(months, mon)->Belt.Float.fromInt @@ -76,7 +76,7 @@ let make = ( setCurrDate(_ => newDate) } - let dummyRow = Belt.Array.make(count, 1) + let dummyRow = Array.make(~length=count, 1)
{dummyRow @@ -96,7 +96,7 @@ let make = ( let tempYear = Js.Date.getFullYear(Js.Date.fromFloat(tempDate)) let showLeft = i == 0 && !secondCalendar - let showRight = i + 1 == Belt.Array.length(dummyRow) && !firstCalendar + let showRight = i + 1 == Array.length(dummyRow) && !firstCalendar let monthAndYear = String.concat( getMonthInStr(getMonthFromFloat(tempMonth)), Belt.Float.toString(tempYear), diff --git a/src/components/CollapsableTableRow.res b/src/components/CollapsableTableRow.res index c5e499392..463220f2a 100644 --- a/src/components/CollapsableTableRow.res +++ b/src/components/CollapsableTableRow.res @@ -81,7 +81,7 @@ let make = (
{item ->Array.mapWithIndex((obj, index) => { - let heading = headingArray->Belt.Array.get(index)->Option.getWithDefault("") + let heading = headingArray->Array.get(index)->Option.getOr("") string_of_int}>
diff --git a/src/components/CustomCharts/FunnelChart.res b/src/components/CustomCharts/FunnelChart.res index f075eb3e9..5f75d27aa 100644 --- a/src/components/CustomCharts/FunnelChart.res +++ b/src/components/CustomCharts/FunnelChart.res @@ -12,13 +12,12 @@ let make = ( let (size, widthClass, flexDirectionClass) = React.useMemo1(() => { isMobileView ? (0.16, "w-full", "flex-col") : (size, "w-1/2", "flex-row") }, [isMobileView]) - let funnelData = - data->Belt.Array.get(0)->Option.getWithDefault(Js.Json.null)->LogicUtils.getDictFromJsonObject + let funnelData = data->Array.get(0)->Option.getOr(Js.Json.null)->LogicUtils.getDictFromJsonObject let (hoverIndex, setHoverIndex) = React.useState(_ => -1.) let (selectedMetric, setSelectedMetric) = React.useState(_ => Volume) let length = metrics->Array.length->Belt.Float.fromInt let widths = metrics->Array.mapWithIndex((metric, i) => { - let previousMetric = metrics->Belt.Array.get(i - 1) + let previousMetric = metrics->Array.get(i - 1) let previousMetric = switch previousMetric { | Some(prevMetric) => prevMetric.metric_name_db | None => "" @@ -81,15 +80,14 @@ let make = ( let borderTop = `${(size *. 14.) ->Belt.Float.toString}rem solid rgb(0,109,249,${opacity->Belt.Float.toString})` - let currentWidthRatio = switch widths->Belt.Array.get(i->Belt.Float.toInt) { + let currentWidthRatio = switch widths->Array.get(i->Belt.Float.toInt) { | Some(width) => width | None => size *. 70. } - let nextWidthRatio = switch widths->Belt.Array.get(i->Belt.Float.toInt + 1) { + let nextWidthRatio = switch widths->Array.get(i->Belt.Float.toInt + 1) { | Some(width) => width - | None => - widths->Belt.Array.get(i->Belt.Float.toInt)->Option.getWithDefault(size *. 70.) + | None => widths->Array.get(i->Belt.Float.toInt)->Option.getOr(size *. 70.) } fixedWidth := currentWidthRatio *. fixedWidth.contents diff --git a/src/components/CustomCharts/HighchartHorizontalBarChart.res b/src/components/CustomCharts/HighchartHorizontalBarChart.res index fe65d4175..35e488105 100644 --- a/src/components/CustomCharts/HighchartHorizontalBarChart.res +++ b/src/components/CustomCharts/HighchartHorizontalBarChart.res @@ -39,12 +39,12 @@ let xLabelFormatter: Js_OO.Callback.arity1 string> = { }) ->Array.reduce(0, (acc, num) => {acc + num}) let index = Array.findIndex(axis.categories, x => {x === value}) - let firstSeries = series->Belt.Array.get(0) + let firstSeries = series->Array.get(0) let y = switch firstSeries { | Some(series) => { let options = series.options switch options { - | Some(options) => options.data->Belt.Array.get(index)->Option.getWithDefault(0) + | Some(options) => options.data->Array.get(index)->Option.getOr(0) | None => 0 } } @@ -74,7 +74,7 @@ let make = ( selectedMetrics.metric_name_db, ) }, (rawData, groupKey, selectedMetrics.metric_name_db)) - let titleKey = titleKey->Option.getWithDefault(groupKey) + let titleKey = titleKey->Option.getOr(groupKey) let barOption: Js.Json.t = React.useMemo2(() => { let colors = { diff --git a/src/components/CustomCharts/HighchartPieChart.res b/src/components/CustomCharts/HighchartPieChart.res index 214f6b092..1759f49dc 100644 --- a/src/components/CustomCharts/HighchartPieChart.res +++ b/src/components/CustomCharts/HighchartPieChart.res @@ -43,7 +43,7 @@ let make = ( let color = theme === Dark ? "white" : "black" let borderColor = theme === Dark ? "black" : "white" let opacity = theme === Dark ? "0.5" : "1" - let titleKey = titleKey->Option.getWithDefault(groupKey) + let titleKey = titleKey->Option.getOr(groupKey) let barOption: Js.Json.t = React.useMemo2(() => { let colors = { diff --git a/src/components/CustomCharts/HighchartTimeSeriesChart.res b/src/components/CustomCharts/HighchartTimeSeriesChart.res index c4965629e..554e72b99 100644 --- a/src/components/CustomCharts/HighchartTimeSeriesChart.res +++ b/src/components/CustomCharts/HighchartTimeSeriesChart.res @@ -169,12 +169,12 @@ module LineChart1D = { let (x, y, secondryMetrics) = axes xAxisMapInfo->LineChartUtils.appendToDictValue( ["run_date", "run_month", "run_week"]->Array.includes(groupKey) - ? x->Js.Json.decodeString->Option.getWithDefault("") + ? x->Js.Json.decodeString->Option.getOr("") : x->Js.Json.stringify, ( item.name, { - item.color->Option.getWithDefault("#000000") + item.color->Option.getOr("#000000") }, y, secondryMetrics, @@ -298,8 +298,8 @@ module LineChart1D = { | None => None } }) - ->Belt.Array.get(0) - ->Option.getWithDefault("") + ->Array.get(0) + ->Option.getOr("") let color = chartData ->Belt.Array.keepMap(item => { @@ -308,8 +308,8 @@ module LineChart1D = { | None => None } }) - ->Belt.Array.get(0) - ->Option.getWithDefault(`${colorOrig}`) + ->Array.get(0) + ->Option.getOr(`${colorOrig}`) let transformValue = num => { num->HSAnalyticsUtils.setPrecision() @@ -611,12 +611,12 @@ module LineChart1D = { let upper_bound = upper_bound <= threshold - ? threshold +. stepUpFromThreshold->Option.getWithDefault(0.) + ? threshold +. stepUpFromThreshold->Option.getOr(0.) : upper_bound let lower_bound = lower_bound >= threshold - ? threshold -. stepUpFromThreshold->Option.getWithDefault(0.) + ? threshold -. stepUpFromThreshold->Option.getOr(0.) : lower_bound let positions = NumericUtils.pretty([lower_bound, upper_bound], 5) @@ -660,8 +660,7 @@ module LineChart1D = { "labels": { let labelsValue = { "formatter": Some( - @this - param => formatLabels(selectedMetrics, param.value->Option.getWithDefault(0.0)), + @this param => formatLabels(selectedMetrics, param.value->Option.getOr(0.0)), ), "enabled": true, "style": { @@ -836,7 +835,7 @@ module RenderMultiDimensionalChart = { ), legendIndex: i.legendIndex, name: i.name, - color: i.color->Option.getWithDefault("#000000"), + color: i.color->Option.getOr("#000000"), }) ) ->ignore @@ -893,10 +892,7 @@ module LineChart2D = { ~chartType: string="area", ) => { let (groupBy1, groupBy2) = switch groupBy { - | Some(value) => ( - value->Belt.Array.get(0)->Option.getWithDefault(""), - value->Belt.Array.get(1)->Option.getWithDefault(""), - ) + | Some(value) => (value->Array.get(0)->Option.getOr(""), value->Array.get(1)->Option.getOr("")) | None => ("", "") } let (groupBy1, groupBy2) = (groupBy2, groupBy1) @@ -939,9 +935,9 @@ module LineChart3D = { ) => { let (groupBy1, groupBy2, groupby3) = switch groupBy { | Some(value) => ( - value->Belt.Array.get(0)->Option.getWithDefault(""), - value->Belt.Array.get(1)->Option.getWithDefault(""), - value->Belt.Array.get(2)->Option.getWithDefault(""), + value->Array.get(0)->Option.getOr(""), + value->Array.get(1)->Option.getOr(""), + value->Array.get(2)->Option.getOr(""), ) | None => ("", "", "") } diff --git a/src/components/CustomCharts/LineChartUtils.res b/src/components/CustomCharts/LineChartUtils.res index 9d6d5d89d..f76e33e51 100644 --- a/src/components/CustomCharts/LineChartUtils.res +++ b/src/components/CustomCharts/LineChartUtils.res @@ -111,8 +111,8 @@ let reduceOpacity = str => { switch match { | Some(val) => { - let opacity = val->Belt.Array.get(1)->Option.flatMap(a => a)->Option.getWithDefault("0") - let newOpacity = opacity->Belt.Float.fromString->Option.getWithDefault(0.0) /. 10.0 + let opacity = val->Array.get(1)->Option.flatMap(a => a)->Option.getOr("0") + let newOpacity = opacity->Belt.Float.fromString->Option.getOr(0.0) /. 10.0 str->String.replace(opacity, newOpacity->Belt.Float.toString) } | None => "0" @@ -282,7 +282,7 @@ let timeSeriesDataMaker = ( let groupByName = dict->getString( groupKey, - Dict.get(dict, groupKey)->Option.getWithDefault(""->Js.Json.string)->Js.Json.stringify, + Dict.get(dict, groupKey)->Option.getOr(""->Js.Json.string)->Js.Json.stringify, ) let xAxisDataPoint = dict->getString(xAxis, "")->String.split(" ")->Array.joinWith("T") ++ "Z" // right now it is time string let yAxisDataPoint = dict->getFloat(yAxis, 0.) @@ -318,9 +318,7 @@ let timeSeriesDataMaker = ( ->Array.map(item => { let (key, value, secondryMetrix) = item let trafficValue = - value *. - 100. /. - groupedByTime->Dict.get(key->Belt.Float.toString)->Option.getWithDefault(1.) + value *. 100. /. groupedByTime->Dict.get(key->Belt.Float.toString)->Option.getOr(1.) (key, trafficValue, secondryMetrix) }) ->Js.Array2.sortInPlaceWith(chartDataSortBasedOnTime) @@ -328,18 +326,17 @@ let timeSeriesDataMaker = ( } let color = switch colors->Array.find(item => item.name == key) { | Some(val) => val.color - | None => - legendColor[mod(index, legendColor->Array.length)]->Option.getWithDefault(defaultColor) + | None => legendColor[mod(index, legendColor->Array.length)]->Option.getOr(defaultColor) } let fillColor = switch legendColorGradients(topGradient, bottomGradient)->Array.find(item => - item.color->Option.getWithDefault("#000000") == color + item.color->Option.getOr("#000000") == color ) { | Some(val) => val | None => legendColorGradients(topGradient, bottomGradient)[ mod(index, legendColor->Array.length) - ]->Option.getWithDefault(defaultLegendColorGradients(topGradient, bottomGradient)) + ]->Option.getOr(defaultLegendColorGradients(topGradient, bottomGradient)) } let value: timeSeriesDictWithSecondryMetrics = { color: Some(color), @@ -366,17 +363,17 @@ let getLegendDataForCurrentMetrix = ( getString( dict, activeTab, - Dict.get(dict, activeTab)->Option.getWithDefault(""->Js.Json.string)->Js.Json.stringify, + Dict.get(dict, activeTab)->Option.getOr(""->Js.Json.string)->Js.Json.stringify, ) }) - timeSeriesData->Belt.Array.forEach(item => { + timeSeriesData->Array.forEach(item => { let dict = item->getDictFromJsonObject let time_overall_statsAtTime = (getString(dict, xAxis, ""), getFloat(dict, yAxis, 0.)) // time_bucket // current value of the metrics will be used for calculation of avg and the current currentAvgDict->appendToDictValue( getString( dict, activeTab, - Dict.get(dict, activeTab)->Option.getWithDefault(""->Js.Json.string)->Js.Json.stringify, + Dict.get(dict, activeTab)->Option.getOr(""->Js.Json.string)->Js.Json.stringify, ), time_overall_statsAtTime, ) @@ -393,8 +390,7 @@ let getLegendDataForCurrentMetrix = ( currentAvgSortedDict ->Array.map(item => { let (_, value) = item - let (_, currentVal) = - value->Belt.Array.get(value->Array.length - 1)->Option.getWithDefault(("", 0.)) + let (_, currentVal) = value->Array.get(value->Array.length - 1)->Option.getOr(("", 0.)) currentVal }) ->AnalyticsUtils.sumOfArrFloat @@ -405,8 +401,7 @@ let getLegendDataForCurrentMetrix = ( let (key, value) = item let sortedValueBasedOnTime = value->Js.Array2.sortInPlaceWith(sortBasedOnTimeLegend) let arrLen = sortedValueBasedOnTime->Array.length - let (_, currentVal) = - sortedValueBasedOnTime->Belt.Array.get(arrLen - 1)->Option.getWithDefault(("", 1.0)) + let (_, currentVal) = sortedValueBasedOnTime->Array.get(arrLen - 1)->Option.getOr(("", 1.0)) let overall = sortedValueBasedOnTime @@ -414,7 +409,7 @@ let getLegendDataForCurrentMetrix = ( let (_, value) = item value }) - ->Belt.Array.reduce(0., (acc, value) => acc +. value) + ->Array.reduce(0., (acc, value) => acc +. value) let value: legendTableData = { groupByName: key, @@ -426,7 +421,7 @@ let getLegendDataForCurrentMetrix = ( }) } else { let currentOverall = Dict.make() - groupedData->Belt.Array.forEach(item => { + groupedData->Array.forEach(item => { let dict = item->getDictFromJsonObject currentOverall->Dict.set(getString(dict, activeTab, ""), getFloat(dict, yAxis, 0.)) }) @@ -444,18 +439,18 @@ let getLegendDataForCurrentMetrix = ( let (metricsName, value) = item let sortedValueBasedOnTime = value->Js.Array2.sortInPlaceWith(sortBasedOnTimeLegend) let arrLen = sortedValueBasedOnTime->Array.length - let (_, currentVal) = sortedValueBasedOnTime[arrLen - 1]->Option.getWithDefault(("", 0.)) + let (_, currentVal) = sortedValueBasedOnTime[arrLen - 1]->Option.getOr(("", 0.)) // the avg stat won't work correct for Sr case have to find another way or avoid using the avg for Sr let overall = if metrixType === Traffic { - (currentOverall->Dict.get(metricsName)->Option.getWithDefault(0.) *. + (currentOverall->Dict.get(metricsName)->Option.getOr(0.) *. 100. /. Js.Math.max_float(totalOverall, 1.)) ->Js.Float.toFixedWithPrecision(~digits=2) ->removeTrailingZero ->Belt.Float.fromString - ->Option.getWithDefault(0.) + ->Option.getOr(0.) } else { - currentOverall->Dict.get(metricsName)->Option.getWithDefault(0.) + currentOverall->Dict.get(metricsName)->Option.getOr(0.) } let currentVal = if metrixType === Traffic { currentVal *. 100. /. currentValueOverallSum @@ -488,7 +483,7 @@ let barChartDataMaker = (~yAxis: string, ~rawData: array, ~activeTab: let selectedSegmentVal = getString( dict, activeTab, - Dict.get(dict, activeTab)->Option.getWithDefault(""->Js.Json.string)->Js.Json.stringify, + Dict.get(dict, activeTab)->Option.getOr(""->Js.Json.string)->Js.Json.stringify, ) // groupby/ selected segment let stats = getFloat(dict, yAxis, 0.) // overall metrics @@ -532,7 +527,7 @@ let legendClickItem = (s: Highcharts.legendItem, e, setState) => { // whatever is there in selected array make it visible // edge case when nothing is selected make everyone visible - Belt.Array.forEach(s.chart.series, x => { + Array.forEach(s.chart.series, x => { if x === legendItemAsBool(s) { setState(prev => { let value = @@ -541,14 +536,14 @@ let legendClickItem = (s: Highcharts.legendItem, e, setState) => { : Belt.Array.concat(prev, [x]) if value->Array.length === 0 { - Belt.Array.forEach( + Array.forEach( s.chart.series, y => { y->Highcharts.show }, ) } else { - Belt.Array.forEach( + Array.forEach( s.chart.series, y => { value->Array.includes(y) ? y->Highcharts.show : y->Highcharts.hide @@ -588,10 +583,7 @@ let getTooltipHTML = (metrics, data, onCursorName) => { let (name, color, y_axis, secondry_metrix) = data let secondry_metrix_val = switch metrics.secondryMetrics { | Some(secondryMetrics) => - `${formatStatsAccToMetrix( - secondryMetrics.metric_type, - secondry_metrix->Option.getWithDefault(0.), - )}` + `${formatStatsAccToMetrix(secondryMetrics.metric_type, secondry_metrix->Option.getOr(0.))}` | None => "" } @@ -616,10 +608,10 @@ let tooltipFormatter = ( let dataArr = if ["run_date", "run_month", "run_week"]->Array.includes(groupKey) { let x = points->getString("name", "") - xAxisMapInfo->Dict.get(x)->Option.getWithDefault([]) + xAxisMapInfo->Dict.get(x)->Option.getOr([]) } else { let x = points->getFloat("x", 0.) - xAxisMapInfo->Dict.get(x->Js.Float.toString)->Option.getWithDefault([]) + xAxisMapInfo->Dict.get(x->Js.Float.toString)->Option.getOr([]) } let onCursorName = series->getString("name", "") @@ -747,7 +739,7 @@ let getGranularityNew = (~startTime, ~endTime) => { } let getGranularityNewStr = (~startTime, ~endTime) => { - getGranularityNew(~startTime, ~endTime)->Belt.Array.map(item => { + getGranularityNew(~startTime, ~endTime)->Array.map(item => { let (val, unit) = item if val === 1 { if unit === "day" { diff --git a/src/components/CustomExpandableTable.res b/src/components/CustomExpandableTable.res index 67e1b39fa..7708bb563 100644 --- a/src/components/CustomExpandableTable.res +++ b/src/components/CustomExpandableTable.res @@ -153,7 +153,7 @@ let make = ( | None => ([], []) }->Some ) - ->Option.getWithDefault(([], [])) + ->Option.getOr(([], [])) if options->Array.length > 1 { let filterInput: ReactFinalForm.fieldRenderPropsInput = { diff --git a/src/components/DatePicker.res b/src/components/DatePicker.res index 2e909cc0a..88c50fe6b 100644 --- a/src/components/DatePicker.res +++ b/src/components/DatePicker.res @@ -32,9 +32,9 @@ let make = ( let (date, setDate) = React.useState(_ => { if selectedDate !== "" { let date = String.split(selectedDate, "-") - let dateDay = date->Belt.Array.get(2)->Option.getWithDefault("1") - let dateMonth = date->Belt.Array.get(1)->Option.getWithDefault("1") - let dateYear = date->Belt.Array.get(0)->Option.getWithDefault("1970") + let dateDay = date->Array.get(2)->Option.getOr("1") + let dateMonth = date->Array.get(1)->Option.getOr("1") + let dateYear = date->Array.get(0)->Option.getOr("1970") let timeSplit = switch input.value->Js.Json.decodeString { @@ -44,9 +44,9 @@ let make = ( ->DateRangePicker.getTimeStringForValue(isoStringToCustomTimeZone) ->String.split(":") - let timeHour = timeSplit->Belt.Array.get(0)->Option.getWithDefault(currentDateHourFormat) - let timeMinute = timeSplit->Belt.Array.get(1)->Option.getWithDefault(currentDateMinuteFormat) - let timeSecond = timeSplit->Belt.Array.get(2)->Option.getWithDefault(currentDateSecondsFormat) + let timeHour = timeSplit->Array.get(0)->Option.getOr(currentDateHourFormat) + let timeMinute = timeSplit->Array.get(1)->Option.getOr(currentDateMinuteFormat) + let timeSecond = timeSplit->Array.get(2)->Option.getOr(currentDateSecondsFormat) let dateTimeCheck = customTimezoneToISOString( dateYear, dateMonth, @@ -74,9 +74,9 @@ let make = ( setSelectedDate(_ => str) let currentDateSplit = String.split(str, "-") - let currentDateDay = currentDateSplit->Belt.Array.get(2)->Option.getWithDefault("1") - let currentDateYear = currentDateSplit->Belt.Array.get(0)->Option.getWithDefault("1970") - let currentDateMonth = currentDateSplit->Belt.Array.get(1)->Option.getWithDefault("1") + let currentDateDay = currentDateSplit->Array.get(2)->Option.getOr("1") + let currentDateYear = currentDateSplit->Array.get(0)->Option.getOr("1970") + let currentDateMonth = currentDateSplit->Array.get(1)->Option.getOr("1") let currentDateTimeCheck = customTimezoneToISOString( currentDateYear, @@ -130,10 +130,10 @@ let make = ( ? `${currentDateHourFormat}:${currentDateMinuteFormat}${showSeconds ? ":" ++ currentDateSecondsFormat : ""}` - : splitTime->Belt.Array.get(0)->Option.getWithDefault("NA") ++ + : splitTime->Array.get(0)->Option.getOr("NA") ++ ":" ++ - splitTime->Belt.Array.get(1)->Option.getWithDefault("NA") ++ ( - showSeconds ? ":" ++ splitTime->Belt.Array.get(2)->Option.getWithDefault("NA") : "" + splitTime->Array.get(1)->Option.getOr("NA") ++ ( + showSeconds ? ":" ++ splitTime->Array.get(2)->Option.getOr("NA") : "" )}` } startDateStr @@ -154,7 +154,7 @@ let make = ( | Some(icon) => icon | None => FontAwesome("calendar") } - let fullLengthWidthClass = fullLength->Option.getWithDefault(false) ? "2xl:w-full" : "" + let fullLengthWidthClass = fullLength->Option.getOr(false) ? "2xl:w-full" : "" let startTimeInput: ReactFinalForm.fieldRenderPropsInput = { name: "string", @@ -171,15 +171,13 @@ let make = ( timeVal } let date = String.split(selectedDate, "-") - let dateDay = date->Belt.Array.get(2)->Option.getWithDefault("1") - let dateMonth = date->Belt.Array.get(1)->Option.getWithDefault("1") - let dateYear = date->Belt.Array.get(0)->Option.getWithDefault("1970") + let dateDay = date->Array.get(2)->Option.getOr("1") + let dateMonth = date->Array.get(1)->Option.getOr("1") + let dateYear = date->Array.get(0)->Option.getOr("1970") let timeSplit = String.split(timeVal, ":") - let timeHour = timeSplit->Belt.Array.get(0)->Option.getWithDefault(currentDateHourFormat) - let timeMinute = - timeSplit->Belt.Array.get(1)->Option.getWithDefault(currentDateMinuteFormat) - let timeSecond = - timeSplit->Belt.Array.get(2)->Option.getWithDefault(currentDateSecondsFormat) + let timeHour = timeSplit->Array.get(0)->Option.getOr(currentDateHourFormat) + let timeMinute = timeSplit->Array.get(1)->Option.getOr(currentDateMinuteFormat) + let timeSecond = timeSplit->Array.get(2)->Option.getOr(currentDateSecondsFormat) let dateTimeCheck = customTimezoneToISOString( dateYear, dateMonth, diff --git a/src/components/DateRangePicker.res b/src/components/DateRangePicker.res index 290bb0a08..e60941f0e 100644 --- a/src/components/DateRangePicker.res +++ b/src/components/DateRangePicker.res @@ -64,11 +64,11 @@ let getFormattedDate = (date, format) => { let isStartBeforeEndDate = (start, end) => { let getDate = date => { let datevalue = Js.Date.makeWithYMD( - ~year=Js.Float.fromString(date[0]->Option.getWithDefault("")), + ~year=Js.Float.fromString(date[0]->Option.getOr("")), ~month=Js.Float.fromString( - String.make(Js.Float.fromString(date[1]->Option.getWithDefault("")) -. 1.0), + String.make(Js.Float.fromString(date[1]->Option.getOr("")) -. 1.0), ), - ~date=Js.Float.fromString(date[2]->Option.getWithDefault("")), + ~date=Js.Float.fromString(date[2]->Option.getOr("")), (), ) datevalue @@ -291,9 +291,9 @@ module Base = { setEndDateVal(_ => "") } else { let endDateSplit = String.split(ele, "-") - let endDateDate = endDateSplit[2]->Option.getWithDefault("") - let endDateYear = endDateSplit[0]->Option.getWithDefault("") - let endDateMonth = endDateSplit[1]->Option.getWithDefault("") + let endDateDate = endDateSplit[2]->Option.getOr("") + let endDateYear = endDateSplit[0]->Option.getOr("") + let endDateMonth = endDateSplit[1]->Option.getOr("") let splitTime = switch time { | Some(val) => val | None => @@ -305,9 +305,9 @@ module Base = { } let timeSplit = String.split(splitTime, ":") - let timeHour = timeSplit->Belt.Array.get(0)->Option.getWithDefault("00") - let timeMinute = timeSplit->Belt.Array.get(1)->Option.getWithDefault("00") - let timeSecond = timeSplit->Belt.Array.get(2)->Option.getWithDefault("00") + let timeHour = timeSplit->Array.get(0)->Option.getOr("00") + let timeMinute = timeSplit->Array.get(1)->Option.getOr("00") + let timeSecond = timeSplit->Array.get(2)->Option.getOr("00") let endDateTimeCheck = customTimezoneToISOString( endDateYear, endDateMonth, @@ -322,9 +322,9 @@ module Base = { let changeStartDate = (ele, isFromCustomInput, time) => { let setDate = str => { let startDateSplit = String.split(str, "-") - let startDateDay = startDateSplit[2]->Option.getWithDefault("") - let startDateYear = startDateSplit[0]->Option.getWithDefault("") - let startDateMonth = startDateSplit[1]->Option.getWithDefault("") + let startDateDay = startDateSplit[2]->Option.getOr("") + let startDateYear = startDateSplit[0]->Option.getOr("") + let startDateMonth = startDateSplit[1]->Option.getOr("") let splitTime = switch time { | Some(val) => val | None => @@ -335,9 +335,9 @@ module Base = { } } let timeSplit = String.split(splitTime, ":") - let timeHour = timeSplit->Belt.Array.get(0)->Option.getWithDefault("00") - let timeMinute = timeSplit->Belt.Array.get(1)->Option.getWithDefault("00") - let timeSecond = timeSplit->Belt.Array.get(2)->Option.getWithDefault("00") + let timeHour = timeSplit->Array.get(0)->Option.getOr("00") + let timeMinute = timeSplit->Array.get(1)->Option.getOr("00") + let timeSecond = timeSplit->Array.get(2)->Option.getOr("00") let startDateTimeCheck = customTimezoneToISOString( startDateYear, startDateMonth, @@ -507,17 +507,13 @@ module Base = { let endTimeStr = { let timeArr = endTimeStr->String.split(":") - let endTimeTxt = `${timeArr[0]->Option.getWithDefault( - "00", - )}:${timeArr[1]->Option.getWithDefault("00")}` - showSeconds ? `${endTimeTxt}:${timeArr[2]->Option.getWithDefault("00")}` : endTimeTxt + let endTimeTxt = `${timeArr[0]->Option.getOr("00")}:${timeArr[1]->Option.getOr("00")}` + showSeconds ? `${endTimeTxt}:${timeArr[2]->Option.getOr("00")}` : endTimeTxt } let startTimeStr = { let timeArr = startTimeStr->String.split(":") - let startTimeTxt = `${timeArr[0]->Option.getWithDefault( - "00", - )}:${timeArr[1]->Option.getWithDefault("00")}` - showSeconds ? `${startTimeTxt}:${timeArr[2]->Option.getWithDefault("00")}` : startTimeTxt + let startTimeTxt = `${timeArr[0]->Option.getOr("00")}:${timeArr[1]->Option.getOr("00")}` + showSeconds ? `${startTimeTxt}:${timeArr[2]->Option.getOr("00")}` : startTimeTxt } let buttonText = { @@ -615,7 +611,7 @@ module Base = { None }, (startDate, endDate, localStartDate, localEndDate)) - let btnStyle = customButtonStyle->Option.getWithDefault("") + let btnStyle = customButtonStyle->Option.getOr("") let customStyleForBtn = btnStyle->String.length > 0 ? btnStyle : "" @@ -791,7 +787,7 @@ module Base = {
} else if showMsg { let msg = `Date Range should not exceed ${dateRangeLimit - ->Option.getWithDefault(0) + ->Option.getOr(0) ->Belt.Int.toString} days` @@ -867,7 +863,7 @@ module Base = { let useStateForInput = (input: ReactFinalForm.fieldRenderPropsInput) => { React.useMemo1(() => { - let val = input.value->Js.Json.decodeString->Option.getWithDefault("") + let val = input.value->Js.Json.decodeString->Option.getOr("") let onChange = fn => { let newVal = fn(val) input.onChange(newVal->Identity.stringToFormReactEvent) diff --git a/src/components/DynamicChart.res b/src/components/DynamicChart.res index 160ec2e3d..fa99dc882 100644 --- a/src/components/DynamicChart.res +++ b/src/components/DynamicChart.res @@ -39,7 +39,7 @@ let getTimeSeriesChart = (chartEntity: chartEntity) => { ~endDateTime=chartEntity.end_time, ~cardinality=chartEntity.cardinality, ~mode=chartEntity.mode, - ~customFilter=chartEntity.customFilter->Option.getWithDefault(""), + ~customFilter=chartEntity.customFilter->Option.getOr(""), ~prefix=chartEntity.prefix, ~source=chartEntity.source, (), @@ -63,7 +63,7 @@ let getLegendBody = (chartEntity: chartEntity) => { ~endDateTime=chartEntity.end_time, ~cardinality=chartEntity.cardinality, ~mode=chartEntity.mode, - ~customFilter=chartEntity.customFilter->Option.getWithDefault(""), + ~customFilter=chartEntity.customFilter->Option.getOr(""), ~prefix=chartEntity.prefix, ~source=chartEntity.source, (), @@ -329,8 +329,8 @@ let make = ( ->Belt.Array.keepMap(item => { let (key, value) = item let keyArr = key->String.split(".") - let prefix = keyArr->Belt.Array.get(0)->Option.getWithDefault("") - let fitlerName = keyArr->Belt.Array.get(1)->Option.getWithDefault("") + let prefix = keyArr->Array.get(0)->Option.getOr("") + let fitlerName = keyArr->Array.get(1)->Option.getOr("") // when chart id is not there then there won't be any prefix so the prefix will the filter name if chartId === "" { @@ -351,7 +351,7 @@ let make = ( ->Belt.Array.keepMap(item => { let (key, value) = item let keyArr = key->String.split(".") - let prefix = keyArr->Belt.Array.get(0)->Option.getWithDefault("") + let prefix = keyArr->Array.get(0)->Option.getOr("") if prefix === chartId && prefix !== "" { None @@ -369,7 +369,7 @@ let make = ( let {allFilterDimension, dateFilterKeys, currentMetrics, uriConfig, source} = entity - let enableLoaders = entity.enableLoaders->Option.getWithDefault(true) + let enableLoaders = entity.enableLoaders->Option.getOr(true) let entityAllMetrics = uriConfig->Array.reduce([], (acc, item) => Array.concat( @@ -387,7 +387,7 @@ let make = ( let chartType = getChartCompFilters->LogicUtils.getString( "chartType", - entity.chartTypes->Belt.Array.get(0)->Option.getWithDefault(Line)->chartMapper, + entity.chartTypes->Array.get(0)->Option.getOr(Line)->chartMapper, ) let chartTopMetric = getChartCompFilters->LogicUtils.getString("chartTopMetric", currentTopMatrix) @@ -396,14 +396,14 @@ let make = ( getChartCompFilters->LogicUtils.getString("chartBottomMetric", currentBottomMetrix) let dict = Dict.make() - let chartMatrixArr = entityAllMetrics->Belt.Array.map(item => item.metric_label) + let chartMatrixArr = entityAllMetrics->Array.map(item => item.metric_label) if cardinalityArr->Array.includes(cardinality) { dict->Dict.set("cardinality", cardinality) } else if cardinalityArr->Array.includes("TOP_5") { dict->Dict.set("cardinality", "TOP_5") } else { - dict->Dict.set("cardinality", cardinalityArr->Belt.Array.get(0)->Option.getWithDefault("")) + dict->Dict.set("cardinality", cardinalityArr->Array.get(0)->Option.getOr("")) } chartTypeArr->Array.includes(chartType) ? dict->Dict.set("chartType", chartType) @@ -414,7 +414,7 @@ let make = ( } else if chartMatrixArr->Array.includes(currentTopMatrix) { dict->Dict.set("chartTopMetric", currentTopMatrix) } else { - dict->Dict.set("chartTopMetric", chartMatrixArr->Belt.Array.get(0)->Option.getWithDefault("")) + dict->Dict.set("chartTopMetric", chartMatrixArr->Array.get(0)->Option.getOr("")) } if chartMatrixArr->Array.includes(chartBottomMetric) { @@ -422,10 +422,7 @@ let make = ( } else if chartMatrixArr->Array.includes(currentBottomMetrix) { dict->Dict.set("chartBottomMetric", currentBottomMetrix) } else { - dict->Dict.set( - "chartBottomMetric", - chartMatrixArr->Belt.Array.get(0)->Option.getWithDefault(""), - ) + dict->Dict.set("chartBottomMetric", chartMatrixArr->Array.get(0)->Option.getOr("")) } updateChartCompFilters(dict) @@ -541,13 +538,13 @@ let make = ( React.useEffect2(() => { setGranularity(prev => { - current_granularity->Array.includes(prev->Option.getWithDefault("")) + current_granularity->Array.includes(prev->Option.getOr("")) ? prev - : current_granularity->Belt.Array.get(0) + : current_granularity->Array.get(0) }) None }, (startTimeFromUrl, endTimeFromUrl)) - let selectedTabStr = selectedTab->Option.getWithDefault([])->Array.joinWith("") + let selectedTabStr = selectedTab->Option.getOr([])->Array.joinWith("") let updatedChartConfigArr = React.useMemo7(() => { uriConfig->Array.map(item => { @@ -563,8 +560,7 @@ let make = ( }, ) ->Dict.fromArray - let activeTab = - selectedTab->Option.getWithDefault([])->Belt.Array.get(0)->Option.getWithDefault("") + let activeTab = selectedTab->Option.getOr([])->Array.get(0)->Option.getOr("") let granularity = if activeTab === "run_date" { "G_ONEHOUR"->Some } else if activeTab === "run_week" { @@ -614,9 +610,7 @@ let make = ( url: item.uri, body: item.timeSeriesBody(chartconfig), legendBody: ?( - chartconfig.groupByNames->Option.getWithDefault([])->Array.length === 1 - ? legendBody - : None + chartconfig.groupByNames->Option.getOr([])->Array.length === 1 ? legendBody : None ), metrics: item.metrics, timeCol: item.timeCol, @@ -633,12 +627,12 @@ let make = ( let (groupKeyFromTab, titleKey) = React.useMemo1(() => { switch (tabTitleMapper, selectedTab) { | (Some(dict), Some(arr)) => { - let groupKey = arr->Belt.Array.get(0)->Option.getWithDefault("") - (groupKey, dict->Dict.get(groupKey)->Option.getWithDefault(groupKey)) + let groupKey = arr->Array.get(0)->Option.getOr("") + (groupKey, dict->Dict.get(groupKey)->Option.getOr(groupKey)) } | (None, Some(arr)) => ( - arr->Belt.Array.get(0)->Option.getWithDefault(""), - arr->Belt.Array.get(0)->Option.getWithDefault(""), + arr->Array.get(0)->Option.getOr(""), + arr->Array.get(0)->Option.getOr(""), ) | _ => ("", "") } @@ -647,7 +641,7 @@ let make = ( let setRawChartData = (data: array) => { let chartData = data->Array.map(mappedData => { let rawdata = mappedData.rawData->Array.map(item => { - let dict = item->Js.Json.decodeObject->Option.getWithDefault(Dict.make()) + let dict = item->Js.Json.decodeObject->Option.getOr(Dict.make()) switch dict->Dict.get("time_range") { | Some(jsonObj) => { @@ -655,7 +649,7 @@ let make = ( switch timeDict->Dict.get("startTime") { | Some(startValue) => { - let sTime = startValue->Js.Json.decodeString->Option.getWithDefault("") + let sTime = startValue->Js.Json.decodeString->Option.getOr("") if sTime->String.length > 0 { let {date, hour, minute, month, second, year} = @@ -674,14 +668,14 @@ let make = ( } selectedTab - ->Option.getWithDefault([]) + ->Option.getOr([]) ->Array.forEach( tabName => { let metric = Dict.get(dict, tabName) - ->Option.getWithDefault(""->Js.Json.string) + ->Option.getOr(""->Js.Json.string) ->Js.Json.decodeString - ->Option.getWithDefault("") + ->Option.getOr("") let label = metric == "" ? "other" : metric Dict.set(dict, tabName, label->Js.Json.string) @@ -691,9 +685,9 @@ let make = ( if key->String.includes("amount") { let amount = Dict.get(dict, key) - ->Option.getWithDefault(Js.Json.number(0.0)) + ->Option.getOr(Js.Json.number(0.0)) ->Js.Json.decodeNumber - ->Option.getWithDefault(0.0) + ->Option.getOr(0.0) let amount = (amount /. 100.0)->Js.Float.toFixedWithPrecision(~digits=2) @@ -742,13 +736,13 @@ let make = ( let chartType = getChartCompFilters->LogicUtils.getString( "chartType", - entity.chartTypes->Belt.Array.get(0)->Option.getWithDefault(Line)->chartMapper, + entity.chartTypes->Array.get(0)->Option.getOr(Line)->chartMapper, ) if ( startTimeFromUrl !== "" && endTimeFilterKey !== "" && (granularity->Option.isSome || chartType !== "Line Chart") && - current_granularity->Array.includes(granularity->Option.getWithDefault("")) + current_granularity->Array.includes(granularity->Option.getOr("")) ) { setChartLoading(_ => enableLoaders) fetchChartData(updatedChartBody, setRawChartData) @@ -867,7 +861,7 @@ let make = ( } else if isExpandedUpper { switch entityAllMetrics ->Array.filter(item => item.metric_label === chartTopMetricFromUrl) - ->Belt.Array.get(0) { + ->Array.get(0) { | Some(selectedMetrics) => let metricsUri = uriConfig->Array.find(uriMetrics => { uriMetrics.metrics @@ -877,7 +871,7 @@ let make = ( let (data, legendData, timeCol) = switch metricsUri { | Some(val) => switch rawChartData - ->Option.getWithDefault([]) + ->Option.getOr([]) ->Array.find(item => item.metricsUrl === val.uri) { | Some(dataVal) => (dataVal.rawData, dataVal.legendData, val.timeCol) | None => ([], [], "") @@ -963,7 +957,7 @@ let make = ( {if enableBottomChart { switch entityAllMetrics ->Array.filter(item => item.metric_label === chartBottomMetricFromUrl) - ->Belt.Array.get(0) { + ->Array.get(0) { | Some(selectedMetrics) => let metricsUri = uriConfig->Array.find(uriMetrics => { uriMetrics.metrics @@ -972,9 +966,7 @@ let make = ( }) let (data, legendData, timeCol) = switch metricsUri { | Some(val) => - switch rawChartData - ->Option.getWithDefault([]) - ->Array.find(item => item.metricsUrl === val.uri) { + switch rawChartData->Option.getOr([])->Array.find(item => item.metricsUrl === val.uri) { | Some(dataVal) => (dataVal.rawData, dataVal.legendData, val.timeCol) | None => ([], [], "") } diff --git a/src/components/DynamicFilter.res b/src/components/DynamicFilter.res index f0a004eb6..157f1a3cc 100644 --- a/src/components/DynamicFilter.res +++ b/src/components/DynamicFilter.res @@ -51,7 +51,7 @@ module CustomFilters = { ->String.replaceRegExp(%re("/ LIKE /gi"), "@@") ->String.split("@@") - let firstEle = Belt.Array.get(mArr, 0)->Option.getWithDefault("") + let firstEle = mArr[0]->Option.getOr("") if ( firstEle != "" && tabNames->Array.indexOf(firstEle->String.trim->String.toLowerCase) < 0 ) { @@ -171,7 +171,7 @@ let make = ( let {updateExistingKeys, filterValue, removeKeys} = React.useContext(FilterContext.filterContext) - let currentCustomFilterValue = filterValue->Dict.get(customFilterKey)->Option.getWithDefault("") + let currentCustomFilterValue = filterValue->Dict.get(customFilterKey)->Option.getOr("") let setCustomFilter = customFilter => { updateExistingKeys(Dict.fromArray([(customFilterKey, customFilter)])) diff --git a/src/components/DynamicSingleStat.res b/src/components/DynamicSingleStat.res index 22a562b9a..e7686e14f 100644 --- a/src/components/DynamicSingleStat.res +++ b/src/components/DynamicSingleStat.res @@ -100,7 +100,7 @@ let deltaTimeRangeMapper: array => deltaRange = (arrJson: arrayDict.get("currentSr") - ->Option.getWithDefault({ + ->Option.getOr({ fromTime: "", toTime: "", }), @@ -139,7 +139,7 @@ let make = ( ->Belt.Array.keepMap(item => { let (key, value) = item let keyArr = key->String.split(".") - let prefix = keyArr->Belt.Array.get(0)->Option.getWithDefault("") + let prefix = keyArr->Array.get(0)->Option.getOr("") if prefix === moduleName && prefix !== "" { None } else { @@ -159,14 +159,14 @@ let make = ( | _ => "BATCH" } - let enableLoaders = entity.enableLoaders->Option.getWithDefault(true) + let enableLoaders = entity.enableLoaders->Option.getOr(true) let customFilterKey = switch entity { | {customFilterKey} => customFilterKey | _ => "" } let allFilterKeys = Array.concat( - [startTimeFilterKey, endTimeFilterKey, mode->Option.getWithDefault("")], + [startTimeFilterKey, endTimeFilterKey, mode->Option.getOr("")], filterKeys, ) @@ -222,7 +222,7 @@ let make = ( let homePageCss = isHomePage || chartAlignment === #row ? "flex-col" : "flex-row" let wrapperClass = - wrapperClass->Option.getWithDefault( + wrapperClass->Option.getOr( `flex mt-5 flex-col md:${homePageCss} flex-wrap justify-start items-stretch relative`, ) @@ -263,7 +263,7 @@ let make = ( entity.urlConfig ->Array.map(urlConfig => { let {uri, metrics} = urlConfig - let domain = String.split("/", uri)->Belt.Array.get(4)->Option.getWithDefault("") + let domain = String.split("/", uri)->Array.get(4)->Option.getOr("") let startTime = if domain === "mandate" { (endTimeFromUrl->DayJs.getDayJsForString).subtract(. 1, @@ -284,8 +284,7 @@ let make = ( source, prefix: ?urlConfig.prefix, } - let singleStatBodyMakerFn = - urlConfig.singleStatBody->Option.getWithDefault(singleStatBodyMake) + let singleStatBodyMakerFn = urlConfig.singleStatBody->Option.getOr(singleStatBodyMake) let singleStatBody = singleStatBodyMakerFn(singleStatBodyEntity) fetchApi( @@ -296,7 +295,7 @@ let make = ( (), ) ->addLogsAroundFetch(~logTitle="SingleStat Data Api") - ->then(json => resolve((`${urlConfig.prefix->Option.getWithDefault("")}${uri}`, json))) + ->then(json => resolve((`${urlConfig.prefix->Option.getOr("")}${uri}`, json))) ->catch(_err => resolve(("", Js.Json.object_(Dict.make())))) }) ->Promise.all @@ -311,8 +310,8 @@ let make = ( ->LogicUtils.getDictFromJsonObject ->LogicUtils.getJsonObjectFromDict("queryData") ->LogicUtils.getArrayFromJson([]) - ->Belt.Array.get(0) - ->Option.getWithDefault(Js.Json.object_(Dict.make())) + ->Array.get(0) + ->Option.getOr(Js.Json.object_(Dict.make())) ->LogicUtils.getDictFromJsonObject ->Dict.toArray ->Array.find( @@ -325,7 +324,7 @@ let make = ( | Some(data) => { let (_key, value) = data setTotalVolume( - _ => value->Js.Json.decodeNumber->Option.getWithDefault(0.)->Belt.Float.toInt, + _ => value->Js.Json.decodeNumber->Option.getOr(0.)->Belt.Float.toInt, ) } @@ -363,7 +362,7 @@ let make = ( entity.urlConfig ->Array.map(urlConfig => { let {uri, metrics} = urlConfig - let domain = String.split("/", uri)->Belt.Array.get(4)->Option.getWithDefault("") + let domain = String.split("/", uri)->Array.get(4)->Option.getOr("") let startTime = if domain === "mandate" { (endTimeFromUrl->DayJs.getDayJsForString).subtract(. 1, @@ -380,14 +379,14 @@ let make = ( delta: false, startDateTime: startTime, endDateTime: endTimeFromUrl, - granularity: ?granularity->Belt.Array.get(0), + granularity: ?granularity->Array.get(0), ?mode, customFilter, source, prefix: ?urlConfig.prefix, } let singleStatBodyMakerFn = - urlConfig.singleStatTimeSeriesBody->Option.getWithDefault(singleStatBodyMake) + urlConfig.singleStatTimeSeriesBody->Option.getOr(singleStatBodyMake) fetchApi( uri, ~method_=Post, @@ -398,7 +397,7 @@ let make = ( ->addLogsAroundFetch(~logTitle="SingleStatTimeseries Data Api") ->then( json => { - resolve((`${urlConfig.prefix->Option.getWithDefault("")}${uri}`, json)) + resolve((`${urlConfig.prefix->Option.getOr("")}${uri}`, json)) }, ) ->catch( @@ -433,7 +432,7 @@ let make = ( let uri = col->entity.matrixUriMapper let timeSeriesData = singlestatDataCombined.singleStatTimeData - ->Option.getWithDefault([("--", [])]) + ->Option.getOr([("--", [])]) ->Belt.Array.keepMap( item => { let (timeSectionName, timeSeriesObj) = item @@ -450,7 +449,7 @@ let make = ( item.sectionUrl === uri }, ) - ->Belt.Array.get(0) + ->Array.get(0) switch sectiondata { | Some(data) => { @@ -459,7 +458,7 @@ let make = ( timeSeriesData, data.deltaTime, col, - mode->Option.getWithDefault("ORDER"), + mode->Option.getOr("ORDER"), ) Option.getWithDefault(false) + prefixAddition->Option.getOr(false) ? title->String.replaceRegExp(_, %re("/ /g"), "-")->String.toLowerCase->Some : None let (defaultFilters, setDefaultFilters) = React.useState(() => entity.defaultFilters) @@ -197,7 +197,7 @@ let make = ( } setData(prevData => { - let newData = prevData->Option.getWithDefault([])->Array.concat(sampleRes) + let newData = prevData->Option.getOr([])->Array.concat(sampleRes) Some(newData) }) } @@ -212,7 +212,7 @@ let make = ( let x = filtersFromUrl ->Dict.get(val) - ->Option.getWithDefault(searchValueDict->Dict.get(val)->Option.getWithDefault("")) + ->Option.getOr(searchValueDict->Dict.get(val)->Option.getOr("")) if requireDateFormatting && (val == "startTime" || val == "endTime") { (x->DayJs.getDayJsForString).format(. "YYYY-MM-DD+HH:mm:ss") } else if requireDateFormatting && (val == "start_date" || val == "end_date") { @@ -295,15 +295,15 @@ let make = ( setRefetchCounter(p => p + 1) }, [setRefetchCounter]) - let visibleColumns = visibleColumnsProp->Option.getWithDefault(defaultColumns) + let visibleColumns = visibleColumnsProp->Option.getOr(defaultColumns) let handleRefetch = () => { - let rowFetched = data->Option.getWithDefault([])->Array.length + let rowFetched = data->Option.getOr([])->Array.length if rowFetched !== summary.totalCount { setTableDataLoading(_ => true) let newDefaultFilter = defaultFilters ->Js.Json.decodeObject - ->Option.getWithDefault(Dict.make()) + ->Option.getOr(Dict.make()) ->Dict.toArray ->Dict.fromArray @@ -314,14 +314,14 @@ let make = ( let showLocalFilter = (localFilters->Array.length > 0 || localOptions->Array.length > 0) && - (applyFilters ? finalData : data)->Option.getWithDefault([])->Array.length > 0 + (applyFilters ? finalData : data)->Option.getOr([])->Array.length > 0 let showRemoteFilter = remoteFilters->Array.length > 0 || remoteOptions->Array.length > 0 let filters = { if ( (Array.length(initialFilters) > 0 || Array.length(options) > 0) && (showLocalFilter || showRemoteFilter) && - (!hideFiltersOnNoData || data->Option.getWithDefault([])->Array.length > 0) + (!hideFiltersOnNoData || data->Option.getOr([])->Array.length > 0) ) { let children =
@@ -416,7 +416,7 @@ let make = ( for i in 0 to cols->Array.length - 1 { checkLength := checkLength.contents && - switch obj[cols[i]->Option.getWithDefault(0)] { + switch obj[cols[i]->Option.getOr(0)] { | Some(ele) => Array.length(ele.selected) > 0 | None => false } diff --git a/src/components/DynamicTableUtils.res b/src/components/DynamicTableUtils.res index 2bfaf6e7b..f7b58882e 100644 --- a/src/components/DynamicTableUtils.res +++ b/src/components/DynamicTableUtils.res @@ -12,10 +12,8 @@ let visibilityColFunc = ( | Date(x) => (dateFormatConvertor(x), dateFormatConvertor(x)) | StartEndDate(start, end) => ( `${dateFormatConvertor(start) - ->Option.getWithDefault(""->Js.Json.string) - ->String.make} ${dateFormatConvertor(end) - ->Option.getWithDefault(""->Js.Json.string) - ->String.make}` + ->Option.getOr(""->Js.Json.string) + ->String.make} ${dateFormatConvertor(end)->Option.getOr(""->Js.Json.string)->String.make}` ->Js.Json.string ->Some, dateFormatConvertor(end), @@ -40,7 +38,7 @@ let useDateFormatConvertor = () => { let filteredData = ( actualData: Js.Array2.t>, - columnFilter: Js.Dict.t>, + columnFilter: Dict.t>, visibleColumns: option>, entity: EntityType.entityType<'colType, 't>, dateFormatConvertor: string => option, @@ -63,7 +61,7 @@ let filteredData = ( ) let visibleColumns = visibleColumns - ->Option.getWithDefault(entity.defaultColumns) + ->Option.getOr(entity.defaultColumns) ->Belt.Array.keepMap( item => { let columnEntity = entity.getHeading(item) @@ -106,7 +104,7 @@ let filteredData = ( | (None, _) => "" } - let searchedText = selectedArr1->Belt.Array.get(0)->Option.getWithDefault("") + let searchedText = selectedArr1->Array.get(0)->Option.getOr("") !String.includes( searchedText->String.toUpperCase, currVal->String.toUpperCase, @@ -121,8 +119,8 @@ let filteredData = ( | _ => 0. } !( - currVal >= selectedArr[0]->Option.getWithDefault(0.) && - currVal <= selectedArr[1]->Option.getWithDefault(0.) + currVal >= selectedArr[0]->Option.getOr(0.) && + currVal <= selectedArr[1]->Option.getOr(0.) ) } } @@ -149,7 +147,7 @@ let convertStrCellToFloat = (dataType: Table.cellType, str: string) => { switch dataType { | DropDown | LabelType | TextType => str->Js.Json.string | MoneyType | NumericType | ProgressType => - str->Belt.Float.fromString->Option.getWithDefault(0.)->Js.Json.number + str->Belt.Float.fromString->Option.getOr(0.)->Js.Json.number } } diff --git a/src/components/DynamicTabs.res b/src/components/DynamicTabs.res index efe298614..d55a9726b 100644 --- a/src/components/DynamicTabs.res +++ b/src/components/DynamicTabs.res @@ -6,7 +6,7 @@ type tab = { } let getValueFromArrayTab = (tabsVal: array, index: int) => { - switch tabsVal->Belt.Array.get(index) { + switch tabsVal->Array.get(index) { | Some(val) => val.value | None => "" } @@ -66,7 +66,7 @@ module TabInfo = { let handleClick = React.useCallback2(_ev => { handleSelectedTab( ~tabValue={ - switch tabNames->Belt.Array.get(index) { + switch tabNames->Array.get(index) { | Some(tab) => tab.value | None => getValueFromArrayTab(tabNames, 0) } @@ -96,10 +96,7 @@ module TabInfo = { updatedStackAfterRemovingTab->Array.filterWithIndex((item, index) => index === 0 ? true - : item !== - updatedStackAfterRemovingTab - ->Belt.Array.get(index - 1) - ->Option.getWithDefault("") + : item !== updatedStackAfterRemovingTab->Array.get(index - 1)->Option.getOr("") ) }) @@ -214,10 +211,7 @@ module IndicationArrow = { } let getBoundingRectInfo = (ref: React.ref>, getter) => { - ref.current - ->Js.Nullable.toOption - ->Belt.Option.map(getBoundingClientRect) - ->Belt.Option.mapWithDefault(0, getter) + ref.current->Js.Nullable.toOption->Belt.Option.map(getBoundingClientRect)->Option.mapOr(0, getter) } @react.component @@ -240,7 +234,7 @@ let make = ( // this tabs will always loaded independent of user preference let isMobileView = MatchMedia.useMobileChecker() let defaultTabs = - defaultTabs->Option.getWithDefault(tabs->Array.copy->Array.filter(item => !item.isRemovable)) + defaultTabs->Option.getOr(tabs->Array.copy->Array.filter(item => !item.isRemovable)) let tabOuterClass = `gap-1.5` let bottomBorderClass = "" @@ -261,8 +255,8 @@ let make = ( ->Array.filter(item => { item.value == key }) - ->Belt.Array.get(0) - ->Option.getWithDefault({title: "", value: "", isRemovable: false}) + ->Array.get(0) + ->Option.getOr({title: "", value: "", isRemovable: false}) ).title } @@ -304,7 +298,7 @@ let make = ( }, ) { | Some(tabValue) => - enableDescriptionHeader ? tabValue.description->Option.getWithDefault("") : "" + enableDescriptionHeader ? tabValue.description->Option.getOr("") : "" | None => "" }, isRemovable: switch tabs->Array.find( @@ -434,10 +428,7 @@ let make = ( ) => unit = (~tabValue: string, ~collapsibleTabs: array, ~removed: bool) => { if removed === false { if ( - tabValue !== - tabStacksnames - ->Belt.Array.get(tabStacksnames->Array.length - 1) - ->Option.getWithDefault("") + tabValue !== tabStacksnames->Array.get(tabStacksnames->Array.length - 1)->Option.getOr("") ) { setTabStacksnames(prev => { Array.concat(prev, [tabValue]) @@ -453,15 +444,11 @@ let make = ( Dict.fromArray([ ( "tabName", - `[${tabStacksnames - ->Belt.Array.get(tabStacksnames->Array.length - 1) - ->Option.getWithDefault("")}]`, + `[${tabStacksnames->Array.get(tabStacksnames->Array.length - 1)->Option.getOr("")}]`, ), ]), ) - setActiveTab( - tabStacksnames->Belt.Array.get(tabStacksnames->Array.length - 1)->Option.getWithDefault(""), - ) + setActiveTab(tabStacksnames->Array.get(tabStacksnames->Array.length - 1)->Option.getOr("")) setSelectedIndex(_ => Js.Math.max_int( @@ -469,9 +456,7 @@ let make = ( collapsibleTabs ->Array.map(item => item.value) ->Array.indexOf( - tabStacksnames - ->Belt.Array.get(tabStacksnames->Array.length - 1) - ->Option.getWithDefault(""), + tabStacksnames->Array.get(tabStacksnames->Array.length - 1)->Option.getOr(""), ), ) ) diff --git a/src/components/FilterUtils.res b/src/components/FilterUtils.res index 99e53811b..dd11f766c 100644 --- a/src/components/FilterUtils.res +++ b/src/components/FilterUtils.res @@ -4,8 +4,8 @@ let parseFilterString = queryString => { ->String.split("&") ->Belt.Array.keepMap(str => { let arr = str->String.split("=") - let key = arr->Belt.Array.get(0)->Option.getWithDefault("-") - let val = arr->Belt.Array.sliceToEnd(1)->Array.joinWith("=") + let key = arr->Array.get(0)->Option.getOr("-") + let val = arr->Array.sliceToEnd(~start=1)->Array.joinWith("=") key === "" || val === "" ? None : Some((key, val)) }) ->Dict.fromArray diff --git a/src/components/HeadlessUISelectBox.res b/src/components/HeadlessUISelectBox.res index 537b08a1b..d11c7160b 100644 --- a/src/components/HeadlessUISelectBox.res +++ b/src/components/HeadlessUISelectBox.res @@ -80,7 +80,7 @@ let make = ( {switch option.leftIcon { | FontAwesome(iconName) => Option.getWithDefault( + className={`align-middle ${option.customIconStyle->Option.getOr( "", )}`} size=14 @@ -93,7 +93,7 @@ let make = ( | _ => React.null }} -
Option.getWithDefault("")}> +
Option.getOr("")}> {React.string(option.label)} @@ -102,7 +102,7 @@ let make = ( {switch option.rightIcon { | FontAwesome(iconName) => Option.getWithDefault( + className={`align-middle ${option.customIconStyle->Option.getOr( "", )}`} size=12 @@ -160,7 +160,7 @@ let make = ( {switch option.leftIcon { | FontAwesome(iconName) => Option.getWithDefault( + className={`align-middle ${option.customIconStyle->Option.getOr( "", )}`} size=12 @@ -173,7 +173,7 @@ let make = ( | _ => React.null }} -
Option.getWithDefault("")}> +
Option.getOr("")}> {React.string(option.label)} @@ -182,7 +182,7 @@ let make = ( {switch option.rightIcon { | FontAwesome(iconName) => Option.getWithDefault( + className={`align-middle ${option.customIconStyle->Option.getOr( "", )}`} size=12 diff --git a/src/components/Icon.res b/src/components/Icon.res index 4598905b1..2ac0cd72c 100644 --- a/src/components/Icon.res +++ b/src/components/Icon.res @@ -35,12 +35,10 @@ let make = ( fill=customIconColor className={`fill-current ${otherClasses}`} width={{ - customWidth->Option.isSome ? customWidth->Option.getWithDefault("") : string_of_int(size) + customWidth->Option.isSome ? customWidth->Option.getOr("") : string_of_int(size) } ++ "px"} height={{ - customHeight->Option.isSome - ? customHeight->Option.getWithDefault("") - : string_of_int(size) + customHeight->Option.isSome ? customHeight->Option.getOr("") : string_of_int(size) } ++ "px"}> useUrl diff --git a/src/components/InfraCalendar.res b/src/components/InfraCalendar.res index b15e5ada7..498fb2486 100644 --- a/src/components/InfraCalendar.res +++ b/src/components/InfraCalendar.res @@ -16,7 +16,7 @@ module TableRow = { switch obj { | Some(a) => { let day = String.split(a, "-") - React.string(day[2]->Option.getWithDefault("")) + React.string(day[2]->Option.getOr("")) } | None => React.string("") @@ -41,7 +41,7 @@ module TableRow = { let highlight = cellHighlighter { - if item == Belt.Array.make(7, "") { + if item == Array.make(~length=7, "") { React.null } else { @@ -106,11 +106,11 @@ module TableRow = { if startDate != "" && obj != "" { let getDate = date => { let datevalue = Js.Date.makeWithYMD( - ~year=Js.Float.fromString(date[0]->Option.getWithDefault("")), + ~year=Js.Float.fromString(date[0]->Option.getOr("")), ~month=Js.Float.fromString( - String.make(Js.Float.fromString(date[1]->Option.getWithDefault("")) -. 1.0), + String.make(Js.Float.fromString(date[1]->Option.getOr("")) -. 1.0), ), - ~date=Js.Float.fromString(date[2]->Option.getWithDefault("")), + ~date=Js.Float.fromString(date[2]->Option.getOr("")), (), ) datevalue @@ -230,7 +230,7 @@ let make = ( } // creating row info - let dummyRow = Belt.Array.make(6, Belt.Array.make(7, "")) + let dummyRow = Array.make(~length=6, Array.make(~length=7, "")) let rowMapper = (row, indexRow) => { Array.mapWithIndex(row, (_item, index) => { diff --git a/src/components/InfraCalendarList.res b/src/components/InfraCalendarList.res index 58994d221..e8cbdca83 100644 --- a/src/components/InfraCalendarList.res +++ b/src/components/InfraCalendarList.res @@ -44,7 +44,7 @@ let getMonthInStr = (mon: InfraCalendar.month) => { let getMonthFromFloat = value => { let valueInt = value->Belt.Float.toInt - months[valueInt]->Option.getWithDefault(Jan) + months[valueInt]->Option.getOr(Jan) } module YearItem = { @send external scrollIntoView: Dom.element => unit = "scrollIntoView" diff --git a/src/components/LoadedTable.res b/src/components/LoadedTable.res index 516b1e9a5..8b124c5f2 100644 --- a/src/components/LoadedTable.res +++ b/src/components/LoadedTable.res @@ -19,7 +19,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" @@ -85,8 +85,8 @@ let sortArray = (originalData, key, sortOrder: Table.sortOrder) => { } let sortedArrayByOrder = { let _ = originalData->Js.Array2.sortInPlaceWith((i1, i2) => { - let item1 = i1->Js.Json.stringifyAny->Option.getWithDefault("")->LogicUtils.safeParse - let item2 = i2->Js.Json.stringifyAny->Option.getWithDefault("")->LogicUtils.safeParse + let item1 = i1->Js.Json.stringifyAny->Option.getOr("")->LogicUtils.safeParse + let item2 = i2->Js.Json.stringifyAny->Option.getOr("")->LogicUtils.safeParse // flatten items and get data let val1 = @@ -130,7 +130,7 @@ type pageDetails = { resultsPerPage: int, } -let table_pageDetails: Recoil.recoilAtom> = Recoil.atom(. +let table_pageDetails: Recoil.recoilAtom> = Recoil.atom(. "table_pageDetails", Dict.make(), ) @@ -251,7 +251,7 @@ let make = ( let (firstRender, setFirstRender) = React.useState(_ => true) let setPageDetails = Recoil.useSetRecoilState(table_pageDetails) let pageDetailDict = Recoil.useRecoilValueFromAtom(table_pageDetails) - let pageDetail = pageDetailDict->Dict.get(title)->Option.getWithDefault(defaultValue) + let pageDetail = pageDetailDict->Dict.get(title)->Option.getOr(defaultValue) let ( selectAllCheckBox: option, @@ -372,10 +372,9 @@ let make = ( (isFilterOpen, setIsFilterOpen) }, (isFilterOpen, setIsFilterOpen)) - let heading = - visibleColumns->Option.getWithDefault(entity.defaultColumns)->Array.map(entity.getHeading) + let heading = visibleColumns->Option.getOr(entity.defaultColumns)->Array.map(entity.getHeading) - let handleRemoveLines = removeVerticalLines->Option.getWithDefault(true) + let handleRemoveLines = removeVerticalLines->Option.getOr(true) if showSerialNumber { heading ->Array.unshift( @@ -439,7 +438,7 @@ let make = ( if tableLocalFilter { let columnFilterRow = visibleColumns - ->Option.getWithDefault(entity.defaultColumns) + ->Option.getOr(entity.defaultColumns) ->Array.map(item => { let headingEntity = entity.getHeading(item) let key = headingEntity.key @@ -454,7 +453,7 @@ let make = ( actualData ->filteredData(columnFilterCopy, visibleColumns, entity, dateFormatConvertor) - ->Belt.Array.forEach( + ->Array.forEach( rows => { switch rows->Js.Nullable.toOption { | Some(rows) => @@ -486,9 +485,7 @@ let make = ( | LabelType | TextType => Table.TextFilter(key) | MoneyType | NumericType | ProgressType => { let newArr = - filterValueArray->Array.map( - item => item->Js.Json.decodeNumber->Option.getWithDefault(0.), - ) + filterValueArray->Array.map(item => item->Js.Json.decodeNumber->Option.getOr(0.)) if newArr->Array.length >= 1 { Table.Range(key, Js.Math.minMany_float(newArr), Js.Math.maxMany_float(newArr)) @@ -559,19 +556,19 @@ let make = ( None }, [selectAllCheckBox]) - let sNoArr = Dict.get(columnFilter, "s_no")->Option.getWithDefault([]) + let sNoArr = Dict.get(columnFilter, "s_no")->Option.getOr([]) // filtering for SNO let nullableRows = filteredData->Array.mapWithIndex((nullableItem, index) => { let actualRows = switch nullableItem->Js.Nullable.toOption { | Some(item) => { let visibleCell = visibleColumns - ->Option.getWithDefault(entity.defaultColumns) + ->Option.getOr(entity.defaultColumns) ->Array.map(colType => { entity.getCell(item, colType) }) - let startPoint = sNoArr->Belt.Array.get(0)->Option.getWithDefault(1.->Js.Json.number) - let endPoint = sNoArr->Belt.Array.get(1)->Option.getWithDefault(1.->Js.Json.number) + let startPoint = sNoArr->Array.get(0)->Option.getOr(1.->Js.Json.number) + let endPoint = sNoArr->Array.get(1)->Option.getOr(1.->Js.Json.number) let jsonIndex = (index + 1)->Belt.Int.toFloat->Js.Json.number sNoArr->Array.length > 0 ? { @@ -637,8 +634,7 @@ let make = ( let dataExists = rows->Array.length > 0 let heading = heading->Array.mapWithIndex((head, index) => { - let getValue = row => - row->Belt.Array.get(index)->Belt.Option.mapWithDefault("", Table.getTableCellValue) + let getValue = row => row->Array.get(index)->Option.mapOr("", Table.getTableCellValue) let default = switch rows[0] { | Some(ele) => getValue(ele) @@ -925,7 +921,7 @@ let make = ( } else { `${ignoreHeaderBg ? "" : backgroundClass} empty:hidden` } - let dataId = title->Js.String2.split("-")->Belt.Array.get(0)->Option.getWithDefault("") + let dataId = title->String.split("-")->Array.get(0)->Option.getOr("")
diff --git a/src/components/LoadedTable.resi b/src/components/LoadedTable.resi index a2453f93e..0f33322a5 100644 --- a/src/components/LoadedTable.resi +++ b/src/components/LoadedTable.resi @@ -1,3 +1,4 @@ +external toJson: Js.Nullable.t<'a> => Js.Json.t = "%identity" type sortTyp = ASC | DSC type sortOb = {sortKey: string, sortType: sortTyp} type checkBoxProps = { @@ -6,7 +7,7 @@ type checkBoxProps = { setSelectedData: (Js.Array2.t => Js.Array2.t) => unit, } let checkBoxPropDefaultVal: checkBoxProps -let sortAtom: Recoil.recoilAtom> +let sortAtom: Recoil.recoilAtom> let backgroundClass: string let useSortedObj: ( string, @@ -15,16 +16,16 @@ let useSortedObj: ( option, (option => option) => unit, ) -// let sortArray: (Js.Array2.t<'a>, RescriptCoreFuture.Dict.key, Table.sortOrder) => Js.Array2.t<'a> +let sortArray: (Js.Array2.t<'a>, string, Table.sortOrder) => Js.Array2.t<'a> type pageDetails = {offset: int, resultsPerPage: int} -let table_pageDetails: Recoil.recoilAtom> +let table_pageDetails: Recoil.recoilAtom> @react.component let make: ( - ~visibleColumns: Js.Array2.t<'colType>=?, + ~visibleColumns: Js.Array2.t<'a>=?, ~defaultSort: Table.sortedObject=?, - ~title: Js.Dict.key, + ~title: Js.String2.t, ~titleSize: NewThemeUtils.headingSize=?, - ~description: Js.String2.t=?, + ~description: string=?, ~tableActions: React.element=?, ~isTableActionBesideFilters: bool=?, ~hideFilterTopPortals: bool=?, @@ -32,16 +33,16 @@ let make: ( ~clearFormattedDataButton: React.element=?, ~bottomActions: React.element=?, ~showSerialNumber: bool=?, - ~actualData: Js.Array2.t>, + ~actualData: Js.Array2.t>, ~totalResults: int, ~resultsPerPage: int, ~offset: int, - ~setOffset: ('b => int) => unit, + ~setOffset: ('c => int) => unit, ~handleRefetch: unit => unit=?, - ~entity: EntityType.entityType<'colType, 't>, - ~onEntityClick: 't => unit=?, - ~onEntityDoubleClick: 't => unit=?, - ~onExpandClickData: 'onExpandClickData=?, + ~entity: EntityType.entityType<'a, 'b>, + ~onEntityClick: 'b => unit=?, + ~onEntityDoubleClick: 'b => unit=?, + ~onExpandClickData: 'd=?, ~currrentFetchCount: int, ~filters: React.element=?, ~showFilterBorder: bool=?, @@ -57,19 +58,19 @@ let make: ( ~tableDataLoading: bool=?, ~dataLoading: bool=?, ~advancedSearchComponent: React.element=?, - ~setData: ('c => option>>) => unit=?, - ~setSummary: ('d => EntityType.summary) => unit=?, - ~customGetObjects: Js.Json.t => array<'a>=?, + ~setData: ('e => option>>) => unit=?, + ~setSummary: ('f => EntityType.summary) => unit=?, + ~customGetObjects: Js.Json.t => array<'g>=?, ~dataNotFoundComponent: React.element=?, - ~renderCard: (~index: int, ~item: 't, ~onRowClick: React.callback) => React.element=?, + ~renderCard: (~index: int, ~item: 'b, ~onRowClick: React.callback) => React.element=?, ~tableLocalFilter: bool=?, ~tableheadingClass: string=?, ~tableBorderClass: string=?, ~tableDataBorderClass: string=?, ~collapseTableRow: bool=?, - ~getRowDetails: Js.Nullable.t<'t> => React.element=?, - ~onMouseEnter: 't => unit=?, - ~onMouseLeave: 't => unit=?, + ~getRowDetails: Js.Nullable.t<'b> => React.element=?, + ~onMouseEnter: 'b => unit=?, + ~onMouseLeave: 'b => unit=?, ~frozenUpto: int=?, ~heightHeadingClass: string=?, ~highlightText: Js.String.t=?, @@ -104,7 +105,7 @@ let make: ( ~headerCustomBgColor: string=?, ~alignCellContent: string=?, ~minTableHeightClass: string=?, - ~setExtFilteredDataLength: ('f => int) => unit=?, + ~setExtFilteredDataLength: ('h => int) => unit=?, ~filterDropdownMaxHeight: string=?, ~showResultsPerPageSelector: bool=?, ~customCellColor: string=?, diff --git a/src/components/LocalFilters.res b/src/components/LocalFilters.res index 1c55318bd..dd93b9580 100644 --- a/src/components/LocalFilters.res +++ b/src/components/LocalFilters.res @@ -122,7 +122,7 @@ let make = ( initialValues ->Js.Json.decodeObject - ->Option.getWithDefault(Dict.make()) + ->Option.getOr(Dict.make()) ->Dict.toArray ->Array.forEach(entry => { let (key, _value) = entry @@ -170,7 +170,7 @@ let make = ( let defaultEntityOptionType: EntityType.optionType< 't, > = EntityType.getDefaultEntityOptionType() - let optionObj = optionObjArry[0]->Option.getWithDefault(defaultEntityOptionType) + let optionObj = optionObjArry[0]->Option.getOr(defaultEntityOptionType) localSelectedFiltersList->Array.push(optionObj.field)->ignore localCheckedFilters->Array.push(value)->ignore }) @@ -182,9 +182,9 @@ let make = ( let toBeRemoved = checkedFilters->Array.filter(oldVal => !Array.includes(fieldNameArr, oldVal)) let finalFieldList = selectedFiltersList->Array.filter(val => { val.inputNames - ->Belt.Array.get(0) + ->Array.get(0) ->Belt.Option.map(name => !{toBeRemoved->Array.includes(name)}) - ->Option.getWithDefault(false) + ->Option.getOr(false) }) let filtersAfterRemoving = checkedFilters->Array.filter(val => !Array.includes(toBeRemoved, val)) @@ -192,7 +192,7 @@ let make = ( let newInitialValues = initialValueJson ->Js.Json.decodeObject - ->Option.getWithDefault(Dict.make()) + ->Option.getOr(Dict.make()) ->Dict.toArray ->Array.filter(entry => { let (key, _value) = entry diff --git a/src/components/MakeRuleFieldComponent.res b/src/components/MakeRuleFieldComponent.res index 68da55ded..9c509c086 100644 --- a/src/components/MakeRuleFieldComponent.res +++ b/src/components/MakeRuleFieldComponent.res @@ -1,4 +1,3 @@ -external strToFormEvent: Js.String.t => ReactEvent.Form.t = "%identity" let validateConditionJson = json => { open LogicUtils let checkValue = dict => { @@ -54,9 +53,7 @@ module CompressedView = { dict->getString("logical.operator", ""), dict->getString("real_field", ""), dict->getString("operator", ""), - dict - ->getOptionStrArrayFromDict("value") - ->Option.getWithDefault([dict->getString("value", "")]), + dict->getOptionStrArrayFromDict("value")->Option.getOr([dict->getString("value", "")]), dict->getDictfromDict("metadata")->getOptionString("key"), ) }) diff --git a/src/components/MonacoEditorLazy.res b/src/components/MonacoEditorLazy.res index 5fe9b5bc2..48218659f 100644 --- a/src/components/MonacoEditorLazy.res +++ b/src/components/MonacoEditorLazy.res @@ -21,9 +21,9 @@ let make = ( let copyValue = value->Option.isNone ? defaultValue : value Option.getWithDefault(""))]> + attributes=[("data-editor", "Monaco Editor"), ("text", value->Option.getOr(""))]>
- {headerComponent->Option.getWithDefault(React.null)} + {headerComponent->Option.getOr(React.null)} {showCopy ? : React.null} { - let val = input.value->Js.Json.decodeString->Option.getWithDefault("") + let val = input.value->Js.Json.decodeString->Option.getOr("") if val->String.includes("") { showPopUp({ popUpType: (Warning, WithIcon), diff --git a/src/components/MultipleFileUpload.res b/src/components/MultipleFileUpload.res index 79f365d3c..a7b14e97d 100644 --- a/src/components/MultipleFileUpload.res +++ b/src/components/MultipleFileUpload.res @@ -95,8 +95,8 @@ let make = ( let files = input.value->LogicUtils.getArrayFromJson([]) while !break.contents { - if target["files"]->Array.length > arr[0]->Option.getWithDefault(0) { - let index = arr->Belt.Array.get(0)->Option.getWithDefault(0) + if target["files"]->Array.length > arr[0]->Option.getOr(0) { + let index = arr->Array.get(0)->Option.getOr(0) switch target["files"][index] { | Some(value) => { let filename = value["name"] @@ -104,7 +104,7 @@ let make = ( let mimeType = value["type"] let fileFormat = String.concat( ".", - Array.pop(filename->String.split("."))->Option.getWithDefault(""), + Array.pop(filename->String.split("."))->Option.getOr(""), ) let fileTypeArr = fileType->String.split(",") let isCorrectFileFormat = @@ -171,7 +171,7 @@ let make = ( toast("Invalid file", ToastError) } } - arr->Belt.Array.set(0, arr[0]->Option.getWithDefault(0) + 1)->ignore + arr->Belt.Array.set(0, arr[0]->Option.getOr(0) + 1)->ignore } | None => () } @@ -189,17 +189,13 @@ let make = ( ~fileName, ~content=decodeParsedfile ? try { - val - ->Belt.Array.get(indx) - ->Option.getWithDefault(Js.Json.null) - ->getStringFromJson("") - ->atob + val->Array.get(indx)->Option.getOr(Js.Json.null)->getStringFromJson("")->atob } catch { | _ => toast("Error : Unable to parse file", ToastError) "" } - : val->Belt.Array.get(indx)->Option.getWithDefault(Js.Json.null)->getStringFromJson(""), + : val->Array.get(indx)->Option.getOr(Js.Json.null)->getStringFromJson(""), ) } @@ -259,7 +255,7 @@ let make = ( className={pointerDisable ? "flex items-center gap-4 flex-1 pointer-events-none" : "flex items-center gap-4 flex-1"}> - {switch fileName->String.split(".")->Array.pop->Option.getWithDefault("") { + {switch fileName->String.split(".")->Array.pop->Option.getOr("") { | "pdf" => | "csv" => | _ => React.null diff --git a/src/components/NewCalendar.res b/src/components/NewCalendar.res index c8d552948..66f3765bb 100644 --- a/src/components/NewCalendar.res +++ b/src/components/NewCalendar.res @@ -15,7 +15,7 @@ module TableRow = { switch obj { | Some(a) => { let day = String.split(a, "-") - React.string(day->Belt.Array.get(2)->Option.getWithDefault("")) + React.string(day->Array.get(2)->Option.getOr("")) } | None => React.string("") @@ -48,7 +48,7 @@ module TableRow = { let highlight = cellHighlighter { - if item == Belt.Array.make(7, "") { + if item == Array.make(~length=7, "") { } else { <> @@ -132,15 +132,11 @@ module TableRow = { } let getDate = date => { let datevalue = Js.Date.makeWithYMD( - ~year=Js.Float.fromString(date->Belt.Array.get(0)->Option.getWithDefault("0")), + ~year=Js.Float.fromString(date->Array.get(0)->Option.getOr("0")), ~month=Js.Float.fromString( - String.make( - Js.Float.fromString( - date->Belt.Array.get(1)->Option.getWithDefault("0"), - ) -. 1.0, - ), + String.make(Js.Float.fromString(date->Array.get(1)->Option.getOr("0")) -. 1.0), ), - ~date=Js.Float.fromString(date->Belt.Array.get(2)->Option.getWithDefault("")), + ~date=Js.Float.fromString(date->Array.get(2)->Option.getOr("")), (), ) datevalue @@ -419,8 +415,8 @@ let make = ( let startMonth = (startDate != "" ? (startDate->DayJs.getDayJsForString).format(. "MM") : "") ->Belt.Int.fromString - ->Option.getWithDefault(currentMonth) - let startYearDiff = year - startYear->Belt.Int.fromString->Option.getWithDefault(2022) + ->Option.getOr(currentMonth) + let startYearDiff = year - startYear->Belt.Int.fromString->Option.getOr(2022) let startIndex = 12 * startYearDiff + (currentMonth - startMonth) @@ -433,8 +429,8 @@ let make = ( let endMonth = (endDate != "" ? (endDate->DayJs.getDayJsForString).format(. "MM") : "") ->Belt.Int.fromString - ->Option.getWithDefault(currentMonth) - let endYearDiff = year - endYear->Belt.Int.fromString->Option.getWithDefault(2022) + ->Option.getOr(currentMonth) + let endYearDiff = year - endYear->Belt.Int.fromString->Option.getOr(2022) let endIndex = 12 * endYearDiff + (currentMonth - endMonth) @@ -449,7 +445,7 @@ let make = ( let windowIndex = totalMonths - index->LogicUtils.getInt("index", 0) - 1 let newMonth = DayJs.getDayJs().subtract(. windowIndex, "month").month(.) let newYear = DayJs.getDayJs().subtract(. windowIndex, "month").year(.) - let updatedMonth = months->Belt.Array.get(newMonth)->Option.getWithDefault(Jan) + let updatedMonth = months->Array.get(newMonth)->Option.getOr(Jan) // get first day let firstDay = Js.Date.getDay( @@ -472,7 +468,7 @@ let make = ( | Dec => 31 } // creating row info - let dummyRow = Belt.Array.make(6, Belt.Array.make(7, "")) + let dummyRow = Array.make(~length=6, Array.make(~length=7, "")) let rowMapper = (row, indexRow) => { Array.mapWithIndex(row, (_item, index) => { diff --git a/src/components/NewCalendarList.res b/src/components/NewCalendarList.res index 8ebd06d92..e5da0343b 100644 --- a/src/components/NewCalendarList.res +++ b/src/components/NewCalendarList.res @@ -120,7 +120,7 @@ let make = ( // check whether month and date has value let getMonthFromFloat = value => { let valueInt = value->Belt.Float.toInt - months->Belt.Array.get(valueInt)->Option.getWithDefault(Jan) + months->Array.get(valueInt)->Option.getOr(Jan) } let getMonthInFloat = mon => { Array.indexOf(months, mon)->Belt.Float.fromInt @@ -138,7 +138,7 @@ let make = ( Js.Date.makeWithYM(~year=startYear, ~month=startMonth, ()) ) - let dummyRow = Belt.Array.make(count, 1) + let dummyRow = Array.make(~length=count, 1)
{dummyRow diff --git a/src/components/NewCalendarTimeInput.res b/src/components/NewCalendarTimeInput.res index 8a8b88af9..f4b8183d1 100644 --- a/src/components/NewCalendarTimeInput.res +++ b/src/components/NewCalendarTimeInput.res @@ -135,20 +135,18 @@ let make = ( let setFromTimeDropdown = val => { let fromTimeArr = val->String.split(" ") - let fromTime = `${fromTimeArr - ->Belt.Array.get(0) - ->Option.getWithDefault("12:00")}:00 ${fromTimeArr - ->Belt.Array.get(1) - ->Option.getWithDefault("AM")}` + let fromTime = `${fromTimeArr->Array.get(0)->Option.getOr("12:00")}:00 ${fromTimeArr + ->Array.get(1) + ->Option.getOr("AM")}` setFromTime(_ => fromTime->String.toUpperCase) } let setToTimeDropdown = val => { let toTimeArr = val->String.split(" ") - let toTime = `${toTimeArr->Belt.Array.get(0)->Option.getWithDefault("11:59")}:00 ${toTimeArr - ->Belt.Array.get(1) - ->Option.getWithDefault("PM")}` + let toTime = `${toTimeArr->Array.get(0)->Option.getOr("11:59")}:00 ${toTimeArr + ->Array.get(1) + ->Option.getOr("PM")}` settoTime(_ => toTime->String.toUpperCase) } diff --git a/src/components/NewPagination.res b/src/components/NewPagination.res index 54502b2fa..2662e23d6 100644 --- a/src/components/NewPagination.res +++ b/src/components/NewPagination.res @@ -63,7 +63,7 @@ let make = (~resultsPerPage, ~totalResults, ~currentPage, ~paginate, ~btnCount=4 } }) ->React.array} - {if currentPage < Belt.Array.length(pageNumbers) { + {if currentPage < Array.length(pageNumbers) { paginate(currentPage + 1)} /> } else { paginate(currentPage + 1)} /> diff --git a/src/components/OrderUtils.res b/src/components/OrderUtils.res index 2f51a676a..094079a17 100644 --- a/src/components/OrderUtils.res +++ b/src/components/OrderUtils.res @@ -42,7 +42,7 @@ module DisplayKeyValueParams = { let textColor = textColor === "" ? "text-jp-gray-900 dark:text-white" : textColor - let description = heading.description->Option.getWithDefault("") + let description = heading.description->Option.getOr("") { diff --git a/src/components/Pagination.res b/src/components/Pagination.res index 7f890cda5..fdb7fc82c 100644 --- a/src/components/Pagination.res +++ b/src/components/Pagination.res @@ -33,7 +33,7 @@ let make = (~resultsPerPage, ~totalResults, ~currentPage, ~paginate, ~btnCount=4 rangeNum->Array.forEach(ele => { ranges->Array.push((ele - 9)->Belt.Int.toString ++ "-" ++ ele->Belt.Int.toString)->ignore }) - let lastNum = rangeNum->Belt.Array.get(Array.length(rangeNum) - 1)->Option.getWithDefault(0) + let lastNum = rangeNum->Array.get(Array.length(rangeNum) - 1)->Option.getOr(0) if totalResults > lastNum { let start = lastNum + (totalResults - lastNum) start === totalResults @@ -91,7 +91,7 @@ let make = (~resultsPerPage, ~totalResults, ~currentPage, ~paginate, ~btnCount=4 buttonType onClick={_evt => paginate(currentPage + 1)} customButtonStyle="!h-10" - buttonState={if currentPage < Belt.Array.length(pageNumbers) { + buttonState={if currentPage < Array.length(pageNumbers) { Normal } else { Disabled @@ -110,7 +110,7 @@ let make = (~resultsPerPage, ~totalResults, ~currentPage, ~paginate, ~btnCount=4 name: "dummy-name", onBlur: _ev => (), onChange: _evt => { - let val = ranges->Belt.Array.get(_evt->formEventToInt - 1)->Option.getWithDefault("1-10") + let val = ranges->Array.get(_evt->formEventToInt - 1)->Option.getOr("1-10") setDropDownVal(_ => val) paginate(_evt->formEventToInt) }, diff --git a/src/components/Paginator.res b/src/components/Paginator.res index e66d57596..19538e834 100644 --- a/src/components/Paginator.res +++ b/src/components/Paginator.res @@ -48,7 +48,7 @@ let make = ( onBlur: _ev => (), onChange: ev => { setResultsPerPage(_ => { - ev->Identity.formReactEventToString->Belt.Int.fromString->Option.getWithDefault(15) + ev->Identity.formReactEventToString->Belt.Int.fromString->Option.getOr(15) }) }, onFocus: _ev => (), diff --git a/src/components/PopUpContainer.res b/src/components/PopUpContainer.res index c70bfd018..d2fb23edd 100644 --- a/src/components/PopUpContainer.res +++ b/src/components/PopUpContainer.res @@ -3,7 +3,7 @@ open PopUpState @react.component let make = (~children) => { let (openPopUps, setOpenPopUp) = Recoil.useRecoilState(PopUpState.openPopUp) - let activePopUp = openPopUps->Belt.Array.get(0) + let activePopUp = openPopUps->Array.get(0) let popUp = switch activePopUp { | Some(popUp) => { let handleConfirm = ev => { diff --git a/src/components/RangeSlider.res b/src/components/RangeSlider.res index 2089bf8b0..2b24fc6b9 100644 --- a/src/components/RangeSlider.res +++ b/src/components/RangeSlider.res @@ -143,7 +143,7 @@ let make = ( max={max->Belt.Float.toString} onBlur={ev => { let minVal = minSlideVal - let maxSliderValue = maxSlide.value->Js.Json.decodeNumber->Option.getWithDefault(0.) + let maxSliderValue = maxSlide.value->Js.Json.decodeNumber->Option.getOr(0.) if minVal >= min && minVal < maxSliderValue { setHasError(((_, max)) => (false, max)) minSlide.onChange(ev->Identity.anyTypeToReactEvent) @@ -160,7 +160,7 @@ let make = ( let keyCode = ev->ReactEvent.Keyboard.keyCode if key === "Enter" || keyCode === 13 { let minVal = minSlideVal - let maxSliderValue = maxSlide.value->Js.Json.decodeNumber->Option.getWithDefault(0.) + let maxSliderValue = maxSlide.value->Js.Json.decodeNumber->Option.getOr(0.) if minVal >= min && minVal <= maxSliderValue { setHasError(((_, max)) => (false, max)) minSlide.onChange(ev->Identity.anyTypeToReactEvent) @@ -181,7 +181,7 @@ let make = ( max={max->Belt.Float.toString} onBlur={ev => { let maxVal = maxSlideVal - let minSliderValue = minSlide.value->Js.Json.decodeNumber->Option.getWithDefault(0.) + let minSliderValue = minSlide.value->Js.Json.decodeNumber->Option.getOr(0.) if maxVal <= max && maxVal > minSliderValue { setHasError(((min, _)) => (min, false)) maxSlide.onChange(ev->Identity.anyTypeToReactEvent) @@ -198,7 +198,7 @@ let make = ( let keyCode = ev->ReactEvent.Keyboard.keyCode let maxVal = maxSlideVal - let minSliderValue = minSlide.value->Js.Json.decodeNumber->Option.getWithDefault(0.) + let minSliderValue = minSlide.value->Js.Json.decodeNumber->Option.getOr(0.) if key === "Enter" || keyCode === 13 { if maxVal <= max && maxVal >= minSliderValue { setHasError(((min, _)) => (min, false)) diff --git a/src/components/ReactWindowTable.res b/src/components/ReactWindowTable.res index 0dea0870e..d6809b555 100644 --- a/src/components/ReactWindowTable.res +++ b/src/components/ReactWindowTable.res @@ -142,8 +142,8 @@ module NewCell = { "w-24" } else { columnWidthArr - ->Belt.Array.get(cellIndex) - ->Option.getWithDefault(`${cellIndex === 0 && customSerialNoColumn ? "w-24" : "w-64"}`) + ->Array.get(cellIndex) + ->Option.getOr(`${cellIndex === 0 && customSerialNoColumn ? "w-24" : "w-64"}`) } let overflowStyle = cellIndex === colsLen ? "overflow-hidden" : "" @@ -249,8 +249,7 @@ module ReactWindowTableComponent = { switch actualData { | Some(actualData) => switch getRowDetails { - | Some(fn) => - fn(actualData->Belt.Array.get(rowIndex)->Option.getWithDefault(Js.Nullable.null)) + | Some(fn) => fn(actualData->Array.get(rowIndex)->Option.getOr(Js.Nullable.null)) | None => React.null } | None => React.null @@ -294,7 +293,7 @@ module ReactWindowTableComponent = { } acc }) - let colFilt = columnFilterRow->Option.getWithDefault([]) + let colFilt = columnFilterRow->Option.getOr([]) let colFilter = showCheckBox ? [TextFilter("")]->Array.concat(colFilt) : colFilt let arr = switch columnWidth { | Some(arr) => arr @@ -321,8 +320,8 @@ module ReactWindowTableComponent = { "w-24" } else { arr - ->Belt.Array.get(i) - ->Option.getWithDefault(`${isFirstCol && customSerialNoColumn ? "w-24" : "w-64"}`) + ->Array.get(i) + ->Option.getOr(`${isFirstCol && customSerialNoColumn ? "w-24" : "w-64"}`) } let roundedClass = if isFirstCol { @@ -370,14 +369,13 @@ module ReactWindowTableComponent = { Option.isSome}>
Option.getWithDefault("")} + description={item.description->Option.getOr("")} toolTipPosition={ToolTip.Bottom} />
- Option.getWithDefault(false)}> + Option.getOr(false)}>
Option.isSome}>
- {React.string(item.data->Option.getWithDefault(""))} + {React.string(item.data->Option.getOr(""))}
@@ -431,7 +429,7 @@ module ReactWindowTableComponent = {
{ let len = colFilter->Array.length - switch colFilter->Belt.Array.get(i) { + switch colFilter->Array.get(i) { | Some(fitlerRows) => LogicUtils.getInt("index", 0) getIndex(rowIndex) - let item = rowInfo->Belt.Array.get(rowIndex)->Option.getWithDefault([]) + let item = rowInfo->Array.get(rowIndex)->Option.getOr([]) let style = index->LogicUtils.getJsonObjectFromDict("style")->Identity.jsonToReactDOMStyle @@ -536,7 +534,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) @@ -600,8 +598,8 @@ let sortArray = (originalData, key, sortOrder: Table.sortOrder) => { } let sortedArrayByOrder = { let _ = originalData->Js.Array2.sortInPlaceWith((i1, i2) => { - let item1 = i1->Js.Json.stringifyAny->Option.getWithDefault("")->LogicUtils.safeParse - let item2 = i2->Js.Json.stringifyAny->Option.getWithDefault("")->LogicUtils.safeParse + let item1 = i1->Js.Json.stringifyAny->Option.getOr("")->LogicUtils.safeParse + let item2 = i2->Js.Json.stringifyAny->Option.getOr("")->LogicUtils.safeParse // flatten items and get data let val1 = item1->Js.Json.decodeObject->Option.flatMap(dict => dict->Dict.get(key)) @@ -751,8 +749,7 @@ let make = ( (isFilterOpen, setIsFilterOpen) }, (isFilterOpen, setIsFilterOpen)) - let heading = - visibleColumns->Option.getWithDefault(entity.defaultColumns)->Array.map(entity.getHeading) + let heading = visibleColumns->Option.getOr(entity.defaultColumns)->Array.map(entity.getHeading) if showSerialNumber { heading @@ -785,7 +782,7 @@ let make = ( if tableLocalFilter { let columnFilterRow = visibleColumns - ->Option.getWithDefault(entity.defaultColumns) + ->Option.getOr(entity.defaultColumns) ->Array.map(item => { let headingEntity = entity.getHeading(item) let key = headingEntity.key @@ -802,9 +799,9 @@ let make = ( ) switch columToConsider { | Some(allCol) => - newValues->Belt.Array.forEach( + newValues->Array.forEach( rows => { - allCol->Belt.Array.forEach( + allCol->Array.forEach( item => { let heading = {item->entity.getHeading} let key = heading.key @@ -837,29 +834,25 @@ let make = ( | None => () } - let filterValueArray = dictArrObj->Dict.get(key)->Option.getWithDefault([]) + let filterValueArray = dictArrObj->Dict.get(key)->Option.getOr([]) switch dataType { | DropDown => Table.DropDownFilter(key, filterValueArray) // TextDropDownColumn | LabelType | TextType => Table.TextFilter(key) | MoneyType | NumericType | ProgressType => { let newArr = filterValueArray - ->Array.map(item => item->Js.Json.decodeNumber->Option.getWithDefault(0.)) + ->Array.map(item => item->Js.Json.decodeNumber->Option.getOr(0.)) ->Js.Array2.sortInPlaceWith(LogicUtils.numericArraySortComperator) let lengthOfArr = newArr->Array.length if lengthOfArr >= 2 { Table.Range( key, - newArr[0]->Option.getWithDefault(0.), - newArr[lengthOfArr - 1]->Option.getWithDefault(0.), + newArr[0]->Option.getOr(0.), + newArr[lengthOfArr - 1]->Option.getOr(0.), ) } else if lengthOfArr >= 1 { - Table.Range( - key, - newArr[0]->Option.getWithDefault(0.), - newArr[0]->Option.getWithDefault(0.), - ) + Table.Range(key, newArr[0]->Option.getOr(0.), newArr[0]->Option.getOr(0.)) } else { Table.Range(key, 0.0, 0.0) } @@ -929,7 +922,7 @@ let make = ( } None }, [selectAllCheckBox]) - let sNoArr = Dict.get(columnFilter, "s_no")->Option.getWithDefault([]) + let sNoArr = Dict.get(columnFilter, "s_no")->Option.getOr([]) // filtering for SNO let rows = filteredData @@ -938,12 +931,12 @@ let make = ( | Some(item) => { let visibleCell = visibleColumns - ->Option.getWithDefault(entity.defaultColumns) + ->Option.getOr(entity.defaultColumns) ->Array.map(colType => { entity.getCell(item, colType) }) - let startPoint = sNoArr->Belt.Array.get(0)->Option.getWithDefault(1.->Js.Json.number) - let endPoint = sNoArr->Belt.Array.get(1)->Option.getWithDefault(1.->Js.Json.number) + let startPoint = sNoArr->Array.get(0)->Option.getOr(1.->Js.Json.number) + let endPoint = sNoArr->Array.get(1)->Option.getOr(1.->Js.Json.number) let jsonIndex = (index + 1)->Belt.Int.toFloat->Js.Json.number sNoArr->Array.length > 0 ? { @@ -955,7 +948,7 @@ let make = ( | None => [] } let getIdFromJson = json => { - let selectedPlanDict = json->Js.Json.decodeObject->Option.getWithDefault(Dict.make()) + let selectedPlanDict = json->Js.Json.decodeObject->Option.getOr(Dict.make()) selectedPlanDict->LogicUtils.getString("id", "") } let setIsSelected = isSelected => { @@ -1016,8 +1009,7 @@ let make = ( let dataExists = rows->Array.length > 0 let heading = heading->Array.mapWithIndex((head, index) => { - let getValue = row => - row->Belt.Array.get(index)->Belt.Option.mapWithDefault("", Table.getTableCellValue) + let getValue = row => row->Array.get(index)->Option.mapOr("", Table.getTableCellValue) let default = switch rows[0] { | Some(ele) => getValue(ele) diff --git a/src/components/RemoteFilter.res b/src/components/RemoteFilter.res index 7bce6fb6e..8168fc130 100644 --- a/src/components/RemoteFilter.res +++ b/src/components/RemoteFilter.res @@ -59,7 +59,7 @@ module ModalUI = { className="overflow-auto" style={ReactDOMStyle.make(~maxHeight="calc(100vh - 15rem)", ())}>
- {switch fieldsFromOption->Belt.Array.get(0) { + {switch fieldsFromOption->Array.get(0) { | Some(field) =>
- {switch fieldsFromOption->Belt.Array.get(1) { + {switch fieldsFromOption->Array.get(1) { | Some(field) => | None => React.null }} - {switch fieldsFromOption->Belt.Array.get(3) { + {switch fieldsFromOption->Array.get(3) { | Some(field) =>
- {switch fieldsFromOption->Belt.Array.get(2) { + {switch fieldsFromOption->Array.get(2) { | Some(field) => Js.Json.decodeObject - ->Option.getWithDefault(Dict.make()) + ->Option.getOr(Dict.make()) ->Dict.toArray ->Belt.Array.keepMap(entry => { let (key, value) = entry @@ -162,7 +162,7 @@ module ClearFilters = { let hasExtraFilters = React.useMemo2(() => { formState.initialValues ->Js.Json.decodeObject - ->Option.getWithDefault(Dict.make()) + ->Option.getOr(Dict.make()) ->Dict.toArray ->Array.filter(entry => { let (key, value) = entry @@ -208,7 +208,7 @@ module AnalyticsClearFilters = { let searchStr = formState.values ->Js.Json.decodeObject - ->Option.getWithDefault(Dict.make()) + ->Option.getOr(Dict.make()) ->Dict.toArray ->Belt.Array.keepMap(entry => { let (key, value) = entry @@ -232,7 +232,7 @@ module AnalyticsClearFilters = { let hasExtraFilters = React.useMemo2(() => { formState.initialValues ->Js.Json.decodeObject - ->Option.getWithDefault(Dict.make()) + ->Option.getOr(Dict.make()) ->Dict.toArray ->Array.filter(entry => { let (key, value) = entry @@ -331,7 +331,7 @@ module AutoSubmitter = { React.useEffect1(() => { if formState.dirty { let defaultFieldsHaveChanged = defaultFilterKeys->Array.some(key => { - formState.dirtyFields->Dict.get(key)->Option.getWithDefault(false) + formState.dirtyFields->Dict.get(key)->Option.getOr(false) }) // if autoApply is false then still autoApply can work for the default filters @@ -350,7 +350,7 @@ module AutoSubmitter = { let getStrFromJson = (key, val) => { switch val->Js.Json.classify { | JSONString(str) => str - | JSONArray(array) => array->Array.length > 0 ? `[${array->Array.joinWith(",")}]` : "" + | JSONArray(array) => array->Array.length > 0 ? `[${array->Array.joinWithUnsafe(",")}]` : "" | JSONNumber(num) => key === "offset" ? "0" : num->Belt.Float.toInt->string_of_int | _ => "" } @@ -399,7 +399,7 @@ module ApplyFilterButton = { ->Dict.toArray ->Array.map(entry => { let (key, value) = entry - let inputField = inputFieldsDict->Dict.get(key)->Option.getWithDefault(defaultinputField) + let inputField = inputFieldsDict->Dict.get(key)->Option.getOr(defaultinputField) let formattor = inputField.format let value = switch formattor { | Some(fn) => fn(. ~value, ~name=key) @@ -462,7 +462,7 @@ module FilterModal = { let formCurrentValues = formState.values->LogicUtils.getDictFromJsonObject let sortedSelectedFiltersList = React.useMemo1(_ => { let selectedFiltersListWithVal = selectedFiltersList->Array.filter(item => { - let inputName = item.inputNames->Belt.Array.get(0)->Option.getWithDefault("") + let inputName = item.inputNames->Array.get(0)->Option.getOr("") let selectedNo = formCurrentValues->LogicUtils.getStrArray(inputName)->Array.length->Belt.Int.toString selectedNo !== "0" @@ -477,7 +477,7 @@ module FilterModal = {
{sortedSelectedFiltersList ->Array.mapWithIndex((item, i) => { - let inputName = item.inputNames->Belt.Array.get(0)->Option.getWithDefault("") + let inputName = item.inputNames->Array.get(0)->Option.getOr("") let selectedNo = formCurrentValues->LogicUtils.getStrArray(inputName)->Array.length->Belt.Int.toString let textcolor = @@ -545,9 +545,7 @@ let make = ( ~revampedFilter=false, ) => { let {query} = React.useContext(FilterContext.filterContext) - let alreadySelectedFiltersUserpref = `remote_filters_selected_keys_${tableName->Option.getWithDefault( - "", - )}` + let alreadySelectedFiltersUserpref = `remote_filters_selected_keys_${tableName->Option.getOr("")}` let {addConfig} = React.useContext(UserPrefContext.userPrefContext) let syncIcon = "sync" @@ -565,7 +563,7 @@ let make = ( let updatedSelectedList = React.useMemo1(() => { selectedFiltersList ->Array.map(item => { - item.inputNames->Belt.Array.get(0)->Option.getWithDefault("") + item.inputNames->Array.get(0)->Option.getOr("") }) ->Js.Json.stringArray }, [selectedFiltersList]) @@ -593,7 +591,7 @@ let make = ( let countSelectedFilters = React.useMemo1(() => { Dict.keysToArray( - initialValueJson->Js.Json.decodeObject->Option.getWithDefault(Dict.make()), + initialValueJson->Js.Json.decodeObject->Option.getOr(Dict.make()), )->Array.length }, [initialValueJson]) @@ -672,8 +670,7 @@ let make = ( let defaultEntityOptionType: EntityType.optionType< 't, > = EntityType.getDefaultEntityOptionType() - let optionObj = - remoteOptions[optionObjIdx]->Option.getWithDefault(defaultEntityOptionType) + let optionObj = remoteOptions[optionObjIdx]->Option.getOr(defaultEntityOptionType) let optionObjUrlKey = optionObj.urlKey if !(popupUrlKeyArr->Array.includes(optionObjUrlKey)) { Array.push(localSelectedFiltersList, optionObj.field) @@ -695,8 +692,7 @@ let make = ( }, [searchParams]) let onSubmit = (values, _) => { - let obj = - values->Js.Json.decodeObject->Option.getWithDefault(Dict.make())->Dict.toArray->Dict.fromArray + let obj = values->Js.Json.decodeObject->Option.getOr(Dict.make())->Dict.toArray->Dict.fromArray let flattendDict = obj->Js.Json.object_->JsonFlattenUtils.flattenObject(false) let localFilterDict = localFilterJson->JsonFlattenUtils.flattenObject(false) @@ -744,7 +740,7 @@ let make = ( let defaultEntityOptionType: EntityType.optionType< 't, > = EntityType.getDefaultEntityOptionType() - let optionObj = optionObjArry[0]->Option.getWithDefault(defaultEntityOptionType) + let optionObj = optionObjArry[0]->Option.getOr(defaultEntityOptionType) let _ = Array.push(localSelectedFiltersList, optionObj.field) let _a = Array.push(localCheckedFilters, value) }) @@ -770,9 +766,9 @@ let make = ( let finalFieldList = selectedFiltersList->Array.filter(val => { val.inputNames - ->Belt.Array.get(0) + ->Array.get(0) ->Belt.Option.map(name => !Array.includes(toBeRemoved, name)) - ->Option.getWithDefault(false) + ->Option.getOr(false) }) let filtersAfterRemoving = checkedFilters->Array.filter(val => !Array.includes(toBeRemoved, val)) @@ -781,7 +777,7 @@ let make = ( initialValueJson ->Js.Json.decodeObject ->Belt.Option.map(Dict.toArray) - ->Option.getWithDefault([]) + ->Option.getOr([]) ->Array.filter(entry => { let (key, _value) = entry !Array.includes(toBeRemoved, key) diff --git a/src/components/RemoteFiltersUtils.res b/src/components/RemoteFiltersUtils.res index 0edff3de0..2ff5cbe7a 100644 --- a/src/components/RemoteFiltersUtils.res +++ b/src/components/RemoteFiltersUtils.res @@ -64,7 +64,7 @@ let getFinalDict = ( | JSONArray(stringValueArr) => stringValueArr ->Array.map(ele => { - getExpectedType(ele->Js.Json.decodeString->Option.getWithDefault("")) + getExpectedType(ele->Js.Json.decodeString->Option.getOr("")) }) ->Js.Json.array | JSONString(ele) => getExpectedType(ele) @@ -83,13 +83,10 @@ let getFinalDict = ( if !isSearchKeyArray { let key = filterDict - ->LogicUtils.getString(dropdownSearchKeyValueNames[0]->Option.getWithDefault(""), "") + ->LogicUtils.getString(dropdownSearchKeyValueNames[0]->Option.getOr(""), "") ->LogicUtils.toCamelCase let value = - filterDict->LogicUtils.getString( - dropdownSearchKeyValueNames[1]->Option.getWithDefault(""), - "", - ) + filterDict->LogicUtils.getString(dropdownSearchKeyValueNames[1]->Option.getOr(""), "") if value !== "" { let isformat = searchkeysDict !== Dict.make() let value = if isformat { @@ -110,17 +107,14 @@ let getFinalDict = ( } else { let key = filterDict - ->LogicUtils.getArrayFromDict( - dropdownSearchKeyValueNames[0]->Option.getWithDefault(""), - [], - ) + ->LogicUtils.getArrayFromDict(dropdownSearchKeyValueNames[0]->Option.getOr(""), []) ->Array.map(item => item->LogicUtils.getStringFromJson("")->LogicUtils.toCamelCase) let value = filterDict - ->LogicUtils.getString(dropdownSearchKeyValueNames[1]->Option.getWithDefault(""), "") + ->LogicUtils.getString(dropdownSearchKeyValueNames[1]->Option.getOr(""), "") ->String.split(", ") value->Array.forEachWithIndex((value, indx) => { - let key = key->Array.length > indx ? key[indx]->Option.getWithDefault("") : "" + let key = key->Array.length > indx ? key[indx]->Option.getOr("") : "" if value !== "" && key != "" { let isformat = searchkeysDict !== Dict.make() let value = if isformat { @@ -157,7 +151,7 @@ let getFinalDict = ( let getStrFromJson = (key, val) => { switch val->Js.Json.classify { | JSONString(str) => str - | JSONArray(array) => array->Array.length > 0 ? `[${array->Array.joinWith(",")}]` : "" + | JSONArray(array) => array->Array.length > 0 ? `[${array->Array.joinWithUnsafe(",")}]` : "" | JSONNumber(num) => key === "offset" ? "0" : num->Belt.Float.toInt->string_of_int | _ => "" } @@ -181,8 +175,8 @@ let getInitialValuesFromUrl = ( splitUrlArray->Array.forEach(filterKeyVal => { let splitArray = String.split(filterKeyVal, "=") - let keyStartIndex = String.lastIndexOf(splitArray[0]->Option.getWithDefault(""), "-") + 1 - let key = String.sliceToEnd(splitArray[0]->Option.getWithDefault(""), ~start=keyStartIndex) + let keyStartIndex = String.lastIndexOf(splitArray[0]->Option.getOr(""), "-") + 1 + let key = String.sliceToEnd(splitArray[0]->Option.getOr(""), ~start=keyStartIndex) Array.push(keyList, key)->ignore splitArray->Js.Array2.shift->ignore let value = splitArray->Array.joinWith("=") @@ -234,23 +228,17 @@ let getLocalFiltersData = ( let valueList = [] splitUrlArray->Array.forEach(filterKeyVal => { let splitArray = String.split(filterKeyVal, "=") - let keyStartIndex = String.lastIndexOf(splitArray[0]->Option.getWithDefault(""), `-`) + 1 - let key = String.sliceToEnd(splitArray[0]->Option.getWithDefault(""), ~start=keyStartIndex) + let keyStartIndex = String.lastIndexOf(splitArray[0]->Option.getOr(""), `-`) + 1 + let key = String.sliceToEnd(splitArray[0]->Option.getOr(""), ~start=keyStartIndex) Array.push(keyList, key)->ignore - Array.push(valueList, splitArray[1]->Option.getWithDefault(""))->ignore + Array.push(valueList, splitArray[1]->Option.getOr(""))->ignore }) let dateRange = dateRangeFilterDict->LogicUtils.getArrayFromDict("dateRange", []) let startKey = - dateRange - ->Belt.Array.get(0) - ->Option.getWithDefault(""->Js.Json.string) - ->LogicUtils.getStringFromJson("") + dateRange->Array.get(0)->Option.getOr(""->Js.Json.string)->LogicUtils.getStringFromJson("") let endKey = - dateRange - ->Belt.Array.get(1) - ->Option.getWithDefault(""->Js.Json.string) - ->LogicUtils.getStringFromJson("") + dateRange->Array.get(1)->Option.getOr(""->Js.Json.string)->LogicUtils.getStringFromJson("") let (keyList, valueList) = if ( dateRangeFilterDict != Dict.make() && @@ -259,8 +247,8 @@ let getLocalFiltersData = ( keyList->Array.includes(startKey) && keyList->Array.includes(endKey) ) { - let start_Date = valueList[keyList->Array.indexOf(startKey)]->Option.getWithDefault("") - let end_Date = valueList[keyList->Array.indexOf(endKey)]->Option.getWithDefault("") + let start_Date = valueList[keyList->Array.indexOf(startKey)]->Option.getOr("") + let end_Date = valueList[keyList->Array.indexOf(endKey)]->Option.getOr("") let keyList = keyList->Array.filter(item => item != startKey && item != endKey) let valueList = valueList->Array.filter(item => item != start_Date && item != end_Date) keyList->Array.push(startKey)->ignore @@ -277,7 +265,7 @@ let getLocalFiltersData = ( field.inputNames->Array.forEach( name => { if name === key { - let value = valueList[idx]->Option.getWithDefault("") + let value = valueList[idx]->Option.getOr("") if String.includes(value, "[") { let str = String.slice(~start=1, ~end=value->String.length - 1, value) let splitArray = String.split(str, ",") @@ -303,7 +291,7 @@ let getLocalFiltersData = ( if fieldName === key { res.contents = switch localFilter { | Some(localFilter) => - localFilter(res.contents, Js.Json.string(valueList[idx]->Option.getWithDefault(""))) + localFilter(res.contents, Js.Json.string(valueList[idx]->Option.getOr(""))) | None => res.contents } } diff --git a/src/components/SearchInput.res b/src/components/SearchInput.res index d7b7fa107..cf977ae47 100644 --- a/src/components/SearchInput.res +++ b/src/components/SearchInput.res @@ -21,7 +21,7 @@ let make = ( let showPopUp = PopUpState.useShowPopUp() let defaultRef = React.useRef(Js.Nullable.null) - let searchRef = searchRef->Option.getWithDefault(defaultRef) + let searchRef = searchRef->Option.getOr(defaultRef) let handleSearch = e => { setPrevVal(_ => inputText) diff --git a/src/components/SelectBox.res b/src/components/SelectBox.res index 77b6325a9..429c953b1 100644 --- a/src/components/SelectBox.res +++ b/src/components/SelectBox.res @@ -120,8 +120,7 @@ module ListItem = { "" } - let labelStyle = - customLabelStyle->Option.isSome ? customLabelStyle->Option.getWithDefault("") : "" + let labelStyle = customLabelStyle->Option.isSome ? customLabelStyle->Option.getOr("") : "" let onToggleSelect = val => { if !isDisabled { @@ -380,12 +379,12 @@ let makeNonOptional = (dropdownOption: dropdownOption): dropdownOptionWithoutOpt { label: dropdownOption.label, value: dropdownOption.value, - isDisabled: dropdownOption.isDisabled->Option.getWithDefault(false), - icon: dropdownOption.icon->Option.getWithDefault(NoIcon), + isDisabled: dropdownOption.isDisabled->Option.getOr(false), + icon: dropdownOption.icon->Option.getOr(NoIcon), description: dropdownOption.description, - iconStroke: dropdownOption.iconStroke->Option.getWithDefault(""), - textColor: dropdownOption.textColor->Option.getWithDefault(""), - optGroup: dropdownOption.optGroup->Option.getWithDefault("-"), + iconStroke: dropdownOption.iconStroke->Option.getOr(""), + textColor: dropdownOption.textColor->Option.getOr(""), + optGroup: dropdownOption.optGroup->Option.getOr("-"), } } @@ -511,7 +510,7 @@ module BaseSelect = { if !isDisabled { let data = if Array.includes(saneValue, itemDataValue) { let values = - deselectDisable->Option.getWithDefault(false) + deselectDisable->Option.getOr(false) ? saneValue : saneValue->Array.filter(x => x !== itemDataValue) onItemSelect(e, itemDataValue)->ignore @@ -571,13 +570,12 @@ module BaseSelect = { } else { `${minWidth} ${dropdownCustomWidth}` } - let textIconPresent = - options->Array.some(op => op.icon->Option.getWithDefault(NoIcon) !== NoIcon) + let textIconPresent = options->Array.some(op => op.icon->Option.getOr(NoIcon) !== NoIcon) let _ = if sortingBasedOnDisabled { options->Js.Array2.sortInPlaceWith((m1, m2) => { - let m1Disabled = m1.isDisabled->Option.getWithDefault(false) - let m2Disabled = m2.isDisabled->Option.getWithDefault(false) + let m1Disabled = m1.isDisabled->Option.getOr(false) + let m2Disabled = m2.isDisabled->Option.getOr(false) if m1Disabled === m2Disabled { 0 } else if m1Disabled { @@ -826,11 +824,11 @@ module BaseSelect = { ->Array.mapWithIndex((item, indx) => { let valueToConsider = item.value let index = Array.findIndex(saneValue, sv => sv === valueToConsider) - let isPrevSelected = switch filteredOptions->Belt.Array.get(indx - 1) { + let isPrevSelected = switch filteredOptions->Array.get(indx - 1) { | Some(prevItem) => Array.findIndex(saneValue, sv => sv === prevItem.value) > -1 | None => false } - let isNextSelected = switch filteredOptions->Belt.Array.get(indx + 1) { + let isNextSelected = switch filteredOptions->Array.get(indx + 1) { | Some(nextItem) => Array.findIndex(saneValue, sv => sv === nextItem.value) > -1 | None => false } @@ -934,8 +932,7 @@ module BaseSelectButton = { let searchRef = React.useRef(Js.Nullable.null) let onItemClick = (itemData, _ev) => { if !disableSelect { - let isSelected = - value->Js.Json.decodeString->Belt.Option.mapWithDefault(false, str => itemData === str) + let isSelected = value->Js.Json.decodeString->Option.mapOr(false, str => itemData === str) if isSelected && !deselectDisable { onSelect("") @@ -1161,7 +1158,7 @@ let getHashMappedOptionValues = (options: array) if acc->Dict.get(ele.optGroup)->Option.isNone { acc->Dict.set(ele.optGroup, [ele]) } else { - acc->Dict.get(ele.optGroup)->Option.getWithDefault([])->Array.push(ele)->ignore + acc->Dict.get(ele.optGroup)->Option.getOr([])->Array.push(ele)->ignore } acc }) @@ -1225,8 +1222,7 @@ module BaseRadio = { let hashMappedOptions = getHashMappedOptionValues(options) let isNonGrouped = - hashMappedOptions->Dict.get("-")->Option.getWithDefault([])->Array.length === - options->Array.length + hashMappedOptions->Dict.get("-")->Option.getOr([])->Array.length === options->Array.length let (optgroupKeys, setOptgroupKeys) = React.useState(_ => getSortedKeys(hashMappedOptions)) @@ -1237,7 +1233,7 @@ module BaseRadio = { }, [searchString]) OutsideClick.useOutsideClick( - ~refs={ArrayOfRef([dropdownRef->Option.getWithDefault(React.useRef(Js.Nullable.null))])}, + ~refs={ArrayOfRef([dropdownRef->Option.getOr(React.useRef(Js.Nullable.null))])}, ~isActive=showDropDown, ~callback=() => { setSearchString(_ => "") @@ -1246,8 +1242,7 @@ module BaseRadio = { ) let onItemClick = (itemData, isDisabled, _ev) => { if !isDisabled { - let isSelected = - value->Js.Json.decodeString->Belt.Option.mapWithDefault(false, str => itemData === str) + let isSelected = value->Js.Json.decodeString->Option.mapOr(false, str => itemData === str) if isSelected && !deselectDisable { setSelectedString(_ => "") @@ -1403,7 +1398,7 @@ module BaseRadio = { Dict.get(ele) - ->Option.getWithDefault([])} + ->Option.getOr([])} value descriptionOnHover isDropDown @@ -1638,7 +1633,7 @@ module BaseDropdown = { BottomMiddle }->Some }) - ->Option.getWithDefault(BottomMiddle) + ->Option.getOr(BottomMiddle) } }, [showDropDown]) @@ -1686,7 +1681,7 @@ module BaseDropdown = { color: condition ? BadgeBlue : NoBadge, } }, [newInputSelect.value]) - let widthClass = isMobileView ? "w-full" : dropdownCustomWidth->Option.getWithDefault("") + let widthClass = isMobileView ? "w-full" : dropdownCustomWidth->Option.getOr("") let optionsElement = if allowMultiSelect {