Skip to content

Commit

Permalink
chore: Nullable Core API Added.. (#315)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pritish Budhiraja authored Jan 31, 2024
1 parent 1ff05f8 commit c8ae50b
Show file tree
Hide file tree
Showing 118 changed files with 339 additions and 350 deletions.
2 changes: 1 addition & 1 deletion src/components/ACLButton.resi
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ let make: (
~customBackColor: string=?,
~showBtnTextToolTip: bool=?,
~access: AuthTypes.authorization=?,
~tooltipText: Js.String2.t=?,
~tooltipText: string=?,
~toolTipPosition: ToolTip.toolTipPosition=?,
) => React.element
8 changes: 4 additions & 4 deletions src/components/AdvancedSearchComponent.res
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ let make = (
->then(json => {
let jsonData = json->JSON.Decode.object->Option.flatMap(dict => dict->Dict.get("rows"))
let newData = switch jsonData {
| Some(actualJson) => actualJson->getObjects->Array.map(obj => obj->Js.Nullable.return)
| Some(actualJson) => actualJson->getObjects->Array.map(obj => obj->Nullable.make)
| None => []
}

Expand All @@ -51,13 +51,13 @@ let make = (
| None => ()
}
setShowModal(_ => false)
form.reset(JSON.Encode.object(Dict.make())->Js.Nullable.return)
json->Js.Nullable.return->resolve
form.reset(JSON.Encode.object(Dict.make())->Nullable.make)
json->Nullable.make->resolve
})
->catch(_err => {
showToast(~message="Something went wrong. Please try again", ~toastType=ToastError, ())

Js.Nullable.null->resolve
Nullable.null->resolve
})
}

Expand Down
4 changes: 2 additions & 2 deletions src/components/AdvancedSearchModal.res
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ module AdvanceSearch = {
| _ =>
showToast(~message="Something went wrong. Please try again", ~toastType=ToastError, ())
}
json->Js.Nullable.return->resolve
json->Nullable.make->resolve
})
->catch(_err => {
showToast(~message="Something went wrong. Please try again", ~toastType=ToastError, ())

Js.Nullable.null->resolve
Nullable.null->resolve
})
}

