Skip to content

Commit

Permalink
chore: Rescript core version upgrade (#293)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pritish Budhiraja authored Jan 29, 2024
1 parent 4c0d56b commit 2d03f43
Show file tree
Hide file tree
Showing 202 changed files with 1,043 additions and 1,274 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/components/AdvancedSearchComponent.res
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
26 changes: 12 additions & 14 deletions src/components/Button.res
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -422,7 +420,7 @@ let make = (
}
}

let heightClass = customHeightClass->Option.getWithDefault({
let heightClass = customHeightClass->Option.getOr({
switch buttonSize {
| XSmall => "h-fit"
| Small => "h-fit"
Expand All @@ -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 =>
Expand All @@ -450,7 +448,7 @@ let make = (
},
)

let textPaddingClass = customTextPaddingClass->Option.getWithDefault(
let textPaddingClass = customTextPaddingClass->Option.getOr(
switch buttonSize {
| XSmall => "px-1"
| Small => "px-1"
Expand All @@ -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"
Expand All @@ -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
Expand All @@ -496,7 +494,7 @@ let make = (
| Large => ""
}

let iconMargin = customIconMargin->Option.getWithDefault(
let iconMargin = customIconMargin->Option.getOr(
switch buttonSize {
| XSmall
| Small => "ml-1"
Expand Down Expand Up @@ -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
Expand All @@ -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"

<AddDataAttributes attributes=[(dataAttrKey, dataAttrStr)]>
Expand Down Expand Up @@ -752,7 +750,7 @@ let make = (
if showBtnTextToolTip {
<div className=ellipsisParentClass>
<ToolTip
description={tooltipText->Option.getWithDefault("")}
description={tooltipText->Option.getOr("")}
toolTipFor=btnContent
contentAlign=Default
justifyClass="justify-start"
Expand Down
12 changes: 6 additions & 6 deletions src/components/Calendar.res
Original file line number Diff line number Diff line change
Expand Up @@ -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("")
Expand Down Expand Up @@ -53,7 +53,7 @@ module TableRow = {
let highlight = cellHighlighter

{
if item == Belt.Array.make(7, "") {
if item == Array.make(~length=7, "") {
<tr className="h-0" />
} else {
<tr className="transition duration-300 ease-in-out">
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) => {
Expand Down
6 changes: 3 additions & 3 deletions src/components/CalendarList.res
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -76,7 +76,7 @@ let make = (
setCurrDate(_ => newDate)
}

let dummyRow = Belt.Array.make(count, 1)
let dummyRow = Array.make(~length=count, 1)
<div
className={`flex flex-1 flex-row justify-center overflow-auto bg-jp-gray-50 dark:bg-jp-gray-950 rounded border border-jp-gray-500 dark:border-jp-gray-960 select-none ${calendarContaierStyle}`}>
{dummyRow
Expand All @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion src/components/CollapsableTableRow.res
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ let make = (
<div className="px-3 py-4 bg-white dark:bg-jp-gray-lightgray_background">
{item
->Array.mapWithIndex((obj, index) => {
let heading = headingArray->Belt.Array.get(index)->Option.getWithDefault("")
let heading = headingArray->Array.get(index)->Option.getOr("")
<UIUtils.RenderIf condition={index !== 0} key={index->string_of_int}>
<div className="flex mb-5 justify-between">
<div className="text-jp-gray-900 opacity-50 font-medium">
Expand Down
12 changes: 5 additions & 7 deletions src/components/CustomCharts/FunnelChart.res
Original file line number Diff line number Diff line change
Expand Up @@ -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 => ""
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/components/CustomCharts/HighchartHorizontalBarChart.res
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ let xLabelFormatter: Js_OO.Callback.arity1<xAxisRecord => 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
}
}
Expand Down Expand Up @@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion src/components/CustomCharts/HighchartPieChart.res
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
32 changes: 14 additions & 18 deletions src/components/CustomCharts/HighchartTimeSeriesChart.res
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 => {
Expand All @@ -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()
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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 => ("", "", "")
}
Expand Down
Loading

0 comments on commit 2d03f43

Please sign in to comment.