From 5743ddecd8bce05b6c6eb4b2f1c991f281695037 Mon Sep 17 00:00:00 2001 From: Sagar Naik Date: Fri, 8 Dec 2023 01:04:58 +0530 Subject: [PATCH] more code refactor --- src/components/DynamicSingleStat.res | 5 ++--- src/components/FilterUtils.res | 13 ------------- src/screens/HyperSwitch/Analytics/Analytics.res | 14 ++++++-------- .../HomePageOverview/HomePageOverviewComponent.res | 1 - .../PaymentsOverview/PaymentOverview.res | 1 - .../SystemMetrics/SystemMetricsAnalytics.res | 2 -- 6 files changed, 8 insertions(+), 28 deletions(-) diff --git a/src/components/DynamicSingleStat.res b/src/components/DynamicSingleStat.res index 09beb90b2..db0a83bc2 100644 --- a/src/components/DynamicSingleStat.res +++ b/src/components/DynamicSingleStat.res @@ -109,7 +109,6 @@ let deltaTimeRangeMapper: array => deltaRange = (arrJson: array, ~modeKey=?, ~filterKeys, @@ -127,9 +126,9 @@ let make = ( ~statThreshold=?, ~wrapperClass=?, ) => { - open FilterUtils + let {filterValueJson} = React.useContext(FilterContext.filterContext) let fetchApi = AuthHooks.useApiFetcher() - let getAllFilter = useFiltersValue(~index)->parseUrlString + let getAllFilter = filterValueJson let isMobileView = MatchMedia.useMobileChecker() let (showStats, setShowStats) = React.useState(_ => false) diff --git a/src/components/FilterUtils.res b/src/components/FilterUtils.res index b9feb6393..7e1a319ab 100644 --- a/src/components/FilterUtils.res +++ b/src/components/FilterUtils.res @@ -67,19 +67,6 @@ let parseUrl = url => { ->Js.Dict.fromArray } -let parseUrlString = url => { - url - ->Js.Global.decodeURI - ->Js.String2.split("&") - ->Belt.Array.keepMap(str => { - let arr = str->Js.String2.split("=") - let key = arr->Belt.Array.get(0)->Belt.Option.getWithDefault("-") - let val = arr->Belt.Array.sliceToEnd(1)->Js.Array2.joinWith("=") - key === "" || val === "" ? None : Some((key, val->Js.Json.string)) - }) - ->Js.Dict.fromArray -} - let useUpdateFilterObject = (~index: string) => { let filters = useFiltersValue(~index) let setFilters = useAddFilters(~index) diff --git a/src/screens/HyperSwitch/Analytics/Analytics.res b/src/screens/HyperSwitch/Analytics/Analytics.res index fe7eef115..1dfab2883 100644 --- a/src/screens/HyperSwitch/Analytics/Analytics.res +++ b/src/screens/HyperSwitch/Analytics/Analytics.res @@ -119,11 +119,8 @@ module TableWrapper = { ~distributionArray=None, ) => { let customFilter = Recoil.useRecoilValueFromAtom(AnalyticsAtoms.customFilterAtom) - let {index} = React.useContext(FilterContext.filterContext) - open FilterUtils - let filterValueString = useFiltersValue(~index) - let filterValueDict = filterValueString->parseUrlString - let filterValueDict = filterValueDict + let {filterValueJson} = React.useContext(FilterContext.filterContext) + let filterValueDict = filterValueJson let fetchDetails = APIUtils.useUpdateMethod() let (_, setDefaultFilter) = Recoil.useRecoilState(AnalyticsHooks.defaultFilter) let (showTable, setShowTable) = React.useState(_ => false) @@ -529,7 +526,9 @@ let make = ( ->LogicUtils.safeParse ->FeatureFlagUtils.featureFlagType let analyticsType = moduleName->getAnalyticsType - let {index, filterValue, updateExistingKeys} = React.useContext(FilterContext.filterContext) + let {index, filterValue, updateExistingKeys, filterValueJson} = React.useContext( + FilterContext.filterContext, + ) let filterValueString = useFiltersValue(~index) let (_totalVolume, setTotalVolume) = React.useState(_ => 0) let defaultFilters = [startTimeFilterKey, endTimeFilterKey] @@ -543,7 +542,7 @@ let make = ( | None => None } - let filterValueDict = filterValueString->parseUrlString + let filterValueDict = filterValueJson let getFilterData = AnalyticsHooks.useGetFiltersData(~index) let (activeTav, setActiveTab) = React.useState(_ => @@ -721,7 +720,6 @@ let make = (
{ let dateDict = HSwitchRemoteFilter.getDateFilteredObject()