Skip to content
Snippets Groups Projects
Commit e4d2d7da authored by Lukas's avatar Lukas
Browse files

Create single component for all search responses

parent f9570ce0
No related branches found
No related tags found
1 merge request!494Lbudginas/#392 part1 reduce searches component
import { useRef } from "react";
import BlockSearchResults from "./searchesResults/BlockSearchResults";
import CommentPermlinkSearchResults from "./searchesResults/CommentPermlinkSearchResults";
import CommentSearchResults from "./searchesResults/CommentSearchResults";
import AccountSearchResults from "./searchesResults/AccountSearchResults";
import { useSearchesContext } from "@/contexts/SearchesContext";
import useBlockSearch from "@/hooks/api/homePage/useBlockSearch";
import useAccountOperations from "@/hooks/api/accountPage/useAccountOperations";
import useCommentSearch from "@/hooks/api/common/useCommentSearch";
import usePermlinkSearch from "@/hooks/api/common/usePermlinkSearch";
const SearchesResponseSection = () => {
const searchesRef = useRef<HTMLDivElement | null>(null);
const {
blockSearchProps,
accountOperationsSearchProps,
permlinkSearchProps,
commentSearchProps,
lastSearchKey,
} = useSearchesContext();
const { blockSearchData } = useBlockSearch(blockSearchProps);
const { accountOperations } = useAccountOperations(
accountOperationsSearchProps
);
const { permlinkSearchData } = usePermlinkSearch(permlinkSearchProps);
const { commentSearchData } = useCommentSearch(commentSearchProps);
return (
<div
className="pt-4 scroll-mt-16"
ref={searchesRef}
>
{blockSearchData && lastSearchKey === "block" && <BlockSearchResults />}
{accountOperations && lastSearchKey === "account" && (
<AccountSearchResults />
)}
{permlinkSearchData && lastSearchKey === "comment-permlink" && (
<CommentPermlinkSearchResults />
)}
{commentSearchData && lastSearchKey === "comment" && (
<CommentSearchResults />
)}
</div>
);
};
export default SearchesResponseSection;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment