Skip to content

Commit

Permalink
chore: upgrade to latest rescript version (#847)
Browse files Browse the repository at this point in the history
Co-authored-by: Pritish Budhiraja <[email protected]>
  • Loading branch information
gitanjli525 and PritishBudhiraja authored Jul 3, 2024
1 parent f6df0c3 commit 8ca1fe4
Show file tree
Hide file tree
Showing 170 changed files with 1,301 additions and 832 deletions.
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"postcss-preset-env": "^6.7.0",
"prettier": "^3.1.0",
"react-refresh": "^0.10.0",
"rescript": "^10.1.2",
"rescript": "^11.1.1",
"serve": "^14.2.1",
"terser-webpack-plugin": "^5.1.3",
"webpack": "^5.3.2",
Expand All @@ -65,8 +65,7 @@
"@juspay-tech/react-hyper-js": "^1.0.2",
"@monaco-editor/react": "^4.4.5",
"@rescript/core": "^0.6.0",
"@rescript/react": "^0.11.0",
"@ryyppy/rescript-promise": "^2.1.0",
"@rescript/react": "^0.12.0",
"bs-fetch": "^0.6.2",
"csvjson-csv2json": "^5.0.6",
"csvjson-json2csv": "^1.0.3",
Expand Down Expand Up @@ -98,7 +97,7 @@
"react-virtualized-auto-sizer": "^1.0.11",
"react-window": "^1.8.8",
"recoil": "^0.1.2",
"rescript-webapi": "^0.7.0",
"rescript-webapi": "^0.9.1",
"tailwindcss": "^3.0.0"
},
"packageManager": "[email protected]"
Expand Down
4 changes: 2 additions & 2 deletions bsconfig.json → rescript.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"$schema": "https://raw.githubusercontent.com/rescript-lang/rescript-compiler/master/docs/docson/build-schema.json",
"name": "editor-ui",
"uncurried": true,
"jsx": {
"version": 4,
"mode": "classic"
Expand All @@ -14,14 +15,13 @@
"namespace": false,
"ppx-flags": [],
"package-specs": {
"module": "es6",
"module": "esmodule",
"in-source": true
},
"bs-dependencies": [
"@rescript/react",
"rescript-webapi",
"bs-fetch",
"@ryyppy/rescript-promise",
"@rescript/core"
]
}
20 changes: 10 additions & 10 deletions src/Recoils/HyperswitchAtom.res
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
let merchantDetailsValueAtom: Recoil.recoilAtom<HSwitchSettingTypes.merchantPayload> = Recoil.atom(.
let merchantDetailsValueAtom: Recoil.recoilAtom<HSwitchSettingTypes.merchantPayload> = Recoil.atom(
"merchantDetailsValue",
JSON.Encode.null->MerchantAccountDetailsMapper.getMerchantDetails,
)

let businessProfilesAtom = Recoil.atom(.
let businessProfilesAtom = Recoil.atom(
"businessProfileDetails",
JSON.Encode.null->BusinessProfileMapper.getArrayOfBusinessProfile,
)

let connectorListAtom: Recoil.recoilAtom<array<ConnectorTypes.connectorPayload>> = Recoil.atom(.
let connectorListAtom: Recoil.recoilAtom<array<ConnectorTypes.connectorPayload>> = Recoil.atom(
"connectorListAtom",
JSON.Encode.null->ConnectorListMapper.getArrayOfConnectorListPayloadType,
)

let enumVariantAtom = Recoil.atom(. "enumVariantDetails", "")
let enumVariantAtom = Recoil.atom("enumVariantDetails", "")

let featureFlagAtom: Recoil.recoilAtom<FeatureFlagUtils.featureFlag> = Recoil.atom(.
let featureFlagAtom: Recoil.recoilAtom<FeatureFlagUtils.featureFlag> = Recoil.atom(
"featureFlag",
JSON.Encode.null->FeatureFlagUtils.featureFlagType,
)
let paypalAccountStatusAtom: Recoil.recoilAtom<PayPalFlowTypes.setupAccountStatus> = Recoil.atom(.
let paypalAccountStatusAtom: Recoil.recoilAtom<PayPalFlowTypes.setupAccountStatus> = Recoil.atom(
"paypalAccountStatusAtom",
PayPalFlowTypes.Connect_paypal_landing,
)
let userPermissionAtom: Recoil.recoilAtom<UserManagementTypes.permissionJson> = Recoil.atom(.
let userPermissionAtom: Recoil.recoilAtom<UserManagementTypes.permissionJson> = Recoil.atom(
"userPermissionAtom",
PermissionUtils.defaultValueForPermission,
)

let switchMerchantListAtom: Recoil.recoilAtom<
array<SwitchMerchantUtils.switchMerchantListResponse>,
> = Recoil.atom(. "switchMerchantListAtom", [SwitchMerchantUtils.defaultValue])
> = Recoil.atom("switchMerchantListAtom", [SwitchMerchantUtils.defaultValue])

let currentTabNameRecoilAtom = Recoil.atom(. "currentTabName", "ActiveTab")
let currentTabNameRecoilAtom = Recoil.atom("currentTabName", "ActiveTab")

let globalSeacrchAtom: Recoil.recoilAtom<GlobalSearchTypes.defaultResult> = Recoil.atom(.
let globalSeacrchAtom: Recoil.recoilAtom<GlobalSearchTypes.defaultResult> = Recoil.atom(
"globalSearch",
{
GlobalSearchTypes.local_results: [],
Expand Down
20 changes: 7 additions & 13 deletions src/Recoils/TableAtoms.res
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
let historyDefaultCols = Recoil.atom(.
"hyperSwitchHistoryDefaultCols",
HistoryEntity.defaultColumns,
)
let historyDefaultCols = Recoil.atom("hyperSwitchHistoryDefaultCols", HistoryEntity.defaultColumns)

let refundsMapDefaultCols = Recoil.atom(. "refundsMapDefaultCols", RefundEntity.defaultColumns)
let refundsMapDefaultCols = Recoil.atom("refundsMapDefaultCols", RefundEntity.defaultColumns)

let payoutsMapDefaultCols = Recoil.atom(. "payoutsMapDefaultCols", PayoutsEntity.defaultColumns)
let payoutsMapDefaultCols = Recoil.atom("payoutsMapDefaultCols", PayoutsEntity.defaultColumns)

let ordersMapDefaultCols = Recoil.atom(. "ordersMapDefaultCols", OrderEntity.defaultColumns)
let ordersMapDefaultCols = Recoil.atom("ordersMapDefaultCols", OrderEntity.defaultColumns)

let disputesMapDefaultCols = Recoil.atom(. "disputesMapDefaultCols", DisputesEntity.defaultColumns)
let disputesMapDefaultCols = Recoil.atom("disputesMapDefaultCols", DisputesEntity.defaultColumns)

let apiDefaultCols = Recoil.atom(. "hyperSwitchApiDefaultCols", DeveloperUtils.defaultColumns)
let apiDefaultCols = Recoil.atom("hyperSwitchApiDefaultCols", DeveloperUtils.defaultColumns)

let customersMapDefaultCols = Recoil.atom(.
"customersMapDefaultCols",
CustomersEntity.defaultColumns,
)
let customersMapDefaultCols = Recoil.atom("customersMapDefaultCols", CustomersEntity.defaultColumns)
2 changes: 1 addition & 1 deletion src/components/AdvancedSearchComponent.res
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ let make = (
open Promise

fetchApi(url, ~bodyStr=JSON.stringify(values), ~method_=Fetch.Post, ())
->then(Fetch.Response.json)
->then(res => res->Fetch.Response.json)
->then(json => {
let jsonData = json->JSON.Decode.object->Option.flatMap(dict => dict->Dict.get("rows"))
let newData = switch jsonData {
Expand Down
9 changes: 5 additions & 4 deletions src/components/AdvancedSearchModal.res
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,22 @@ module AdvanceSearch = {
None
}
})
->Array.joinWith("&")
->Array.joinWithUnsafe("&")
| _ => ""
}
let finalUrl = otherQueries->isNonEmptyString ? `${url}?${otherQueries}` : url

open Promise
fetchApi(finalUrl, ~bodyStr=JSON.stringify(initialValueJson), ~method_=Fetch.Get, ())
->then(Fetch.Response.json)
->then(res => res->Fetch.Response.json)
->then(json => {
switch JSON.Classify.classify(json) {
| Object(jsonDict) => {
let statusStr = getString(jsonDict, "status", "FAILURE")

if statusStr === "SUCCESS" {
let payloadDict = jsonDict->Dict.get(detailsKey)->Option.flatMap(JSON.Decode.object)
let payloadDict =
jsonDict->Dict.get(detailsKey)->Option.flatMap(obj => obj->JSON.Decode.object)

switch payloadDict {
| Some(dict) => {
Expand Down Expand Up @@ -100,7 +101,7 @@ module AdvanceSearch = {
if !isSubmitEnabled {
Dict.set(
errors,
optionalSearchFieldsList->Array.joinWith(","),
optionalSearchFieldsList->Array.joinWithUnsafe(","),
"Atleast One of Optional fields is Required"->JSON.Encode.string,
)
}
Expand Down
14 changes: 7 additions & 7 deletions src/components/Calendar.res
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,15 @@ module TableRow = {
| true =>
switch onDateClick {
| Some(fn) =>
fn((Date.toISOString(date)->DayJs.getDayJsForString).format(. "YYYY-MM-DD"))
fn((Date.toISOString(date)->DayJs.getDayJsForString).format("YYYY-MM-DD"))

| None => ()
}
| false => ()
}
}
let hSelf = highlight(
(Date.toString(date)->DayJs.getDayJsForString).format(. "YYYY-MM-DD"),
(Date.toString(date)->DayJs.getDayJsForString).format("YYYY-MM-DD"),
)

let dayClass = if (
Expand All @@ -159,13 +159,13 @@ module TableRow = {
)
datevalue
}
let today = (Date.make()->Date.toString->DayJs.getDayJsForString).format(. "YYYY-MM-DD")
let today = (Date.make()->Date.toString->DayJs.getDayJsForString).format("YYYY-MM-DD")

let renderingDate = (
getDate([Float.toString(year), Float.toString(month +. 1.0), obj])
->Date.toString
->DayJs.getDayJsForString
).format(. "YYYY-MM-DD")
).format("YYYY-MM-DD")

let textColor =
today == renderingDate
Expand Down Expand Up @@ -227,7 +227,7 @@ module TableRow = {
)
}
let handleHover = () => {
let date = (Date.toString(date)->DayJs.getDayJsForString).format(. "YYYY-MM-DD")
let date = (Date.toString(date)->DayJs.getDayJsForString).format("YYYY-MM-DD")
let parsedDate = getDate(String.split(date, "-"))
setHoverdDate(_ => parsedDate->Date.toString)
switch setShowMsg {
Expand All @@ -252,7 +252,7 @@ module TableRow = {
className={classN}
onClick
onMouseOver={_ => handleHover()}
onMouseOut={evt => setHoverdDate(_ => "")}>
onMouseOut={_evt => setHoverdDate(_ => "")}>
<AddDataAttributes
attributes=[
(
Expand All @@ -274,7 +274,7 @@ module TableRow = {
{cellRenderer(
obj->isEmptyString
? None
: Some((Date.toString(date)->DayJs.getDayJsForString).format(. "YYYY-MM-DD")),
: Some((Date.toString(date)->DayJs.getDayJsForString).format("YYYY-MM-DD")),
)}
</span>
</AddDataAttributes>
Expand Down
2 changes: 1 addition & 1 deletion src/components/CalendarList.res
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ let make = (
Int.toFloat(Float.toInt(Js.Date.getMonth(currDateTemp)) + i),
)
let tempMonth = if disableFutureDates {
(Js.Date.fromFloat(tempDate)->DayJs.getDayJsForJsDate).toString(.)
(Js.Date.fromFloat(tempDate)->DayJs.getDayJsForJsDate).toString()
->Date.fromString
->Js.Date.getMonth
} else {
Expand Down
12 changes: 6 additions & 6 deletions src/components/CustomCharts/HighchartHorizontalBarChart.res
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ module RawHBarChart = {
}
open HighchartsHorizontalBarChart

let valueFormatter = {
let valueFormatter = (
@this
(this: tooltipRecord) => {
`<div class='text-white'>${this.category} count: <b>${this.y->Int.toString}</b></div>`
}
}
)->asTooltipPointFormatter

let dataLabelFormatter: Js_OO.Callback.arity1<yAxisRecord => string> = {
let dataLabelFormatter: yAxisRecord => string = (
@this
_param => {
""
}
}
)->asDataLabelFormatter

let xLabelFormatter: Js_OO.Callback.arity1<xAxisRecord => string> = {
let xLabelFormatter: xAxisRecord => string = (
@this
param => {
let axis = param.axis
Expand Down Expand Up @@ -55,7 +55,7 @@ let xLabelFormatter: Js_OO.Callback.arity1<xAxisRecord => string> = {
(y->Float.fromInt *. 100. /. seriesSum->Float.fromInt)
->Float.toFixedWithPrecision(~digits=2) ++ `%</div></div>`
}
}
)->asXLabelFormatter

@react.component
let make = (
Expand Down
22 changes: 11 additions & 11 deletions src/components/CustomCharts/HighchartPieChart.res
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@ module RawPieChart = {
}
open HighchartsPieChart

let valueFormatter = {
let valueFormatter = (
@this
(this: tooltipRecord) => {
`<div class='text-white'>${this.name} count: <b>${this.y->Int.toString}</b></div>`
}
}
)->asTooltipPointFormatter

let formatter: Js_OO.Callback.arity1<yAxisRecord => string> = {
@this
param => {
`<div class="font-semibold text-black dark:text-white">` ++
param.point.name ++
`</div><br><div class="font-medium text-black dark:text-white">` ++
param.point.percentage->Float.toFixedWithPrecision(~digits=2) ++ `%</div>`
}
}
let formatter: yAxisRecord => string =
(
@this
param =>
`<div class="font-semibold text-black dark:text-white">` ++
param.point.name ++
`</div><br><div class="font-medium text-black dark:text-white">` ++
param.point.percentage->Float.toFixedWithPrecision(~digits=2) ++ `%</div>`
)->asDataLabelFormatter

@react.component
let make = (
Expand Down
Loading

0 comments on commit 8ca1fe4

Please sign in to comment.