1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-25 12:56:41 +07:00

removed search reducer completely

This commit is contained in:
Fedor Katurov 2022-01-04 15:51:44 +07:00
parent 38eedab3c2
commit b82ccfb786
22 changed files with 146 additions and 570 deletions

View file

@ -4,38 +4,34 @@ import { useSearch } from '~/hooks/search/useSearch';
export interface SearchContextProps {
searchText: string;
searchTotal: number;
hasMore: boolean;
searchIsLoading: boolean;
searchResults: INode[];
onSearchChange: (text: string) => void;
onSearchLoadMore: () => void;
setSearchText: (text: string) => void;
loadMore: () => void;
}
export const SearchContext = createContext<SearchContextProps>({
searchText: '',
searchTotal: 0,
hasMore: false,
searchIsLoading: false,
searchResults: [],
onSearchChange: () => {},
onSearchLoadMore: () => {},
setSearchText: () => {},
loadMore: () => {},
});
export const SearchContextProvider: FC = ({ children }) => {
const {
search: { text, results, is_loading, total },
onSearchLoadMore,
onSearchChange,
} = useSearch();
const { results, searchText, isLoading, loadMore, setSearchText, hasMore } = useSearch();
return (
<SearchContext.Provider
value={{
searchText: text,
searchText,
searchResults: results,
searchIsLoading: is_loading,
searchTotal: total,
onSearchChange,
onSearchLoadMore,
searchIsLoading: isLoading,
hasMore,
setSearchText,
loadMore,
}}
>
{children}