From 64ed460f9862d7cb8743cdf8aae82bba22c170bf Mon Sep 17 00:00:00 2001 From: sjaanus Date: Thu, 3 Jul 2025 07:21:24 +0300 Subject: [PATCH] Fix --- .../events/EventLog/EventLogFilters.tsx | 58 ++++++++++--------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/frontend/src/component/events/EventLog/EventLogFilters.tsx b/frontend/src/component/events/EventLog/EventLogFilters.tsx index e26bcb6fb3..354ea6f584 100644 --- a/frontend/src/component/events/EventLog/EventLogFilters.tsx +++ b/frontend/src/component/events/EventLog/EventLogFilters.tsx @@ -22,37 +22,39 @@ export const useEventLogFilters = ( const location = useLocation(); const [availableFilters, setAvailableFilters] = useState([]); + const createRemovableFilterOptions = ( + searchParams: URLSearchParams, + paramNames: string[], + ) => { + return paramNames.reduce( + (acc, paramName) => { + const hasParam = searchParams.has(paramName); + const paramValue = searchParams.get(paramName); + + acc[paramName] = + hasParam && paramValue + ? (() => { + const parsed = FilterItemParam.decode(paramValue); + return parsed + ? [ + { + label: parsed.values[0], + value: parsed.values[0], + }, + ] + : []; + })() + : []; + return acc; + }, + {} as Record>, + ); + }; + useEffect(() => { const searchParams = new URLSearchParams(location.search); - const createRemovableFilterOptions = (paramNames: string[]) => { - return paramNames.reduce( - (acc, paramName) => { - const hasParam = searchParams.has(paramName); - const paramValue = searchParams.get(paramName); - - acc[paramName] = - hasParam && paramValue - ? (() => { - const parsed = - FilterItemParam.decode(paramValue); - return parsed - ? [ - { - label: parsed.values[0], - value: parsed.values[0], - }, - ] - : []; - })() - : []; - return acc; - }, - {} as Record>, - ); - }; - - const removableOptions = createRemovableFilterOptions([ + const removableOptions = createRemovableFilterOptions(searchParams, [ 'id', 'groupId', ]);