Spaces:
Runtime error
Runtime error
File size: 1,643 Bytes
cd6f98e |
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 50 |
import type { ChangeEvent, FC } from "react";
import React from "react";
interface SearchBarProps {
setSearchQuery: (query: string) => void;
setCategory: (category: string) => void;
}
const SearchBar: FC<SearchBarProps> = ({ setSearchQuery, setCategory }) => {
const handleSearchChange = (e: ChangeEvent<HTMLInputElement>) => {
setSearchQuery(e.target.value);
};
const handleCategoryChange = (e: ChangeEvent<HTMLSelectElement>) => {
setCategory(e.target.value);
};
return (
<div className="flex flex-row items-center gap-2 py-2">
<div className="flex w-full flex-grow space-x-2">
<input
type="search"
className="flex-grow rounded-md border border-white/20 bg-zinc-900 py-1 text-white placeholder-white shadow-sm focus:border-white focus:outline-none focus:ring-white"
placeholder="Search"
aria-label="Search"
aria-describedby="button-addon2"
onChange={handleSearchChange}
/>
</div>
<div className="w-full sm:w-auto">
<select
id="category"
name="category"
className="block w-full rounded-md border border-white/20 bg-zinc-900 px-2 py-1 text-white shadow-sm focus:border-white focus:outline-none focus:ring-white sm:text-sm"
onChange={handleCategoryChange}
>
<option value="">All</option>
<option>Health and Fitness</option>
<option>Creative and social</option>
<option>Academics and Professional</option>
<option>Other</option>
</select>
</div>
</div>
);
};
export default SearchBar;
|