Expand Down
4 changes: 2 additions & 2 deletions src/components/Button.res
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,8 @@ let make = (
~tooltipText=?,
~toolTipPosition=ToolTip.Top,
) => {
let parentRef = React.useRef(Js.Nullable.null)
let dummyRef = React.useRef(Js.Nullable.null)
let parentRef = React.useRef(Nullable.null)
let dummyRef = React.useRef(Nullable.null)
let buttonRef = disableRipple ? dummyRef : parentRef
let rippleEffect = RippleEffectBackground.useHorizontalRippleHook(buttonRef)
if !isPhoneDropdown {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Button.resi
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,6 @@ let make: (
~isPhoneDropdown: bool=?,
~showBtnTextToolTip: bool=?,
~showTooltip: bool=?,
~tooltipText: Js.String2.t=?,
~tooltipText: string=?,
~toolTipPosition: ToolTip.toolTipPosition=?,
) => React.element
2 changes: 1 addition & 1 deletion src/components/CustomCharts/HighchartBarChart.res
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module HighBarChart1D = {
let barOption: JSON.t = {
"chart": Highcharts.makebarChart(
~chartType={isHrizonatalBar ? "bar" : "column"},
~backgroundColor=Js.Nullable.null,
~backgroundColor=Nullable.null,
(),
),
"title": {
Expand Down
12 changes: 6 additions & 6 deletions src/components/CustomCharts/HighchartTimeSeriesChart.res
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ type ele
external toElement: Dom.element => ele = "%identity"

@send
external querySelectorAll: (DOMUtils.document, string) => array<Js.Nullable.t<domElement>> =
external querySelectorAll: (DOMUtils.document, string) => array<Nullable.t<domElement>> =
"querySelectorAll"

@send external addEventListener: ('a, string, unit => unit) => unit = "addEventListener"
Expand Down Expand Up @@ -239,7 +239,7 @@ module LineChart1D = {
data: chartDataItem.data->Array.map(
item => {
let (x, y, _) = item
(x, y->Js.Nullable.return)
(x, y->Nullable.make)
},
),
legendIndex: chartDataItem.legendIndex,
Expand Down Expand Up @@ -468,7 +468,7 @@ module LineChart1D = {
"type": chartType,
"margin": None,
"zoomType": "x",
"backgroundColor": Js.Nullable.null,
"backgroundColor": Nullable.null,
"height": Some(chartHeight),
"events": {
render: (
Expand Down Expand Up @@ -538,7 +538,7 @@ module LineChart1D = {
},
},
"lineWidth": 1.2,
"threshold": Js.Nullable.null,
"threshold": Nullable.null,
}->genericObjectOrRecordToJson,
"line": {
"pointStart": None,
Expand All @@ -550,7 +550,7 @@ module LineChart1D = {
},
},
"lineWidth": 1.2,
"threshold": Js.Nullable.null,
"threshold": Nullable.null,
}->genericObjectOrRecordToJson,
"boxplot": {
"visible": false,
Expand Down Expand Up @@ -716,7 +716,7 @@ module LineChart1D = {
: [GroupBY, fistLegend, secondLegend]}
title="High Chart Time Series Chart"
hideTitle=true
actualData={legendData->Array.map(Js.Nullable.return)}
actualData={legendData->Array.map(Nullable.make)}
entity=legendTableEntity
resultsPerPage=15
totalResults={legendData->Array.length}
Expand Down
2 changes: 1 addition & 1 deletion src/components/DatePicker.res
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ let make = (
~showSeconds=true,
~fullLength=?,
) => {
let dropdownRef = React.useRef(Js.Nullable.null)
let dropdownRef = React.useRef(Nullable.null)
let (isExpanded, setIsExpanded) = React.useState(_ => false)
let customTimezoneToISOString = TimeZoneHook.useCustomTimeZoneToIsoString()
let isoStringToCustomTimeZone = TimeZoneHook.useIsoStringToCustomTimeZone()
Expand Down
4 changes: 2 additions & 2 deletions src/components/DateRangePicker.res
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,8 @@ module Base = {
None
}, (localStartDate, localEndDate))

let dateRangeRef = React.useRef(Js.Nullable.null)
let dropdownRef = React.useRef(Js.Nullable.null)
let dateRangeRef = React.useRef(Nullable.null)
let dropdownRef = React.useRef(Nullable.null)

useErroryValueResetter(startDateVal, setStartDateVal)
useErroryValueResetter(endDateVal, setEndDateVal)
Expand Down
2 changes: 1 addition & 1 deletion src/components/DynamicChart.res
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ let make = (
<div>
<ReactFinalForm.Form
subscription=ReactFinalForm.subscribeToValues
onSubmit={(_, _) => Js.Nullable.null->Promise.resolve}
onSubmit={(_, _) => Nullable.null->Promise.resolve}
render={({handleSubmit}) => {
<form onSubmit={handleSubmit}>
<AddDataAttributes attributes=[("data-chart-segment", "Chart-1")]>
Expand Down
6 changes: 3 additions & 3 deletions src/components/DynamicTable.res
Original file line number Diff line number Diff line change
Expand Up @@ -251,11 +251,11 @@ let make = (
})
->then(json => {
switch json->JSON.Classify.classify {
| Array(_arr) => json->getObjects->Array.map(obj => obj->Js.Nullable.return)->setNewData
| Array(_arr) => json->getObjects->Array.map(obj => obj->Nullable.make)->setNewData
| Object(dict) => {
let flattenedObject = JsonFlattenUtils.flattenObject(json, false)
switch Dict.get(flattenedObject, dataKey) {
| Some(x) => x->getObjects->Array.map(obj => obj->Js.Nullable.return)->setNewData
| Some(x) => x->getObjects->Array.map(obj => obj->Nullable.make)->setNewData
| None => ()
}
let summary = switch Dict.get(dict, summaryKey) {
Expand Down Expand Up @@ -423,7 +423,7 @@ let make = (
let newData = switch data {
| Some(data) =>
data->Array.filter(item => {
switch item->Js.Nullable.toOption {
switch item->Nullable.toOption {
| Some(val) => filterCheck(val, keys)
| _ => false
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/DynamicTableUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ let useDateFormatConvertor = () => {
}

let filteredData = (
actualData: array<Js.Nullable.t<'t>>,
actualData: array<Nullable.t<'t>>,
columnFilter: Dict.t<array<JSON.t>>,
visibleColumns: option<array<'colType>>,
entity: EntityType.entityType<'colType, 't>,
Expand All @@ -48,7 +48,7 @@ let filteredData = (
let selectedFiltersKeys = columnFilter->Dict.keysToArray
if selectedFiltersKeys->Array.length > 0 {
actualData->Array.filter(item => {
switch item->Js.Nullable.toOption {
switch item->Nullable.toOption {
| Some(row) =>
// either to take this row or not if any filter is present then take row or else drop
let rowDict = row->Identity.genericTypeToDictOfJson
Expand Down
14 changes: 7 additions & 7 deletions src/components/DynamicTabs.res
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ module IndicationArrow = {
let onClick = {
_ev =>
refElement.current
->Js.Nullable.toOption
->Nullable.toOption
->Option.forEach(input =>
input->scrollIntoView(_, {behavior: "smooth", block: "nearest", inline: "nearest"})
)
Expand Down Expand Up @@ -206,8 +206,8 @@ module IndicationArrow = {
}
}

let getBoundingRectInfo = (ref: React.ref<Js.Nullable.t<Dom.element>>, getter) => {
ref.current->Js.Nullable.toOption->Option.map(getBoundingClientRect)->Option.mapOr(0, getter)
let getBoundingRectInfo = (ref: React.ref<Nullable.t<Dom.element>>, getter) => {
ref.current->Nullable.toOption->Option.map(getBoundingClientRect)->Option.mapOr(0, getter)
}

@react.component
Expand Down Expand Up @@ -400,9 +400,9 @@ let make = (
let (isLeftArrowVisible, setIsLeftArrowVisible) = React.useState(() => false)
let (isRightArrowVisible, setIsRightArrowVisible) = React.useState(() => true)

let firstTabRef = React.useRef(Js.Nullable.null)
let scrollRef = React.useRef(Js.Nullable.null)
let lastTabRef = React.useRef(Js.Nullable.null)
let firstTabRef = React.useRef(Nullable.null)
let scrollRef = React.useRef(Nullable.null)
let lastTabRef = React.useRef(Nullable.null)

let onScroll = _ev => {
setTabScroll(
Expand Down Expand Up @@ -481,7 +481,7 @@ let make = (

Js.Global.setTimeout(_ => {
lastTabRef.current
->Js.Nullable.toOption
->Nullable.toOption
->Option.forEach(input =>
input->scrollIntoView(_, {behavior: "smooth", block: "nearest", inline: "start"})
)
Expand Down
2 changes: 1 addition & 1 deletion src/components/HSwitchFeedBackModal.res
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ let make = (
| _ => ()
}
setShowModal(_ => false)
Js.Nullable.null
Nullable.null
}

let showLabel = switch modalType {
Expand Down
6 changes: 3 additions & 3 deletions src/components/HSwitchSingleStatWidget.res
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ let make = (
->Array.map(item => {
let (x, y) = item
if y === 0. && filterNullVals {
(x, Js.Nullable.null)
(x, Nullable.null)
} else {
(x, y->Js.Nullable.return)
(x, y->Nullable.make)
}
})
}, [data])
Expand Down Expand Up @@ -82,7 +82,7 @@ let make = (
"margin": Some([0, 0, 0, 0]),
"marginLeft": isHomePage ? Some(-5) : None,
"marginRight": isHomePage ? Some(-5) : None,
"backgroundColor": Js.Nullable.null,
"backgroundColor": Nullable.null,
"height": (isHomePage ? "80" : "50")->Some,
"width": isHomePage ? None : Some("105"),
"events": None,
Expand Down
2 changes: 1 addition & 1 deletion src/components/HyperSwitchAuthWrapper.res
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ let make = (~children) => {
| list{"register"} =>
setAuthStatus(LoggedOut)
| _ =>
switch LocalStorage.getItem("login")->Js.Nullable.toOption {
switch LocalStorage.getItem("login")->Nullable.toOption {
| Some(token) =>
if !(token->LogicUtils.isEmptyString) {
setAuthStatus(LoggedIn(HyperSwitchAuthTypes.getDummyAuthInfoForToken(token)))
Expand Down
8 changes: 4 additions & 4 deletions src/components/InfraCalendarList.res
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ module YearItem = {
@react.component
let make = (~tempYear, ~year, ~handleChangeMonthBy, ~setCurrDate, ~tempMonth) => {
let isSelected = year->Int.toFloat === tempYear
let yearRef = React.useRef(Js.Nullable.null)
let yearRef = React.useRef(Nullable.null)

React.useEffect1(() => {
if isSelected {
switch yearRef.current->Js.Nullable.toOption {
switch yearRef.current->Nullable.toOption {
| Some(element) => element->scrollIntoView
| None => ()
}
Expand Down Expand Up @@ -96,11 +96,11 @@ module MonthItem = {
~mon: InfraCalendar.month,
) => {
let isSelected = index->Int.toFloat === tempMonth
let monthRef = React.useRef(Js.Nullable.null)
let monthRef = React.useRef(Nullable.null)

React.useEffect1(() => {
if isSelected {
switch monthRef.current->Js.Nullable.toOption {
switch monthRef.current->Nullable.toOption {
| Some(element) => element->scrollIntoView
| None => ()
}
Expand Down
Loading

0 comments on commit c8ae50b

Please sign in to comment.