search cleanup
This commit is contained in:
@@ -47,6 +47,21 @@ interface UseDocumentsSearchResult {
|
||||
clearFilters: () => void;
|
||||
handleSearchChange: (value: string) => void;
|
||||
handleSearchSubmit: () => void;
|
||||
documentsFilterValue: {
|
||||
query: string;
|
||||
searchResults: DocumentLike[] | null;
|
||||
searchLoading: boolean;
|
||||
includeDescendants: boolean;
|
||||
activeTagIds: Identifier[];
|
||||
activeCorrespondentIds: Identifier[];
|
||||
isActive: boolean;
|
||||
setQuery: (value: string) => void;
|
||||
submit: () => void;
|
||||
clear: () => void;
|
||||
toggleTag: (tagId: Identifier) => void;
|
||||
toggleCorrespondent: (correspondentId?: Identifier | null) => void;
|
||||
toggleIncludeDescendants: () => void;
|
||||
};
|
||||
}
|
||||
|
||||
const useDocumentsSearch = ({
|
||||
@@ -124,6 +139,39 @@ const useDocumentsSearch = ({
|
||||
}
|
||||
}, [navigate, selectedFolder, isDocumentsRoute, locationPathname]);
|
||||
|
||||
const documentsFilterValue = useMemo(
|
||||
() => ({
|
||||
query: searchQuery,
|
||||
searchResults,
|
||||
searchLoading,
|
||||
includeDescendants: Boolean(searchIncludeDescendants),
|
||||
activeTagIds: activeTagFilters,
|
||||
activeCorrespondentIds: activeCorrespondentFilters,
|
||||
isActive: isFilterActive,
|
||||
setQuery: handleSearchChange,
|
||||
submit: handleSearchSubmit,
|
||||
clear: clearFilters,
|
||||
toggleTag: toggleTagFilter,
|
||||
toggleCorrespondent: toggleCorrespondentFilter,
|
||||
toggleIncludeDescendants: () => setSearchIncludeDescendants(!searchIncludeDescendants),
|
||||
}),
|
||||
[
|
||||
searchQuery,
|
||||
searchResults,
|
||||
searchLoading,
|
||||
searchIncludeDescendants,
|
||||
activeTagFilters,
|
||||
activeCorrespondentFilters,
|
||||
isFilterActive,
|
||||
handleSearchChange,
|
||||
handleSearchSubmit,
|
||||
clearFilters,
|
||||
toggleTagFilter,
|
||||
toggleCorrespondentFilter,
|
||||
setSearchIncludeDescendants,
|
||||
],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (!token) return undefined;
|
||||
|
||||
@@ -237,6 +285,7 @@ const useDocumentsSearch = ({
|
||||
clearFilters,
|
||||
handleSearchChange,
|
||||
handleSearchSubmit,
|
||||
documentsFilterValue,
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user