From 666329bdb26a804ae72da72aa6fddfb6df59d000 Mon Sep 17 00:00:00 2001 From: Rupin Khandelwal Date: Wed, 31 Aug 2022 22:58:27 -0500 Subject: [PATCH] Saving the search query in the local storage --- .../templates/library/LibrarySearchBar.tsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/web/components/templates/library/LibrarySearchBar.tsx b/packages/web/components/templates/library/LibrarySearchBar.tsx index 5469faf79..a723de3de 100644 --- a/packages/web/components/templates/library/LibrarySearchBar.tsx +++ b/packages/web/components/templates/library/LibrarySearchBar.tsx @@ -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([])) + //const [recentSearches, setRecentSearches] = useState(Array()) 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() }}