Spaces:
Build error
Build error
File size: 1,536 Bytes
caae15f 7d9d30d caae15f 7d9d30d caae15f 7d9d30d caae15f 7d9d30d caae15f 7d9d30d caae15f 7d9d30d caae15f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
// SearchSection.tsx
"use client";
import { useState, ChangeEvent, FormEvent } from "react";
import useSearch from "@/app/components/ui/search/useSearch";
import SearchResults from "@/app/components/ui/search/search-results";
import SearchInput from "@/app/components/ui/search/search-input";
import AutofillSearchQuery from "@/app/components/ui/autofill-prompt/autofill-search-prompt-dialog";
const SearchSection: React.FC = () => {
const [query, setQuery] = useState("");
const { searchResults, isLoading, handleSearch } = useSearch();
const [searchButtonPressed, setSearchButtonPressed] = useState(false);
const handleInputChange = (e: ChangeEvent<HTMLInputElement>) => {
setQuery(e.target.value);
setSearchButtonPressed(false);
};
const handleSearchSubmit = (e: FormEvent) => {
e.preventDefault();
setSearchButtonPressed(true);
handleSearch(query);
};
return (
<div className="space-y-4 max-w-5xl w-full">
<SearchInput
query={query}
isLoading={isLoading}
results={searchResults}
onInputChange={handleInputChange}
onSearchSubmit={handleSearchSubmit}
/>
<AutofillSearchQuery
query={query}
isLoading={isLoading}
results={searchResults}
onInputChange={handleInputChange}
onSearchSubmit={handleSearchSubmit}
/>
<SearchResults query={query} results={searchResults} isLoading={isLoading} searchButtonPressed={searchButtonPressed} />
</div>
);
};
export default SearchSection;
|