import { debounce, isEmpty, map } from "lodash"; import React, { ReactElement, useCallback, useState } from "react"; import { useDispatch, useSelector } from "react-redux"; import Card from "../shared/Carda"; import { searchIssue } from "../../actions/fileops.actions"; import MetadataPanel from "../shared/MetadataPanel"; interface ISearchBarProps { data: any; } export const SearchBar = (data: ISearchBarProps): ReactElement => { const dispatch = useDispatch(); const searchResults = useSelector( (state: RootState) => state.fileOps.librarySearchResultsFormatted, ); const performSearch = useCallback( debounce((e) => { dispatch( searchIssue( { query: { volumeName: e.target.value, }, }, { pagination: { size: 25, from: 0, }, type: "volumeName", trigger: "globalSearchBar", }, ), ); }, 500), [data], ); return ( <>