diff --git a/src/context/FilterContext.res b/src/context/FilterContext.res index 1af2464b5..4386b1a90 100644 --- a/src/context/FilterContext.res +++ b/src/context/FilterContext.res @@ -33,8 +33,9 @@ module Provider = { @react.component let make = (~index: string, ~children, ~disableSessionStorage=false) => { open FilterUtils - let temp = React.useMemo0(() => {ref("")}) - let searcParamsToDict = temp.contents->parseFilterString + open HSwitchUtils + let query = React.useMemo0(() => {ref("")}) + let searcParamsToDict = query.contents->parseFilterString let (filterDict, setfilterDict) = React.useState(_ => searcParamsToDict) let updateFilter = React.useMemo2(() => { @@ -48,7 +49,7 @@ let make = (~index: string, ~children, ~disableSessionStorage=false) => { let (key, value) = item switch dict->Js.Dict.get(key) { | Some(_) => None - | None => value !== "" ? Some(item) : None + | None => !(value->isEmptyString) ? Some(item) : None } }, ) @@ -58,7 +59,7 @@ let make = (~index: string, ~children, ~disableSessionStorage=false) => { ->Js.Array2.filter( item => { let (_, value) = item - value !== "" + !(value->isEmptyString) }, ) @@ -68,7 +69,7 @@ let make = (~index: string, ~children, ~disableSessionStorage=false) => { } else { updatedDict } - temp := dict->FilterUtils.parseFilterDict + query := dict->FilterUtils.parseFilterDict dict }) } @@ -76,7 +77,7 @@ let make = (~index: string, ~children, ~disableSessionStorage=false) => { let reset = () => { let dict = Js.Dict.empty() setfilterDict(_ => dict) - temp := dict->FilterUtils.parseFilterDict + query := dict->FilterUtils.parseFilterDict } let removeKeys = (arr: array) => { @@ -88,12 +89,12 @@ let make = (~index: string, ~children, ~disableSessionStorage=false) => { } else { updatedDict } - temp := dict->FilterUtils.parseFilterDict + query := dict->FilterUtils.parseFilterDict dict }) } { - query: temp.contents, + query: query.contents, filterValue: filterDict, updateExistingKeys: updateFilter, removeKeys, @@ -120,11 +121,11 @@ let make = (~index: string, ~children, ~disableSessionStorage=false) => { }) React.useEffect1(() => { - if !(temp.contents->Js.String2.length < 1) && !disableSessionStorage { - sessionStorage.setItem(. index, temp.contents) + if !(query.contents->Js.String2.length < 1) && !disableSessionStorage { + sessionStorage.setItem(. index, query.contents) } None - }, [temp.contents]) + }, [query.contents]) children } diff --git a/src/screens/HyperSwitch/HSwitchRemoteFilter.res b/src/screens/HyperSwitch/HSwitchRemoteFilter.res index 75021302e..6cefeebfc 100644 --- a/src/screens/HyperSwitch/HSwitchRemoteFilter.res +++ b/src/screens/HyperSwitch/HSwitchRemoteFilter.res @@ -118,7 +118,7 @@ let useGetFiltersData = () => { let endTimeVal = filterValueJson->getString("end_time", "") (url, body) => { - React.useEffect1(() => { + React.useEffect3(() => { setFilterData(_ => None) if startTimeVal->isStringNonEmpty && endTimeVal->isStringNonEmpty { try { @@ -131,7 +131,7 @@ let useGetFiltersData = () => { } } None - }, [startTimeVal, endTimeVal, body->Js.Json.object_->Js.Json.stringify]) + }, (startTimeVal, endTimeVal, body->Js.Json.object_->Js.Json.stringify)) filterData } } diff --git a/src/screens/HyperSwitch/Order/Orders.res b/src/screens/HyperSwitch/Order/Orders.res index 7654c9679..4245e47c6 100644 --- a/src/screens/HyperSwitch/Order/Orders.res +++ b/src/screens/HyperSwitch/Order/Orders.res @@ -30,7 +30,7 @@ let make = (~previewOnly=false) => { filters->Js.Dict.set("offset", offset->Belt.Int.toFloat->Js.Json.number) if !(searchText->isEmptyString) { - filters->Js.Dict.set("payment_id", searchText->Js.Json.string) + filters->Js.Dict.set("payment_id", searchText->Js.String2.trim->Js.Json.string) } dict @@ -80,7 +80,7 @@ let make = (~previewOnly=false) => { let customUI = - let filtersUI = React.useMemo1(() => { + let filtersUI = React.useMemo0(() => { { initialFixedFilter setOffset /> - }, []) + })
diff --git a/src/screens/HyperSwitch/Refunds/Refund.res b/src/screens/HyperSwitch/Refunds/Refund.res index bc836fa26..ac78bc357 100644 --- a/src/screens/HyperSwitch/Refunds/Refund.res +++ b/src/screens/HyperSwitch/Refunds/Refund.res @@ -22,8 +22,8 @@ let make = () => { filters->Js.Dict.set("offset", offset->Belt.Int.toFloat->Js.Json.number) if !(searchText->isEmptyString) { - filters->Js.Dict.set("payment_id", searchText->Js.Json.string) - filters->Js.Dict.set("refund_id", searchText->Js.Json.string) + filters->Js.Dict.set("payment_id", searchText->Js.String2.trim->Js.Json.string) + filters->Js.Dict.set("refund_id", searchText->Js.String2.trim->Js.Json.string) } dict