import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { isEmptyString } from "@/lib/utils"; import { type ChangeEvent, type KeyboardEvent, useEffect, useState } from "react"; export const SearchInput = (props: { handleSearch: (word: string) => any; isLoading: boolean; word?: string | null; }) => { const [searchText, setSearchText] = useState(props.word ?? ""); useEffect(() => { if (!isEmptyString(searchText)) { props.handleSearch(searchText); } }, []); const handleInputSearchText = (event: ChangeEvent) => { setSearchText(event.target.value); }; const handleEnterKeySearch = (event: KeyboardEvent) => { if (event.key === "Go" || event.key === "Enter") { props.handleSearch(searchText); } }; return (
); };