Skip to content

Commit

Permalink
more code refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
sagarnaikjuspay committed Dec 7, 2023
1 parent 5743dde commit 7379a37
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 18 deletions.
9 changes: 4 additions & 5 deletions src/hooks/AnalyticsHooks.res
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,11 @@ let useGetCalendarTime = () => {
calendarTime
}

let useGetFiltersData = (~index) => {
let useGetFiltersData = () => {
let (filterData, setFilterData) = React.useState(_ => None)
open FilterUtils
let timeFilters = useFiltersValue(~index)->parseUrl
let startTimeVal = timeFilters->Js.Dict.get("startTime")->Belt.Option.getWithDefault("")
let endTimeVal = timeFilters->Js.Dict.get("endTime")->Belt.Option.getWithDefault("")
let {filterValueJson} = React.useContext(FilterContext.filterContext)
let startTimeVal = filterValueJson->getString("startTime", "")
let endTimeVal = filterValueJson->getString("endTime", "")
let addLogsAroundFetch = EulerAnalyticsLogUtils.useAddLogsAroundFetch()

let fetchApi = AuthHooks.useApiFetcher()
Expand Down
2 changes: 1 addition & 1 deletion src/screens/HyperSwitch/Analytics/Analytics.res
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ let make = (
}

let filterValueDict = filterValueJson
let getFilterData = AnalyticsHooks.useGetFiltersData(~index)
let getFilterData = AnalyticsHooks.useGetFiltersData()

let (activeTav, setActiveTab) = React.useState(_ =>
filterValueDict->getStrArrayFromDict(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ module SystemMetricsInsights = {
open HSAnalyticsUtils
open AnalyticsTypes
@react.component
let make = (~index) => {
let make = () => {
let (_totalVolume, setTotalVolume) = React.useState(_ => 0)

let getStatData = (
Expand Down Expand Up @@ -255,9 +255,9 @@ let make = () => {
<p className=headingStyle> {"Overview"->React.string} </p>
<div className="grid grid-cols-1 md:grid-cols-3 w-full gap-4">
<ConnectorOverview />
<PaymentOverview index="PaymentOverview" />
<PaymentOverview />
<UIUtils.RenderIf condition={systemMetrics}>
<SystemMetricsInsights index="SystemMetricsInsights" />
<SystemMetricsInsights />
</UIUtils.RenderIf>
</div>
<OverviewInfo />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@react.component
let make = (~index) => {
let make = () => {
open HSAnalyticsUtils
let (_totalVolume, setTotalVolume) = React.useState(_ => 0)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ module ConnectorLatency = {
open HSAnalyticsUtils
open AnalyticsTypes
@react.component
let make = (~index) => {
let make = () => {
let (_totalVolume, setTotalVolume) = React.useState(_ => 0)

let getStatData = (
Expand Down Expand Up @@ -329,7 +329,6 @@ module SystemMetricsAnalytics = {
open LogicUtils
@react.component
let make = (
~index,
~pageTitle="",
~pageSubTitle="",
~startTimeFilterKey: string,
Expand All @@ -343,7 +342,7 @@ module SystemMetricsAnalytics = {
) => {
let url = RescriptReactRouter.useUrl()

let getFilterData = AnalyticsHooks.useGetFiltersData(~index)
let getFilterData = AnalyticsHooks.useGetFiltersData()
let getModuleFilters = UrlUtils.useGetFilterDictFromUrl("")
let startTimeVal = getModuleFilters->getString(startTimeFilterKey, "")
let endTimeVal = getModuleFilters->getString(endTimeFilterKey, "")
Expand Down Expand Up @@ -468,13 +467,11 @@ let make = () => {
})

let tabKeys = getStringListFromArrayDict(dimensions)
let index = "SystemMetrics"
let title = "System Metrics"
let subTitle = "Gain Insights, monitor performance and make Informed Decisions with System Metrics."

<PageLoaderWrapper screenState customUI={<NoData title subTitle />}>
<SystemMetricsAnalytics
index
pageTitle=title
pageSubTitle=subTitle
filterUri={`${HSwitchGlobalVars.hyperSwitchApiPrefix}/analytics/v1/filters/${domain}`}
Expand Down
4 changes: 1 addition & 3 deletions src/screens/analyticsScreens/AnalyticsCommonComponents.res
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,12 @@ module SavedViewTable = {
module FiltersComponent = {
@react.component
let make = (
~index,
~filterEntity: AnalyticsUtils.filterEntity<'t>,
~downloadDataButtonUi: React.element=React.null,
) => {
open AnalyticsUtils
let iframe_padding = parent !== window ? "px-5" : ""
let getFilterData = AnalyticsHooks.useGetFiltersData(~index)
let getFilterData = AnalyticsHooks.useGetFiltersData()
let {updateExistingKeys, filterValue} = React.useContext(FilterContext.filterContext)

let {
Expand Down Expand Up @@ -177,7 +176,6 @@ module FiltersComponent = {
module FiltersComponentNew = {
@react.component
let make = (
~index,
~filterEntity: AnalyticsUtils.filterEntityNew<'t>,
~downloadDataButtonUi: React.element=React.null,
~domain="txns",
Expand Down

0 comments on commit 7379a37

Please sign in to comment.