Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Multi filters support #79

Merged
merged 56 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from 55 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
8025deb
basic filter changes
sagarnaikjuspay Dec 3, 2023
1b339c1
added helper funtions
sagarnaikjuspay Dec 3, 2023
afb3984
code refactor
sagarnaikjuspay Dec 3, 2023
4bade11
intitial filters settings
sagarnaikjuspay Dec 3, 2023
9f030a6
update component fix
sagarnaikjuspay Dec 3, 2023
f7ec1bb
code refactor
sagarnaikjuspay Dec 3, 2023
e8263be
orders refactor
sagarnaikjuspay Dec 3, 2023
7fbc0ee
remote filters fix
sagarnaikjuspay Dec 4, 2023
d387826
analytics filters fix
sagarnaikjuspay Dec 4, 2023
546d3ef
Merge branch 'main' into multi-filters-support
sagarnaikjuspay Dec 7, 2023
ae5bcb1
filter dict fix
sagarnaikjuspay Dec 7, 2023
72d6afc
basic version
sagarnaikjuspay Dec 7, 2023
e825959
Merge branch 'main' into multi-filters-support
sagarnaikjuspay Dec 7, 2023
53244c7
code refactor
sagarnaikjuspay Dec 7, 2023
3f01f88
merged main
sagarnaikjuspay Dec 7, 2023
e96a1f5
code refactor
sagarnaikjuspay Dec 7, 2023
5743dde
more code refactor
sagarnaikjuspay Dec 7, 2023
7379a37
more code refactor
sagarnaikjuspay Dec 7, 2023
13aefa2
init filter change
sagarnaikjuspay Dec 7, 2023
3dc42cf
code refactor
sagarnaikjuspay Dec 8, 2023
28611c2
Merge branch 'main' into multi-filters-support
sagarnaikjuspay Dec 10, 2023
6fbcdbd
chore: code refactor
sagarnaikjuspay Dec 10, 2023
17b9106
chore: code refactor
sagarnaikjuspay Dec 10, 2023
a1c1f98
chore: code refactor
sagarnaikjuspay Dec 10, 2023
47990ad
chore: removed auto apply for remote filters
sagarnaikjuspay Dec 10, 2023
e1cf266
chore: code refactor
sagarnaikjuspay Dec 10, 2023
32a6d06
chore: merged latest code
sagarnaikjuspay Dec 11, 2023
fb177bd
chore: code refactor
sagarnaikjuspay Dec 11, 2023
10115d2
chore: code refactor
sagarnaikjuspay Dec 11, 2023
90be0f1
chore: some code
sagarnaikjuspay Dec 11, 2023
e08549c
chore: fixed the clear filters
sagarnaikjuspay Dec 11, 2023
c06d751
chore: filters reload isseu fixed
sagarnaikjuspay Dec 11, 2023
c6a6b7b
chore: merged latest code
sagarnaikjuspay Dec 14, 2023
292726f
refactor: removed unused code
sagarnaikjuspay Dec 14, 2023
7818e82
Merge branch 'multi-filters-support' of github.com:juspay/hyperswitch…
sagarnaikjuspay Dec 14, 2023
79603b5
chore: fixed the bug
sagarnaikjuspay Dec 14, 2023
f62a323
feat: added session history
sagarnaikjuspay Dec 14, 2023
37aca6e
Merge branch 'main' into multi-filters-support
sagarnaikjuspay Dec 19, 2023
02a6964
refactor: removed dead code
sagarnaikjuspay Dec 19, 2023
c9b047d
chore: merged latest main
sagarnaikjuspay Dec 20, 2023
313db53
Merge branch 'main' into multi-filters-support
sagarnaikjuspay Dec 20, 2023
b3a7274
chore: disable session storage
sagarnaikjuspay Dec 21, 2023
ed68a32
Merge branch 'main' into multi-filters-support
sagarnaikjuspay Dec 21, 2023
129b23d
chore: merged latest branch
sagarnaikjuspay Dec 27, 2023
ab6bde9
Merge branch 'main' into multi-filters-support
sagarnaikjuspay Dec 27, 2023
2bc1629
Merge branch 'main' into multi-filters-support
sagarnaikjuspay Dec 27, 2023
6d4e335
chore: code refactor
sagarnaikjuspay Dec 27, 2023
ea69695
Merge branch 'main' into multi-filters-support
sagarnaikjuspay Dec 28, 2023
4d96e8b
Merge branch 'main' into multi-filters-support
sagarnaikjuspay Dec 28, 2023
fcf67c1
Merge branch 'multi-filters-support' of github.com:juspay/hyperswitch…
sagarnaikjuspay Dec 28, 2023
69b6fff
Merge branch 'main' into multi-filters-support
sagarnaikjuspay Dec 28, 2023
409912a
Merge branch 'main' into multi-filters-support
sagarnaikjuspay Dec 28, 2023
a311bfe
chore: some code refactor
sagarnaikjuspay Dec 28, 2023
3704f20
Merge branch 'main' into multi-filters-support
sagarnaikjuspay Jan 2, 2024
91c7340
chore: merged latest branch
sagarnaikjuspay Jan 2, 2024
ae03d50
chore: merged latest branch
sagarnaikjuspay Jan 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/DynamicChart.res
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ let make = (
}

