import { SearchIcon } from "@/components/icons/search"; import { Button } from "./ui/button"; import { Input } from "./ui/input"; import { useState } from "react"; import { useNavigate } from "react-router"; interface SearchBoxProps extends React.ComponentProps<"div"> { query: string; setQuery: (q: string) => void; onSearch: () => void; } export function SearchBox({ query = "", setQuery, onSearch, className, ...rest }: SearchBoxProps) { return (
setQuery(e.target.value)} onKeyDown={(e) => { if (e.key === "Enter") { onSearch(); } }} id="search-input" />
); } export function Search(props: React.ComponentProps<"div">) { const [query, setQuery] = useState(""); let navigate = useNavigate(); return ( navigate(`/search?q=${query}`)} {...props} /> ); }