Skip to content

Commit

Permalink
feat: added session history
Browse files Browse the repository at this point in the history
  • Loading branch information
sagarnaikjuspay committed Dec 14, 2023
1 parent 79603b5 commit f62a323
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 7 deletions.
25 changes: 24 additions & 1 deletion src/context/FilterContext.res
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
type sessionStorage = {
getItem: (. string) => Js.Nullable.t<string>,
setItem: (. string, string) => unit,
removeItem: (. string) => unit,
}

@val external sessionStorage: sessionStorage = "sessionStorage"

type filterUpdater = {
query: string,
filterValue: Js.Dict.t<string>,
Expand All @@ -23,7 +31,7 @@ module Provider = {
}

@react.component
let make = (~children) => {
let make = (~index: string, ~children) => {
open FilterUtils
let (query, setQuery) = React.useState(_ => "")
let searcParamsToDict = query->parseFilterString
Expand Down Expand Up @@ -102,5 +110,20 @@ let make = (~children) => {
}
}, (filterDict, setfilterDict))

React.useEffect0(() => {
switch sessionStorage.getItem(. index)->Js.Nullable.toOption {
| Some(value) => value->FilterUtils.parseFilterString->updateFilter.updateExistingKeys
| None => ()
}
None
})

React.useEffect1(() => {
if !(query->Js.String2.length < 1) {
sessionStorage.setItem(. index, query)
}
None
}, [query])

<Provider value={updateFilter}> children </Provider>
}
12 changes: 6 additions & 6 deletions src/entryPoints/hyperswitch/HyperSwitchApp.res
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ let make = () => {
renderShow={_ => <ConnectorHome isPayoutFlow=true />}
/>
| list{"payments", ...remainingPath} =>
<FilterContext key="payments">
<FilterContext key="payments" index="payments">
<EntityScaffold
entityName="Payments"
remainingPath
Expand All @@ -257,7 +257,7 @@ let make = () => {
/>
</FilterContext>
| list{"refunds", ...remainingPath} =>
<FilterContext key="refunds">
<FilterContext key="refunds" index="refunds">
<EntityScaffold
entityName="Refunds"
remainingPath
Expand Down Expand Up @@ -291,15 +291,15 @@ let make = () => {
renderShow={_ => <UserRoleShowData />}
/>
| list{"analytics-payments"} =>
<FilterContext key="PaymentsAnalytics">
<FilterContext key="PaymentsAnalytics" index="PaymentsAnalytics">
<PaymentAnalytics />
</FilterContext>
| list{"analytics-refunds"} =>
<FilterContext key="PaymentsRefunds">
<FilterContext key="PaymentsRefunds" index="PaymentsRefunds">
<RefundsAnalytics />
</FilterContext>
| list{"analytics-user-journey"} =>
<FilterContext key="UserJourneyAnalytics">
<FilterContext key="UserJourneyAnalytics" index="UserJourneyAnalytics">
<UserJourneyAnalytics />
</FilterContext>
| list{"monitoring"} => comingSoonPage
Expand All @@ -308,7 +308,7 @@ let make = () => {
<UIUtils.RenderIf
condition={userRole->Js.String2.includes("internal_") &&
featureFlagDetails.systemMetrics}>
<FilterContext key="SystemMetrics">
<FilterContext key="SystemMetrics" index="SystemMetrics">
<SystemMetricsAnalytics />
</FilterContext>
</UIUtils.RenderIf>
Expand Down

0 comments on commit f62a323

Please sign in to comment.