diff --git a/client/src/App.tsx b/client/src/App.tsx index 9fcfeaf..eb52246 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -6,6 +6,7 @@ import { TooltipProvider } from "@/components/ui/tooltip"; import NotFound from "@/pages/not-found"; import Home from "@/pages/Home"; import Explore from "@/pages/Explore"; +import Search from "@/pages/Search"; import AuthorProfile from "@/pages/authors/AuthorProfile"; import Authors from "@/pages/authors/Authors"; import WorkReading from "@/pages/works/WorkReading"; @@ -21,6 +22,7 @@ function Router() { + diff --git a/client/src/components/common/SearchBar.tsx b/client/src/components/common/SearchBar.tsx index 7e4e0b9..cd8d92d 100644 --- a/client/src/components/common/SearchBar.tsx +++ b/client/src/components/common/SearchBar.tsx @@ -81,12 +81,12 @@ export function SearchBar({ setQuery(e.target.value)} onFocus={() => setIsFocused(true)} /> - + {query && ( + )} + + + + + + {/* Tab Navigation */} +
+ + + All Results + Works + Authors + Advanced + + + +
+ +
+ View: + + +
+
+
+ +
+ {/* Show filter sidebar in Advanced tab */} + {(activeTab === 'advanced' || showFilters) && ( + + )} + + {/* Results area */} +
+ {/* Query info */} + {query && query.length >= 2 && ( +
+ {isLoading ? ( +

Searching for "{query}"...

+ ) : ( +

+ Showing results for "{query}" + {activeTab !== 'advanced' && searchResults && ( + - {searchResults.works.length} works, {searchResults.authors.length} authors found + )} + {activeTab === 'advanced' && filteredWorks && ( + - {filteredWorks.length} works match your filters + )} +

+ )} +
+ )} + + {/* Authors section in all or authors tab */} + {(activeTab === 'all' || activeTab === 'authors') && query.length >= 2 && ( + <> + {activeTab === 'all' && searchResults?.authors && searchResults.authors.length > 0 && ( +

Authors

+ )} + + {isLoading ? ( +
+ {Array.from({ length: 3 }).map((_, i) => ( + + +
+
+
+
+
+
+
+
+
+
+ ))} +
+ ) : ( + <> + {searchResults?.authors && searchResults.authors.length > 0 && ( +
+ {searchResults.authors.map((author) => ( + + + +

+ {author.biography?.slice(0, 120)}... +

+ +
+
+ ))} +
+ )} + + {hasNoAuthors && activeTab === 'authors' && ( +
+

No authors found matching "{query}"

+

Try a different search term or check your spelling

+
+ )} + + )} + + )} + + {/* Works section */} + {(activeTab === 'all' || activeTab === 'works' || activeTab === 'advanced') && ( + <> + {activeTab === 'all' && searchResults?.works && searchResults.works.length > 0 && ( +

Works

+ )} + + {isLoading ? ( + viewMode === 'list' ? ( +
+ {Array.from({ length: 5 }).map((_, i) => ( +
+ ))} +
+ ) : ( +
+ {Array.from({ length: 6 }).map((_, i) => ( +
+ ))} +
+ ) + ) : ( + <> + {displayWorks.length > 0 ? ( + viewMode === 'list' ? ( +
+ {displayWorks.map((work) => ( + + ))} +
+ ) : ( +
+ {displayWorks.map((work) => ( + + ))} +
+ ) + ) : hasNoResults && ( +
+

No works found matching "{query}"

+

+ {activeTab === 'advanced' + ? 'Try adjusting your filters or using different search terms' + : 'Try a different search term or check your spelling'} +

+
+ )} + + )} + + )} + + {/* Entry prompt when search is empty */} + {query.length < 2 && ( +
+ +

Start Your Literary Journey

+

+ Enter a search term above to discover works by title, author, or keyword +

+
+ {['Poetry', 'Novel', 'Tolstoy', 'Shakespeare', 'Modernism', 'Love'].map((term) => ( + + ))} +
+
+ )} + + {/* Pagination */} + {totalPages > 1 && !isLoading && ( +
+ +
+ )} +
+
+ + + ); +} \ No newline at end of file