Saving the search query in the local storage

This commit is contained in:
Rupin Khandelwal 2022-08-31 22:58:27 -05:00
parent 04acffd668
commit 666329bdb2

View file

@ -10,10 +10,15 @@ export type LibrarySearchBarProps = {
coordinator: SearchCoordinator
}
// export type searchHistoryProps = {
// searchQuery: string,
// index: number
// }
export function LibrarySearchBar(props: LibrarySearchBarProps): JSX.Element {
const [searchTerm, setSearchTerm] = useState('')
const [recentSearches, setRecentSearches] = useState(Array<any>([]))
//const [recentSearches, setRecentSearches] = useState(Array<searchHistoryProps>())
return (
<>
@ -88,8 +93,10 @@ export function LibrarySearchBar(props: LibrarySearchBarProps): JSX.Element {
style="ctaDarkYellow"
onClick={(event) => {
event.preventDefault()
console.log(searchTerm)
setSearchTerm(searchTerm)
//recentSearches.push({searchQuery: searchTerm, index: recentSearches.length })
localStorage.setItem(searchTerm,searchTerm)
//setRecentSearches(recentSearches)
// props.applySearchQuery('')
// inputRef.current?.blur()
}}