let currentTheme = ThemeProvider.useTheme()
let {filterValue} = React.useContext(AnalyticsUrlUpdaterContext.urlUpdaterContext)
let {filterValue} = React.useContext(FilterContext.filterContext)
let (_switchToMobileView, setSwitchToMobileView) = React.useState(_ => false)
let (selectedTabState, setSelectedTabState) = React.useState(_ => selectedTab)

Expand Down
4 changes: 1 addition & 3 deletions src/components/DynamicFilter.res
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,7 @@ let make = (
let defaultFilters = ""->Js.Json.string
let (showModal, setShowModal) = React.useState(_ => false)

let {updateExistingKeys, filterValue, removeKeys} = React.useContext(
AnalyticsUrlUpdaterContext.urlUpdaterContext,
)
let {updateExistingKeys, filterValue, removeKeys} = React.useContext(FilterContext.filterContext)

let currentCustomFilterValue =
filterValue->Js.Dict.get(customFilterKey)->Belt.Option.getWithDefault("")
Expand Down
3 changes: 2 additions & 1 deletion src/components/DynamicSingleStat.res
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,9 @@ let make = (
~statThreshold=?,
~wrapperClass=?,
) => {
let {filterValueJson} = React.useContext(FilterContext.filterContext)
let fetchApi = AuthHooks.useApiFetcher()
let getAllFilter = UrlUtils.useGetFilterDictFromUrl("")
let getAllFilter = filterValueJson
let isMobileView = MatchMedia.useMobileChecker()
let (showStats, setShowStats) = React.useState(_ => false)

Expand Down
3 changes: 2 additions & 1 deletion src/components/DynamicTabs.res
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,8 @@ let make = (
| None => _ => ()
}
let {addConfig, getConfig} = React.useContext(UserPrefContext.userPrefContext)
let getTabNames = UrlUtils.useGetFilterDictFromUrl(tabId)
let {filterValueJson} = React.useContext(FilterContext.filterContext)
let getTabNames = filterValueJson
let getTitle = key => {
(
tabs
Expand Down
39 changes: 21 additions & 18 deletions src/components/FilterUtils.res
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
let generateDefaultUrl = dict => {
dict
->Js.Dict.entries
->Belt.Array.keepMap(entry => {
let (key, val) = entry

let strValue = RemoteFiltersUtils.getStrFromJson(key, val)
if strValue !== "" {
Some(`${key}=${strValue}`)
} else {
None
}
let parseFilterString = queryString => {
queryString
->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.Array2.joinWith("&")
->Js.Dict.fromArray
}

let updateURLWithDefaultFilter = (~path, ~filterParam, ~filterString) => {
if path->Js.String2.length > 0 && filterParam->Js.String2.length == 0 {
let finalUrl = `${path}?${filterString}`
RescriptReactRouter.replace(finalUrl)
}
let parseFilterDict = dict => {
let searchParam =
dict
->Js.Dict.entries
->Js.Array2.map(item => {
let (key, value) = item
`${key}=${value}`
})
->Js.Array2.joinWith("&")

searchParam
}
18 changes: 7 additions & 11 deletions src/components/RemoteFilter.res
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ module ClearFilters = {
~isCountRequired=true,
~outsidefilter=false,
) => {
let url = RescriptReactRouter.useUrl()
let {updateExistingKeys} = React.useContext(FilterContext.filterContext)
let isMobileView = MatchMedia.useMobileChecker()
let outerClass = if isMobileView {
"flex items-center justify-end"
Expand Down Expand Up @@ -160,8 +160,7 @@ module ClearFilters = {
})
->Js.Array2.joinWith("&")

let path = url.path->Belt.List.toArray->Js.Array2.joinWith("/")
RescriptReactRouter.replace(`/${path}?${searchStr}`)
searchStr->FilterUtils.parseFilterString->updateExistingKeys
}
}

Expand Down Expand Up @@ -197,7 +196,7 @@ module ClearFilters = {
module AnalyticsClearFilters = {
@react.component
let make = (~defaultFilterKeys=[], ~clearFilters=?, ~outsidefilter=false) => {
let url = RescriptReactRouter.useUrl()
let {updateExistingKeys} = React.useContext(FilterContext.filterContext)
let formState: ReactFinalForm.formState = ReactFinalForm.useFormState(
ReactFinalForm.useFormSubscription(["values", "initialValues"])->Js.Nullable.return,
)
Expand Down Expand Up @@ -231,8 +230,7 @@ module AnalyticsClearFilters = {
})
->Js.Array2.joinWith("&")

let path = url.path->Belt.List.toArray->Js.Array2.joinWith("/")
RescriptReactRouter.replace(`/${path}?${searchStr}`)
searchStr->FilterUtils.parseFilterString->updateExistingKeys
}
}

Expand Down Expand Up @@ -554,6 +552,7 @@ let make = (
~disableURIdecode=false,
~revampedFilter=false,
) => {
let {query} = React.useContext(FilterContext.filterContext)
let hyperswitchMixPanel = HSMixPanel.useSendEvent()
let alreadySelectedFiltersUserpref = `remote_filters_selected_keys_${tableName->Belt.Option.getWithDefault(
"",
Expand Down Expand Up @@ -588,17 +587,14 @@ let make = (
}, [updatedSelectedList->Js.Json.stringify])

let getNewQuery = DateRefreshHooks.useConstructQueryOnBasisOfOpt()
let url = RescriptReactRouter.useUrl()
let (isButtonDisabled, setIsButtonDisabled) = React.useState(_ => false)
let queryStr = url.search

let totalFilters = selectedFiltersList->Js.Array2.length + localOptions->Js.Array2.length
let (checkedFilters, setCheckedFilters) = React.useState(_ => [])
let (clearFilterAfterRefresh, setClearFilterAfterRefresh) = React.useState(_ => false)
let (count, setCount) = React.useState(_ => initalCount)

let url = RescriptReactRouter.useUrl()
let searchParams = disableURIdecode ? url.search : url.search->Js.Global.decodeURI
let searchParams = disableURIdecode ? query : query->Js.Global.decodeURI

let isMobileView = MatchMedia.useMobileChecker()

Expand Down Expand Up @@ -840,7 +836,7 @@ let make = (

let handleRefresh = _ => {
let newQueryStr = getNewQuery(
~queryString=queryStr,
~queryString=query,
~disableFutureDates=true,
~disablePastDates=false,
~startKey="startTime",
Expand Down
109 changes: 0 additions & 109 deletions src/context/AnalyticsUrlUpdaterContext.res

This file was deleted.

Loading
Loading